|
| 1 | +import { FC, useEffect, useState } from "react"; |
| 2 | +import { View } from "../../pages/Login"; |
| 3 | +import { Transition } from "@headlessui/react"; |
| 4 | + |
| 5 | +interface LoginViewProps { |
| 6 | + changeView: React.Dispatch<React.SetStateAction<View>>; |
| 7 | + setNotificationShowing: React.Dispatch<React.SetStateAction<boolean>>; |
| 8 | +} |
| 9 | + |
| 10 | +export const ForgotPasswordView: FC<LoginViewProps> = ({ |
| 11 | + changeView, |
| 12 | + setNotificationShowing, |
| 13 | +}) => { |
| 14 | + return ( |
| 15 | + <div className="space-y-6"> |
| 16 | + <div> |
| 17 | + <label |
| 18 | + htmlFor="email" |
| 19 | + className="block text-sm font-medium text-gray-700" |
| 20 | + > |
| 21 | + Email address |
| 22 | + </label> |
| 23 | + <div className="mt-1"> |
| 24 | + <input |
| 25 | + id="email" |
| 26 | + name="email" |
| 27 | + type="email" |
| 28 | + autoComplete="email" |
| 29 | + className="transition duration-500 appearance-none block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" |
| 30 | + /> |
| 31 | + </div> |
| 32 | + </div> |
| 33 | + |
| 34 | + <div> |
| 35 | + <button |
| 36 | + onClick={() => { |
| 37 | + changeView(View.Login); |
| 38 | + setNotificationShowing(true); |
| 39 | + }} |
| 40 | + className="transition w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-cyan-600 hover:bg-cyan-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-cyans-500" |
| 41 | + > |
| 42 | + Reset Password |
| 43 | + </button> |
| 44 | + </div> |
| 45 | + |
| 46 | + <div className="text-right"> |
| 47 | + <div className="text-sm"> |
| 48 | + <a |
| 49 | + onClick={() => changeView(View.Login)} |
| 50 | + className="font-medium text-cyan-600 hover:text-cyan-500 cursor-pointer" |
| 51 | + > |
| 52 | + Back to Login |
| 53 | + </a> |
| 54 | + </div> |
| 55 | + </div> |
| 56 | + </div> |
| 57 | + ); |
| 58 | +}; |
| 59 | + |
| 60 | +interface ResetNotificationProps { |
| 61 | + showing: boolean; |
| 62 | + setShowing: React.Dispatch<React.SetStateAction<boolean>>; |
| 63 | +} |
| 64 | + |
| 65 | +export const ResetNotification: FC<ResetNotificationProps> = ({ |
| 66 | + showing, |
| 67 | + setShowing, |
| 68 | +}: ResetNotificationProps) => { |
| 69 | + useEffect(() => { |
| 70 | + if (showing) { |
| 71 | + setTimeout(() => { |
| 72 | + setShowing(false); |
| 73 | + }, 2500); |
| 74 | + } |
| 75 | + }); |
| 76 | + |
| 77 | + return ( |
| 78 | + <Transition |
| 79 | + show={showing} |
| 80 | + enter="transition duration-500 ease-out" |
| 81 | + enterFrom="opacity-0" |
| 82 | + enterTo="opacity-100" |
| 83 | + leave="transition duration-500" |
| 84 | + leaveFrom="opacity-100" |
| 85 | + leaveTo="opacity-0" |
| 86 | + > |
| 87 | + <div className="fixed inset-0 flex items-end justify-center px-4 py-6 pointer-events-none sm:p-6 sm:items-start sm:justify-end"> |
| 88 | + <div |
| 89 | + x-data="{ show: true }" |
| 90 | + x-show="show" |
| 91 | + x-description="Notification panel, show/hide based on alert state." |
| 92 | + className="max-w-sm w-full bg-white shadow-lg rounded-lg pointer-events-auto ring-1 ring-black ring-opacity-5 overflow-hidden" |
| 93 | + > |
| 94 | + <div className="p-4"> |
| 95 | + <div className="flex items-start"> |
| 96 | + <div className="flex-shrink-0"> |
| 97 | + <svg |
| 98 | + className="h-6 w-6 text-green-400" |
| 99 | + x-description="Heroicon name: check-circle" |
| 100 | + xmlns="http://www.w3.org/2000/svg" |
| 101 | + fill="none" |
| 102 | + viewBox="0 0 24 24" |
| 103 | + stroke="currentColor" |
| 104 | + aria-hidden="true" |
| 105 | + > |
| 106 | + <path |
| 107 | + stroke-linecap="round" |
| 108 | + stroke-linejoin="round" |
| 109 | + stroke-width="2" |
| 110 | + d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" |
| 111 | + ></path> |
| 112 | + </svg> |
| 113 | + </div> |
| 114 | + <div className="ml-3 w-0 flex-1 pt-0.5"> |
| 115 | + <p className="ztext-sm font-medium text-gray-900"> |
| 116 | + Reset Email Sent! |
| 117 | + </p> |
| 118 | + <p className="mt-1 text-sm text-gray-500"> |
| 119 | + Please check your inbox to reset your password. |
| 120 | + </p> |
| 121 | + </div> |
| 122 | + <div className="ml-4 flex-shrink-0 flex"> |
| 123 | + <button |
| 124 | + onClick={() => setShowing(false)} |
| 125 | + className="bg-white rounded-md inline-flex text-gray-400 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500" |
| 126 | + > |
| 127 | + <span className="sr-only">Close</span> |
| 128 | + <svg |
| 129 | + className="h-5 w-5" |
| 130 | + x-description="Heroicon name: x" |
| 131 | + xmlns="http://www.w3.org/2000/svg" |
| 132 | + viewBox="0 0 20 20" |
| 133 | + fill="currentColor" |
| 134 | + aria-hidden="true" |
| 135 | + > |
| 136 | + <path |
| 137 | + fill-rule="evenodd" |
| 138 | + d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" |
| 139 | + clip-rule="evenodd" |
| 140 | + ></path> |
| 141 | + </svg> |
| 142 | + </button> |
| 143 | + </div> |
| 144 | + </div> |
| 145 | + </div> |
| 146 | + </div> |
| 147 | + </div> |
| 148 | + </Transition> |
| 149 | + ); |
| 150 | +}; |
0 commit comments