- state/authStore: session subscription (initialize + onAuthStateChange), profile + roles load, recovery flag, URL failure; services/localeSync: profiles.locale <-> localeStore - routes: /login, /signup, /forgot-password, /reset-password, /auth/callback; guards RequireAuth (next=) and RedirectIfSignedIn; /app (dashboard), /app/account behind the guard - shell: AppLayout (desktop sidebar, light top bar, mobile drawer), SidebarNav, UserBadge, SignOutButton - account: personal / professional / preferences / security sections, one save each, Zod validation with i18n keys - ui: Icon, FormField, Notice, ButtonLink (buttonClassName shared), PasswordField, OAuthButtons (config-driven) - Home header: Mon espace / Se connecter when Supabase is configured; local tool routes untouched - i18n: auth.*, shell.*, dashboard.*, account.*, home.space.* in fr + en
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { useState, type InputHTMLAttributes } from 'react'
|
|
import Input from '@/components/ui/Input'
|
|
import Icon from '@/components/ui/Icon'
|
|
import { useT } from '@/i18n/useT'
|
|
|
|
type Props = Omit<InputHTMLAttributes<HTMLInputElement>, 'type'>
|
|
|
|
/** Password input with a show/hide toggle; the toggle is a labelled button. */
|
|
export default function PasswordField({ className = '', ...rest }: Props) {
|
|
const [visible, setVisible] = useState(false)
|
|
const t = useT()
|
|
return (
|
|
<div className="relative">
|
|
<Input
|
|
type={visible ? 'text' : 'password'}
|
|
className={`pr-11 ${className}`}
|
|
{...rest}
|
|
/>
|
|
<button
|
|
type="button"
|
|
onClick={() => setVisible((v) => !v)}
|
|
aria-label={visible ? t('auth.hide_password') : t('auth.show_password')}
|
|
aria-pressed={visible}
|
|
className="absolute inset-y-0 right-0 flex w-11 items-center justify-center rounded-r-lg text-[var(--color-ink-muted)] hover:text-[var(--color-ink)] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-accent)]"
|
|
>
|
|
<Icon name={visible ? 'eye-off' : 'eye'} />
|
|
</button>
|
|
</div>
|
|
)
|
|
}
|