|
| 1 | +import { useForm } from "react-hook-form"; |
| 2 | +import { Link } from "react-router-dom"; |
| 3 | + |
| 4 | +export default function ForgotPassword() { |
| 5 | + const { |
| 6 | + register, |
| 7 | + handleSubmit, |
| 8 | + formState: { errors }, |
| 9 | + } = useForm(); |
| 10 | + |
| 11 | + console.log(errors); |
| 12 | + return ( |
| 13 | + <> |
| 14 | + <div className="flex min-h-full flex-1 flex-col justify-center px-6 py-12 lg:px-8"> |
| 15 | + <div className="sm:mx-auto sm:w-full sm:max-w-sm"> |
| 16 | + <img |
| 17 | + className="mx-auto h-10 w-auto" |
| 18 | + src="https://tailwindui.com/img/logos/mark.svg?color=indigo&shade=600" |
| 19 | + alt="Your Company" |
| 20 | + /> |
| 21 | + <h2 className="mt-10 text-center text-2xl font-bold leading-9 tracking-tight text-gray-900"> |
| 22 | + Enter Email to Reset Password |
| 23 | + </h2> |
| 24 | + </div> |
| 25 | + |
| 26 | + <div className="mt-10 sm:mx-auto sm:w-full sm:max-w-sm"> |
| 27 | + <form |
| 28 | + noValidate |
| 29 | + className="space-y-6" |
| 30 | + onSubmit={handleSubmit((data) => { |
| 31 | + console.log(data); |
| 32 | + // TODO: implementation on backend with email |
| 33 | + })} |
| 34 | + > |
| 35 | + <div> |
| 36 | + <label |
| 37 | + htmlFor="email" |
| 38 | + className="block text-sm font-medium leading-6 text-gray-900" |
| 39 | + > |
| 40 | + Email address |
| 41 | + </label> |
| 42 | + <div className="mt-2"> |
| 43 | + <input |
| 44 | + id="email" |
| 45 | + {...register("email", { |
| 46 | + required: "email is required", |
| 47 | + pattern: { |
| 48 | + value: /\b[\w\.-]+@[\w\.-]+\.\w{2,4}\b/gi, |
| 49 | + message: "email is not valid", |
| 50 | + }, |
| 51 | + })} |
| 52 | + type="email" |
| 53 | + className="block w-full rounded-md border-0 py-1.5 text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6" |
| 54 | + /> |
| 55 | + {errors.email && ( |
| 56 | + <p className="text-red-500">{errors.email.message}</p> |
| 57 | + )} |
| 58 | + </div> |
| 59 | + </div> |
| 60 | + |
| 61 | + <div> |
| 62 | + <button |
| 63 | + type="submit" |
| 64 | + className="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600" |
| 65 | + > |
| 66 | + Log in |
| 67 | + </button> |
| 68 | + </div> |
| 69 | + </form> |
| 70 | + |
| 71 | + <p className="mt-10 text-center text-sm text-gray-500"> |
| 72 | + Send me back to{" "} |
| 73 | + <Link |
| 74 | + to="/login" |
| 75 | + className="font-semibold leading-6 text-indigo-600 hover:text-indigo-500" |
| 76 | + > |
| 77 | + Login |
| 78 | + </Link> |
| 79 | + </p> |
| 80 | + </div> |
| 81 | + </div> |
| 82 | + </> |
| 83 | + ); |
| 84 | +} |
0 commit comments