import { Center, HStack, Image, Input, Text, VStack } from "@chakra-ui/react"; import { useContext, useState } from "react"; import { useForm } from "react-hook-form"; import GlobalStateContext from "../../Contexts/GlobalStateContext"; import logo from "../../assets/logo.svg"; import { Button } from "../../components/ui/button"; import { Field } from "../../components/ui/field"; import { Toaster, toaster } from "../../components/ui/toaster"; interface FormValues { password: string; confirmPassword: string; } const CreatePass = () => { const [isLoading, setIsLoading] = useState(false); const context = useContext(GlobalStateContext); if (!context) { throw new Error("App must be used within a GlobalStateProvider"); } const { setIsAuthenticate } = context; const { register, handleSubmit, formState: { errors }, } = useForm(); const onSubmit = handleSubmit((data) => { setIsLoading(true); if (data?.password === "password123") { setTimeout(() => { setIsAuthenticate(true); setIsLoading(false); }, 3000); } else { toaster.create({ title: `Invalid Credentials`, type: "error", }); setIsLoading(false); } }); return (
create a password value === getValues("password") || "Passwords do not match", })} placeholder="Confirm your password" /> Forgot password
); }; export default CreatePass;