| 1 | "use client"; |
| 2 | |
| 3 | import { getAuthLinkURL } from |
| 4 | import { useAuth } |
| 5 | import { Card, CardContent |
| 6 | import { FieldDescription } |
| 7 | import { cn } |
| 8 | import { OpenEmailButton } |
| 9 | import { useIsHydrated } |
| 10 | |
| 11 | /** `sessionStorage` key the forgot-password form stores the submitted email under. */ |
| 12 | export const RESET_LINK_SENT_STORAGE_KEY = |
| 13 | |
| 14 | export type ResetLinkSentProps |
| 15 | className?: string |
| 16 | }; |
| 17 | |
| 18 | /** Render a card confirming that a password-reset email was sent, with a button to open the user's email provider. */ |
| 19 | export function ResetLinkSent({ |
| 20 | const { basePaths, |
| 21 | |
| 22 | const isHydrated = |
| 23 | const email = |
| 24 | (isHydrated && sessionStorage |
| 25 | |
| 26 | return ( |
| 27 | <Card className={ |
| 28 | <CardHeader> |
| 29 | <CardTitle className=" |
| 30 | {localization.auth.checkYourEmailTitle |
| 31 | </CardTitle> |
| 32 | </CardHeader> |
| 33 | |
| 34 | <CardContent> |
| 35 | <div className="flex flex-col gap-4 |
| 36 | <FieldDescription> |
| 37 | {email |
| 38 | ? localization.auth. |
| 39 | : localization.auth. |
| 40 | </FieldDescription> |
| 41 | |
| 42 | {email && <OpenEmailButton |
| 43 | </div> |
| 44 | |
| 45 | <div className="flex flex-col gap-3 items-center w-full mt-4 |
| 46 | <FieldDescription className=" |
| 47 | {localization.auth.rememberYourPassword |
| 48 | <Link |
| 49 | href={getAuthLinkURL( |
| 50 | `${basePaths.auth} |
| 51 | redirectTo, |
| 52 | )} |
| 53 | className="underline underline-offset-4" |
| 54 | > |
| 55 | {localization.auth.signIn |
| 56 | </Link> |
| 57 | </FieldDescription> |
| 58 | </div> |
| 59 | </CardContent> |
| 60 | </Card> |
| 61 | ); |
| 62 | } |