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 { mobileNumber: number } const Login = () => { 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?.mobileNumber === 1234567890) { setTimeout(() => { setIsAuthenticate(true); setIsLoading(false) }, 3000); // 3-second delay } else { toaster.create({ title: `Invalid Credentials`, type: "error", }) setIsLoading(false) } }); return (
LOGIN {/* Forget password */} Forgot password
) } export default Login