()
| 7 | import { useTranslations } from "next-intl"; |
| 8 | |
| 9 | export default function SetupForm() { |
| 10 | const t = useTranslations('auth'); |
| 11 | const [error, setError] = useState<string>(""); |
| 12 | const [isLoading, setIsLoading] = useState(false); |
| 13 | const { isRwMarkable } = useAppMode(); |
| 14 | |
| 15 | async function handleSubmit(formData: FormData) { |
| 16 | setIsLoading(true); |
| 17 | setError(""); |
| 18 | |
| 19 | try { |
| 20 | const result = await register(formData); |
| 21 | if (result?.error) { |
| 22 | setError(result.error); |
| 23 | } |
| 24 | } finally { |
| 25 | setIsLoading(false); |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | return ( |
| 30 | <div className="space-y-6"> |
| 31 | <div className="space-y-2 text-center"> |
| 32 | <h1 className="text-2xl font-bold tracking-tight text-foreground"> |
| 33 | {t('welcomeTo', { appName: isRwMarkable ? "rwMarkable" : "jotty·page" })} |
| 34 | </h1> |
| 35 | <p className="text-md lg:text-sm text-muted-foreground"> |
| 36 | {t('createAdminAccountDescription')} |
| 37 | </p> |
| 38 | </div> |
| 39 | |
| 40 | <form action={handleSubmit} className="space-y-4"> |
| 41 | {error && ( |
| 42 | <div className="flex items-center gap-2 p-3 bg-destructive/10 border border-destructive/20 rounded-jotty"> |
| 43 | <span className="text-md lg:text-sm text-destructive">{error}</span> |
| 44 | </div> |
| 45 | )} |
| 46 | |
| 47 | <Input |
| 48 | id="username" |
| 49 | name="username" |
| 50 | label={t('usernameLabel')} |
| 51 | type="text" |
| 52 | placeholder={t('chooseUsername')} |
| 53 | required |
| 54 | disabled={isLoading} |
| 55 | /> |
| 56 | |
| 57 | <Input |
| 58 | id="password" |
| 59 | name="password" |
| 60 | label={t('passwordLabel')} |
| 61 | type="password" |
| 62 | placeholder={t('choosePassword')} |
| 63 | required |
| 64 | disabled={isLoading} |
| 65 | /> |
| 66 |
nothing calls this directly
no test coverage detected