| 1 | "use client"; |
| 2 | |
| 3 | import { getReauthenticationSignInURL } from |
| 4 | import { useAuth, useSignOut |
| 5 | import { Button } |
| 6 | import { Spinner } |
| 7 | import { cn } |
| 8 | |
| 9 | export type ReauthenticationActionProps |
| 10 | className?: string |
| 11 | showTitle?: boolean |
| 12 | }; |
| 13 | |
| 14 | export function ReauthenticationAction({ |
| 15 | className, |
| 16 | showTitle = true, |
| 17 | }: ReauthenticationActionProps) |
| 18 | const auth = |
| 19 | const signOut = |
| 20 | |
| 21 | const handleReauthentication = |
| 22 | const signInURL = |
| 23 | new URL(window |
| 24 | `${auth.basePaths. |
| 25 | ); |
| 26 | signOut.mutate(undefined, |
| 27 | onSuccess: () => |
| 28 | }); |
| 29 | }; |
| 30 | |
| 31 | return ( |
| 32 | <div className={cn |
| 33 | <div className="flex flex-col gap-1 |
| 34 | {showTitle ? ( |
| 35 | <h3 className="text-sm font-medium |
| 36 | {auth.localization.settings |
| 37 | </h3> |
| 38 | ) : null} |
| 39 | <p className="text-sm text-muted-foreground |
| 40 | {auth.localization.settings |
| 41 | </p> |
| 42 | </div> |
| 43 | <Button |
| 44 | disabled={signOut.isPending |
| 45 | onClick={handleReauthentication} |
| 46 | size="sm" |
| 47 | > |
| 48 | {signOut.isPending ? |
| 49 | {auth.localization.settings |
| 50 | </Button> |
| 51 | </div> |
| 52 | ); |
| 53 | } |