feat(i18n): Complete localization of marketing frontend with react-i18next, prefixed URLs, JSON migrations, and automation
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { FormEvent, useEffect, useState } from 'react';
|
||||
import { Head, useForm } from '@inertiajs/react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import InputError from '@/components/input-error';
|
||||
import TextLink from '@/components/text-link';
|
||||
import { Button } from '@/components/ui/button';
|
||||
@@ -18,6 +19,7 @@ interface LoginProps {
|
||||
|
||||
export default function Login({ status, canResetPassword }: LoginProps) {
|
||||
const [hasTriedSubmit, setHasTriedSubmit] = useState(false);
|
||||
const { t } = useTranslation('auth');
|
||||
|
||||
const { data, setData, post, processing, errors, clearErrors } = useForm({
|
||||
email: '',
|
||||
@@ -52,13 +54,13 @@ export default function Login({ status, canResetPassword }: LoginProps) {
|
||||
}, [errors, hasTriedSubmit]);
|
||||
|
||||
return (
|
||||
<AuthLayout title="Log in to your account" description="Enter your email and password below to log in">
|
||||
<Head title="Log in" />
|
||||
<AuthLayout title={t('login.title')} description={t('login.description')}>
|
||||
<Head title={t('login.title')} />
|
||||
|
||||
<form onSubmit={submit} className="flex flex-col gap-6">
|
||||
<div className="grid gap-6">
|
||||
<div className="grid gap-2">
|
||||
<Label htmlFor="email">Email address</Label>
|
||||
<Label htmlFor="email">{t('login.email')}</Label>
|
||||
<Input
|
||||
id="email"
|
||||
type="email"
|
||||
@@ -67,7 +69,7 @@ export default function Login({ status, canResetPassword }: LoginProps) {
|
||||
autoFocus
|
||||
tabIndex={1}
|
||||
autoComplete="email"
|
||||
placeholder="email@example.com"
|
||||
placeholder={t('login.email_placeholder')}
|
||||
value={data.email}
|
||||
onChange={(e) => {
|
||||
setData('email', e.target.value);
|
||||
@@ -81,10 +83,10 @@ export default function Login({ status, canResetPassword }: LoginProps) {
|
||||
|
||||
<div className="grid gap-2">
|
||||
<div className="flex items-center">
|
||||
<Label htmlFor="password">Password</Label>
|
||||
<Label htmlFor="password">{t('login.password')}</Label>
|
||||
{canResetPassword && (
|
||||
<TextLink href={request()} className="ml-auto text-sm" tabIndex={5}>
|
||||
Forgot password?
|
||||
{t('login.forgot')}
|
||||
</TextLink>
|
||||
)}
|
||||
</div>
|
||||
@@ -95,7 +97,7 @@ export default function Login({ status, canResetPassword }: LoginProps) {
|
||||
required
|
||||
tabIndex={2}
|
||||
autoComplete="current-password"
|
||||
placeholder="Password"
|
||||
placeholder={t('login.password_placeholder')}
|
||||
value={data.password}
|
||||
onChange={(e) => {
|
||||
setData('password', e.target.value);
|
||||
@@ -115,19 +117,19 @@ export default function Login({ status, canResetPassword }: LoginProps) {
|
||||
checked={data.remember}
|
||||
onCheckedChange={(checked) => setData('remember', Boolean(checked))}
|
||||
/>
|
||||
<Label htmlFor="remember">Remember me</Label>
|
||||
<Label htmlFor="remember">{t('login.remember')}</Label>
|
||||
</div>
|
||||
|
||||
<Button type="submit" className="mt-4 w-full" tabIndex={4} disabled={processing}>
|
||||
{processing && <LoaderCircle className="h-4 w-4 animate-spin" />}
|
||||
Log in
|
||||
{t('login.submit')}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="text-center text-sm text-muted-foreground">
|
||||
Don't have an account?{' '}
|
||||
{t('login.no_account')}{' '}
|
||||
<TextLink href={register()} tabIndex={5}>
|
||||
Sign up
|
||||
{t('login.sign_up')}
|
||||
</TextLink>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user