"use client"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { cn } from "@/lib/utils"; import { VerifyRegistrationOTP } from "@/queries/authentication"; import { Loader2 } from "lucide-react"; import Link from "next/link"; import { redirect, useSearchParams } from "next/navigation"; import { useActionState } from "react"; export default function VerifyRegistrationOTPForm({ phone_number, }: { phone_number: string }) { console.log("verification in OTP form", phone_number); const searchParams = useSearchParams(); const mobile = searchParams.get("phone_number"); if (!mobile) redirect("/auth/login"); const [state, formAction, isPending] = useActionState(VerifyRegistrationOTP, { message: "", status: "", }); return (
{state.status === "verify_success" ? (

{state.message}

) : (

Account verification OTP sent to [{phone_number}]

)} {state?.status === "error" && (

{state.message}

)} {state.status === "verify_error" && (

{state.message}

)}
{state.status === "verify_success" && (
Go to{" "} login
)}
); }