This commit is contained in:
parent
c18a99dfdb
commit
a256ccc05d
|
|
@ -22,38 +22,16 @@ type Props = {
|
||||||
export const EmailCode: React.FC<Props> = ({ setError, emailValue, passwordValue }) => {
|
export const EmailCode: React.FC<Props> = ({ setError, emailValue, passwordValue }) => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
// const { signUp, isLoaded: signUpLoaded, setActive } = useSignUp();
|
|
||||||
|
|
||||||
const [isLoading, setIsLoading] = React.useState(false);
|
const [isLoading, setIsLoading] = React.useState(false);
|
||||||
const [_timeLeft, _setTimeLeft] = React.useState(0);
|
const [_timeLeft, _setTimeLeft] = React.useState(0);
|
||||||
|
|
||||||
const verifyCode = async (otp: string) => {
|
const verifyCode = async (otp: string) => {
|
||||||
// if (!signUpLoaded || typeof otp !== "string") {
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
console.log("verifyCode", otp, passwordValue,
|
console.log("verifyCode", otp, passwordValue,
|
||||||
// typeof passwordValue, md5(passwordValue), passwordValue === '123456'
|
|
||||||
)
|
)
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
// await signUp
|
|
||||||
// .attemptEmailAddressVerification({
|
|
||||||
// code: otp,
|
|
||||||
// })
|
|
||||||
// .then((result) => {
|
|
||||||
// if (result.status === "complete" && result.createdSessionId) {
|
|
||||||
// setActive({ session: result.createdSessionId }).then(() => {
|
|
||||||
// router.push("/new");
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .catch((err) => {
|
|
||||||
// setIsLoading(false);
|
|
||||||
// setError(err.errors.at(0)?.longMessage ?? "Unknown error, pleae contact support@unkey.dev");
|
|
||||||
// });
|
|
||||||
|
|
||||||
// debug
|
|
||||||
// otp = "88888888"
|
|
||||||
|
|
||||||
await service.post('/api/v1/customer/register', {
|
await service.post('/api/v1/customer/register', {
|
||||||
user_name: emailValue,
|
user_name: emailValue,
|
||||||
|
|
@ -74,8 +52,6 @@ export const EmailCode: React.FC<Props> = ({ setError, emailValue, passwordValue
|
||||||
toast.success(result.header.message)
|
toast.success(result.header.message)
|
||||||
|
|
||||||
router.push("/auth/sign-in");
|
router.push("/auth/sign-in");
|
||||||
|
|
||||||
|
|
||||||
// 自身方法
|
// 自身方法
|
||||||
// localStorage.setItem("data", JSON.stringify(result.data));
|
// localStorage.setItem("data", JSON.stringify(result.data));
|
||||||
// []方法
|
// []方法
|
||||||
|
|
@ -84,12 +60,7 @@ export const EmailCode: React.FC<Props> = ({ setError, emailValue, passwordValue
|
||||||
}).catch((err: any) => {
|
}).catch((err: any) => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
// if (err.errors[0].code === "form_identifier_not_found") {
|
|
||||||
// props.setAccountNotFound(true);
|
|
||||||
// props.email(email);
|
|
||||||
// } else {
|
|
||||||
// props.setError("Sorry, We couldn't sign you in. Please try again later");
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -112,21 +83,9 @@ export const EmailCode: React.FC<Props> = ({ setError, emailValue, passwordValue
|
||||||
|
|
||||||
toast.success(result.header.message)
|
toast.success(result.header.message)
|
||||||
|
|
||||||
|
|
||||||
// 自身方法
|
|
||||||
// localStorage.setItem("data", JSON.stringify(result.data));
|
|
||||||
// []方法
|
|
||||||
{ {/* localStorage["name"]="bonly"; */ } }
|
|
||||||
|
|
||||||
}).catch((err: any) => {
|
}).catch((err: any) => {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
console.log(err);
|
console.log(err);
|
||||||
// if (err.errors[0].code === "form_identifier_not_found") {
|
|
||||||
// props.setAccountNotFound(true);
|
|
||||||
// props.email(email);
|
|
||||||
// } else {
|
|
||||||
// props.setError("Sorry, We couldn't sign you in. Please try again later");
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
|
|
@ -156,27 +115,14 @@ export const EmailCode: React.FC<Props> = ({ setError, emailValue, passwordValue
|
||||||
render={({ slots }) => (
|
render={({ slots }) => (
|
||||||
<div className="flex items-center justify-between">
|
<div className="flex items-center justify-between">
|
||||||
{slots.slice(0, 3).map((slot, idx) => (
|
{slots.slice(0, 3).map((slot, idx) => (
|
||||||
// biome-ignore lint/suspicious/noArrayIndexKey: I have nothing better
|
|
||||||
<Slot key={idx} {...slot} />
|
<Slot key={idx} {...slot} />
|
||||||
))}
|
))}
|
||||||
{/* <Minus className="w-6 h-6 text-white/15" /> */}
|
|
||||||
{slots.slice(3).map((slot, idx) => (
|
{slots.slice(3).map((slot, idx) => (
|
||||||
// biome-ignore lint/suspicious/noArrayIndexKey: I have nothing better
|
|
||||||
<Slot key={idx} {...slot} />
|
<Slot key={idx} {...slot} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* <button
|
|
||||||
type="submit"
|
|
||||||
className="flex items-center justify-center h-10 gap-2 px-4 text-sm font-semibold text-white duration-200 bg-black border border-white rounded-lg hover:border-black/30 hover:bg-black hover:text-black"
|
|
||||||
disabled={isLoading}
|
|
||||||
onClick={() => verifyCode(otp)}
|
|
||||||
>
|
|
||||||
{isLoading ? <Loading className="w-4 h-4 mr-2 animate-spin" /> : null}
|
|
||||||
Continue
|
|
||||||
</button> */}
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<p className="mt-2 text-sm text-right text-black/40">
|
<p className="mt-2 text-sm text-right text-black/40">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue