| 1 | "use client"; |
| 2 | |
| 3 | import { useLastLoginMethod } from |
| 4 | |
| 5 | import { Badge } |
| 6 | |
| 7 | export type LastUsedBadgeProps |
| 8 | /** Login method IDs that should display the indicator. */ |
| 9 | method: string |
| 10 | /** Use the shorter label in constrained layouts. */ |
| 11 | compact?: boolean |
| 12 | /** Float the compact indicator over the top-right edge of its container. */ |
| 13 | floating?: boolean |
| 14 | }; |
| 15 | |
| 16 | /** Displays an indicator when one of the supplied method IDs matches Better Auth's stored last login method. */ |
| 17 | export function LastUsedBadge({ |
| 18 | method, |
| 19 | compact, |
| 20 | floating, |
| 21 | }: LastUsedBadgeProps) |
| 22 | const { method: |
| 23 | const methods = |
| 24 | |
| 25 | if (!lastLoginMethod || |
| 26 | |
| 27 | return ( |
| 28 | <Badge |
| 29 | className={ |
| 30 | floating |
| 31 | ? "pointer-events-none absolute top-0 right-0 z-10 translate-x-1/4 -translate-y-1/2 shadow-sm" |
| 32 | : undefined |
| 33 | } |
| 34 | variant="secondary" |
| 35 | > |
| 36 | {compact || floating |
| 37 | </Badge> |
| 38 | ); |
| 39 | } |