This commit is contained in:
2026-03-06 19:42:15 +00:00
parent abcbe3e1e5
commit 04cbb846d1
99 changed files with 11724 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { Button } from '@/components/ui/button'
import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } from '@/components/ui/card'
import { Input } from '@/components/ui/input'
import type { AuthContext } from '@/hooks/useAuth'
interface Props {
auth: AuthContext
onToggle: () => void
}
export function RegisterPage({ auth: { register }, onToggle }: Props) {
const { t } = useTranslation()
const [email, setEmail] = useState('')
const [password, setPassword] = useState('')
const [displayName, setDisplayName] = useState('')
const [error, setError] = useState('')
const [loading, setLoading] = useState(false)
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault()
setError('')
setLoading(true)
try {
await register(email, password, displayName)
} catch (err) {
setError(err instanceof Error ? err.message : 'Registration failed')
} finally {
setLoading(false)
}
}
return (
<div className="flex min-h-screen items-center justify-center bg-background">
<Card className="w-full max-w-md">
<CardHeader>
<CardTitle>{t('auth.register')}</CardTitle>
<CardDescription>{t('app.title')}</CardDescription>
</CardHeader>
<form onSubmit={handleSubmit}>
<CardContent className="flex flex-col gap-4">
{error && <p className="text-sm text-destructive">{error}</p>}
<Input
placeholder={t('auth.displayName')}
value={displayName}
onChange={(e) => setDisplayName(e.target.value)}
required
/>
<Input
type="email"
placeholder={t('auth.email')}
value={email}
onChange={(e) => setEmail(e.target.value)}
required
/>
<Input
type="password"
placeholder={t('auth.password')}
value={password}
onChange={(e) => setPassword(e.target.value)}
required
minLength={8}
/>
<Button type="submit" disabled={loading} className="w-full">
{t('auth.register')}
</Button>
</CardContent>
</form>
<CardFooter>
<Button variant="link" onClick={onToggle}>
{t('auth.hasAccount')} {t('auth.login')}
</Button>
</CardFooter>
</Card>
</div>
)
}