Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /* eslint-disable react/no-unescaped-entities */ import React, { useState } from 'react'; import Image from 'next/image'; import { useRouter } from 'next/router'; import { useForm } from 'react-hook-form'; import { yupResolver } from '@hookform/resolvers/yup'; import { object, string } from 'yup'; import { signIn } from 'next-auth/react'; import { ToastContainer, toast } from "react-toastify"; import InputErrors from '@/components/ui/form/InputErrors'; const LoginForm = () => { const { register, handleSubmit, formState } = useForm({ resolver: yupResolver( object().shape({ email: string().required('The email field is required').email('Please Enter a Valid Email Address.'), password: string().required('The password field is required.') }) ) }); const { errors } = formState; const router = useRouter(); const onSubmit = async (data:any, e:any) => { e.preventDefault(); setButtonDisable(true); setLoginButtonText("Please wait..."); const response = await signIn('credentials', { email: data.email, password: data.password, callbackUrl: `${window.location.origin}`, redirect: false }); if (response?.ok === true) { setButtonDisable(false); setLoginButtonText(`LOGIN`); router.push('/dashboard'); } else { toast.error(response?.error); setButtonDisable(false); setLoginButtonText(`LOGIN`); } }; const [showPassword, setShowPassword] = useState(false); const [buttonDisable, setButtonDisable] = useState(false); const [loginButtonText, setLoginButtonText] = useState('LOGIN'); return ( <div className="card card1"> <ToastContainer /> <div className="row justify-content-center my-auto"> <div className="col-md-10 col-10 my-3"> <div className="row justify-content-center px-3"> <Image src='/images/login-logo.svg' alt="" width={250} height={250} id="logo" /> </div> <h3 className="text-center heading">Login</h3> <form onSubmit={handleSubmit(onSubmit)}> <div className="form-group"> <input {...register('email')} type="email" id="email" name="email" placeholder="User Name" className={`form-control ${errors.email ? 'is-invalid' : ''}`} /> <span className="icon_input"> <Image width={20} height={20} src='/images/email-user.svg' alt="email icon" /> </span> <InputErrors errorField={errors.email} message={errors.email?.message?.toString()} /> </div> <div className="form-group"> <input type={showPassword ? 'text' : 'password'} {...register('password')} id="psw" name="password" placeholder="password" className={`form-control ${errors.password ? 'is-invalid' : ''}`} /> <span className="icon_input"> <Image className='passwordIcon' onClick={() => setShowPassword(!showPassword)} alt="password" width={20} height={20} src={showPassword ? '/images/hidepassword.png' : '/images/password.png' } /> </span> <InputErrors errorField={errors.password} message={errors.password?.message?.toString()} /> </div> <div className="form-group"> <div className="check_btn"> <div className="forgot_block"> <input className="form-check-input" type="checkbox" id="inlineCheckbox1" value="option1" /> <label className="form-check-label" htmlFor="inlineCheckbox1"> Keep me Logged In </label> </div> <div className="my-2"> <a href="#" className="forgot_p"> Forgot Password? </a> </div> </div> </div> <div className="row justify-content-center my-3 px-3"> <button type="submit" className="btn-block btn-color" disabled={buttonDisable} > {loginButtonText} </button> </div> </form> </div> </div> <div className="bottom text-center"> <p className="sm-text mx-auto mb-3"> Don't have an account? <a href="#">Register Now</a> </p> </div> </div> ); }; export default LoginForm; |