This commit is contained in:
2024-11-27 07:48:16 +05:00
parent 7389de4c76
commit 7fadcd561f
17 changed files with 454 additions and 189 deletions

View File

@ -15,14 +15,13 @@ import { z } from "zod";
const OTPSchema = z.object({
pin: z.string().min(6, {
message: "Your one-time password must be 6 characters.",
}),
});
export default function VerifyOTPForm() {
export default function VerifyOTPForm({ phone_number }: { phone_number: string }) {
const [isPending, startTransition] = useTransition();
const router = useRouter();
console.log("verification in OTP form", phone_number)
const {
register,
handleSubmit,
@ -35,13 +34,13 @@ export default function VerifyOTPForm() {
});
const onSubmit: SubmitHandler<z.infer<typeof OTPSchema>> = (data) => {
console.log(data);
startTransition(async () => {
const isVerified = await authClient.phoneNumber.verify({
phoneNumber: "+9607780588",
phoneNumber: phone_number,
code: data.pin,
});
console.log({ isVerified });
if (!isVerified.error) {
router.push("/devices");
} else {
@ -53,9 +52,8 @@ export default function VerifyOTPForm() {
return (
<form
onSubmit={handleSubmit(onSubmit)}
className="bg-white dark:bg-gray-900 w-full max-w-xs rounded-lg shadow my-4 "
className="bg-white dark:bg-gray-900 w-full max-w-xs rounded-lg shadow my-4"
>
<h4 className="text-center rounded m-2 text-xl font-bold text-gray-600 bg-gray-200 py-4">Verify OTP</h4>
<div className="grid pb-4 pt-2 gap-4 px-10">
<div className="">
<Label htmlFor="otp-number" className="text-gray-500">