U2 identity-mail-flows (frontend en documentatie): taalkeuze, mailresultaat, opnieuw mailen
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -19,10 +19,13 @@ import {
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog';
|
||||
import { ProblemDetailsError } from '@/lib/api-client';
|
||||
import { changeLanguage } from '@/i18n/config';
|
||||
import { useSystemCapabilities } from '@/features/system/services/useSystemCapabilities';
|
||||
|
||||
const profileSchema = z.object({
|
||||
name: z.string().min(1, 'Name is required'),
|
||||
email: z.string().email('Enter a valid email address'),
|
||||
language: z.enum(['', 'nl', 'en']),
|
||||
});
|
||||
|
||||
const changePasswordSchema = z
|
||||
@@ -176,6 +179,7 @@ export function ProfilePage() {
|
||||
const { t } = useTranslation();
|
||||
const { user } = useAuth();
|
||||
const updateProfile = useUpdateProfile();
|
||||
const { data: capabilities } = useSystemCapabilities();
|
||||
const [passwordDialogOpen, setPasswordDialogOpen] = useState(false);
|
||||
|
||||
const {
|
||||
@@ -187,12 +191,16 @@ export function ProfilePage() {
|
||||
defaultValues: {
|
||||
name: user?.name ?? '',
|
||||
email: user?.email ?? '',
|
||||
language: user?.language ?? '',
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = async (data: ProfileFormData) => {
|
||||
try {
|
||||
await updateProfile.mutateAsync(data);
|
||||
// Show the choice right away; clearing it falls back to the site's default language.
|
||||
if (data.language === 'nl' || data.language === 'en') await changeLanguage(data.language);
|
||||
else await changeLanguage(capabilities?.defaultLanguage ?? 'nl');
|
||||
toast.success(t('profile.saveSuccess'));
|
||||
} catch (err) {
|
||||
if (err instanceof ProblemDetailsError && err.status === 400) {
|
||||
@@ -243,6 +251,20 @@ export function ProfilePage() {
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label htmlFor="language">{t('profile.language')}</Label>
|
||||
<select
|
||||
id="language"
|
||||
data-testid="profile-language-select"
|
||||
className="h-10 w-full rounded-md border border-input bg-background px-3 text-sm"
|
||||
{...register('language')}
|
||||
>
|
||||
<option value="">{t('profile.languageDefault')}</option>
|
||||
<option value="nl">Nederlands</option>
|
||||
<option value="en">English</option>
|
||||
</select>
|
||||
<p className="text-xs text-muted-foreground">{t('profile.languageHelp')}</p>
|
||||
</div>
|
||||
<div className="space-y-1">
|
||||
<Label>{t('profile.role')}</Label>
|
||||
<div>
|
||||
|
||||
@@ -6,6 +6,8 @@ import type { UserListItem } from '@/features/users/services/types';
|
||||
export interface UpdateProfilePayload {
|
||||
name: string;
|
||||
email: string;
|
||||
/** 'nl' | 'en'; '' clears the preference (site default); omitted leaves it unchanged. */
|
||||
language?: string;
|
||||
}
|
||||
|
||||
export interface ChangePasswordPayload {
|
||||
|
||||
Reference in New Issue
Block a user