"use client"; // import { useSignIn } from "@clerk/nextjs"; // import { OTPInput, SlotProps } from "input-otp"; import { useRouter } from "next/navigation"; import * as React from "react"; import { Loading } from "@/components/ui/loading"; import { toast } from "@/components/ui/toaster"; import { cn } from "@/lib/utils"; import { useTranslation } from "react-i18next"; // import { Minus } from "lucide-react"; type Props = { setError: (s: string) => void; }; export const EmailCode: React.FC = ({ setError }) => { const router = useRouter(); const { t } = useTranslation(); // const { signIn, isLoaded: signInLoaded, setActive } = useSignIn(); const [isLoading, setIsLoading] = React.useState(false); const verifyCode = async (otp: string) => { console.log("verifying", otp); setIsLoading(true); setIsLoading(false); }; const resendCode = async () => { // try { // const firstFactor = signIn?.supportedFirstFactors.find((f) => f.strategy === "email_code") as // | { emailAddressId: string } // | undefined; // if (!firstFactor) { // return null; // } // const p = signIn!.prepareFirstFactor({ // strategy: "email_code", // emailAddressId: firstFactor.emailAddressId, // }); // toast.promise(p, { // loading: "Sending new code ...", // success: "A new code has been sent to your email", // }); // await p; // } catch (error) { // setIsLoading(false); // setError((error as Error).message); // console.error(error); // } }; const [otp, setOtp] = React.useState(""); return (

{t("auth.security_code_sent")}

{t("auth.to_continue_text")}

{t("auth.receive_code")}{" "}

verifyCode(otp)}> {/* verifyCode(otp)} maxLength={6} render={({ slots }) => (
{slots.slice(0, 3).map((slot, idx) => ( // biome-ignore lint/suspicious/noArrayIndexKey: I have nothing better ))} {slots.slice(3).map((slot, idx) => ( // biome-ignore lint/suspicious/noArrayIndexKey: I have nothing better ))}
)} />*/}
); }; // const Slot: React.FC = (props) => ( //
// {props.char !== null &&
{props.char}
} //
// );