feat(ai): localize AI features
This commit is contained in:
@@ -8,10 +8,12 @@ import { resetPassword } from '@/app/actions/auth-reset'
|
||||
import { toast } from 'sonner'
|
||||
import { useSearchParams, useRouter } from 'next/navigation'
|
||||
import Link from 'next/link'
|
||||
import { useLanguage } from '@/lib/i18n'
|
||||
|
||||
function ResetPasswordForm() {
|
||||
const searchParams = useSearchParams()
|
||||
const router = useRouter()
|
||||
const { t } = useLanguage()
|
||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||
|
||||
const token = searchParams.get('token')
|
||||
@@ -25,7 +27,7 @@ function ResetPasswordForm() {
|
||||
const confirm = formData.get('confirmPassword') as string
|
||||
|
||||
if (password !== confirm) {
|
||||
toast.error("Passwords don't match")
|
||||
toast.error(t('resetPassword.passwordMismatch'))
|
||||
return
|
||||
}
|
||||
|
||||
@@ -36,7 +38,7 @@ function ResetPasswordForm() {
|
||||
if (result.error) {
|
||||
toast.error(result.error)
|
||||
} else {
|
||||
toast.success('Password reset successfully. You can now login.')
|
||||
toast.success(t('resetPassword.success'))
|
||||
router.push('/login')
|
||||
}
|
||||
}
|
||||
@@ -45,12 +47,12 @@ function ResetPasswordForm() {
|
||||
return (
|
||||
<Card className="w-full max-w-[400px]">
|
||||
<CardHeader>
|
||||
<CardTitle>Invalid Link</CardTitle>
|
||||
<CardDescription>This password reset link is invalid or has expired.</CardDescription>
|
||||
<CardTitle>{t('resetPassword.invalidLinkTitle')}</CardTitle>
|
||||
<CardDescription>{t('resetPassword.invalidLinkDescription')}</CardDescription>
|
||||
</CardHeader>
|
||||
<CardFooter>
|
||||
<Link href="/forgot-password" title="Try again" className="w-full">
|
||||
<Button variant="outline" className="w-full">Request new link</Button>
|
||||
<Button variant="outline" className="w-full">{t('resetPassword.requestNewLink')}</Button>
|
||||
</Link>
|
||||
</CardFooter>
|
||||
</Card>
|
||||
@@ -60,23 +62,23 @@ function ResetPasswordForm() {
|
||||
return (
|
||||
<Card className="w-full max-w-[400px]">
|
||||
<CardHeader>
|
||||
<CardTitle>Reset Password</CardTitle>
|
||||
<CardDescription>Enter your new password below.</CardDescription>
|
||||
<CardTitle>{t('resetPassword.title')}</CardTitle>
|
||||
<CardDescription>{t('resetPassword.description')}</CardDescription>
|
||||
</CardHeader>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<CardContent className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<label htmlFor="password">New Password</label>
|
||||
<label htmlFor="password">{t('resetPassword.newPassword')}</label>
|
||||
<Input id="password" name="password" type="password" required minLength={6} autoFocus />
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<label htmlFor="confirmPassword">Confirm New Password</label>
|
||||
<label htmlFor="confirmPassword">{t('resetPassword.confirmNewPassword')}</label>
|
||||
<Input id="confirmPassword" name="confirmPassword" type="password" required minLength={6} />
|
||||
</div>
|
||||
</CardContent>
|
||||
<CardFooter>
|
||||
<Button type="submit" className="w-full" disabled={isSubmitting}>
|
||||
{isSubmitting ? 'Resetting...' : 'Reset Password'}
|
||||
{isSubmitting ? t('resetPassword.resetting') : t('resetPassword.resetPassword')}
|
||||
</Button>
|
||||
</CardFooter>
|
||||
</form>
|
||||
@@ -85,9 +87,10 @@ function ResetPasswordForm() {
|
||||
}
|
||||
|
||||
export default function ResetPasswordPage() {
|
||||
const { t } = useLanguage()
|
||||
return (
|
||||
<main className="flex items-center justify-center md:h-screen p-4">
|
||||
<Suspense fallback={<div>Loading...</div>}>
|
||||
<Suspense fallback={<div>{t('resetPassword.loading')}</div>}>
|
||||
<ResetPasswordForm />
|
||||
</Suspense>
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user