fix(demographics): align Frontend enum/prefix values with Backend zod schema
Backend-Agent identified 2 mismatches that caused 422 on save: 1. MARITAL_OPTIONS values: - 'partnership' → 'partnered' (Backend expects this) - 'none' → 'no_answer' 2. BUNDESLAND_OPTIONS values: - 'BW' → 'DE-BW' (alle 16 Bundesländer mit DE-prefix) - Backend zod-regex: ^DE-(BW|BY|...)$ 3. germanCities.ts getCitiesForBundesland: - Akzeptiert jetzt sowohl 'BY' als auch 'DE-BY' (strip prefix on lookup) User-visible labels unverändert. Nur internal values aligned mit Backend-API. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2f5d0382f0
commit
c776570106
@ -54,11 +54,11 @@ const GENDER_OPTIONS: Array<{ label: string; value: string }> = [
|
||||
|
||||
const MARITAL_OPTIONS: Array<{ label: string; value: string }> = [
|
||||
{ label: 'ledig', value: 'single' },
|
||||
{ label: 'Partnerschaft', value: 'partnership' },
|
||||
{ label: 'Partnerschaft', value: 'partnered' },
|
||||
{ label: 'verheiratet', value: 'married' },
|
||||
{ label: 'geschieden', value: 'divorced' },
|
||||
{ label: 'verwitwet', value: 'widowed' },
|
||||
{ label: 'keine Angabe', value: 'none' },
|
||||
{ label: 'keine Angabe', value: 'no_answer' },
|
||||
];
|
||||
|
||||
const EMPLOYMENT_STATUS_OPTIONS: Array<{ label: string; value: string }> = [
|
||||
@ -93,23 +93,24 @@ const JOB_TENURE_OPTIONS: Array<{ label: string; value: string }> = [
|
||||
{ label: 'mehr als 10 Jahre', value: 'more_10y' },
|
||||
];
|
||||
|
||||
// Backend zod-regex: ^DE-(BW|BY|...)$ — values müssen mit `DE-` prefix gesendet werden
|
||||
const BUNDESLAND_OPTIONS: Array<{ label: string; value: string }> = [
|
||||
{ label: 'Baden-Württemberg', value: 'BW' },
|
||||
{ label: 'Bayern', value: 'BY' },
|
||||
{ label: 'Berlin', value: 'BE' },
|
||||
{ label: 'Brandenburg', value: 'BB' },
|
||||
{ label: 'Bremen', value: 'HB' },
|
||||
{ label: 'Hamburg', value: 'HH' },
|
||||
{ label: 'Hessen', value: 'HE' },
|
||||
{ label: 'Mecklenburg-Vorpommern', value: 'MV' },
|
||||
{ label: 'Niedersachsen', value: 'NI' },
|
||||
{ label: 'Nordrhein-Westfalen', value: 'NW' },
|
||||
{ label: 'Rheinland-Pfalz', value: 'RP' },
|
||||
{ label: 'Saarland', value: 'SL' },
|
||||
{ label: 'Sachsen', value: 'SN' },
|
||||
{ label: 'Sachsen-Anhalt', value: 'ST' },
|
||||
{ label: 'Schleswig-Holstein', value: 'SH' },
|
||||
{ label: 'Thüringen', value: 'TH' },
|
||||
{ label: 'Baden-Württemberg', value: 'DE-BW' },
|
||||
{ label: 'Bayern', value: 'DE-BY' },
|
||||
{ label: 'Berlin', value: 'DE-BE' },
|
||||
{ label: 'Brandenburg', value: 'DE-BB' },
|
||||
{ label: 'Bremen', value: 'DE-HB' },
|
||||
{ label: 'Hamburg', value: 'DE-HH' },
|
||||
{ label: 'Hessen', value: 'DE-HE' },
|
||||
{ label: 'Mecklenburg-Vorpommern', value: 'DE-MV' },
|
||||
{ label: 'Niedersachsen', value: 'DE-NI' },
|
||||
{ label: 'Nordrhein-Westfalen', value: 'DE-NW' },
|
||||
{ label: 'Rheinland-Pfalz', value: 'DE-RP' },
|
||||
{ label: 'Saarland', value: 'DE-SL' },
|
||||
{ label: 'Sachsen', value: 'DE-SN' },
|
||||
{ label: 'Sachsen-Anhalt', value: 'DE-ST' },
|
||||
{ label: 'Schleswig-Holstein', value: 'DE-SH' },
|
||||
{ label: 'Thüringen', value: 'DE-TH' },
|
||||
];
|
||||
|
||||
const STATUS_WITH_SHIFT: Array<string> = ['employed', 'self_employed'];
|
||||
|
||||
@ -85,5 +85,7 @@ export const GERMAN_CITIES_BY_BUNDESLAND: Record<string, string[]> = {
|
||||
|
||||
export function getCitiesForBundesland(bundeslandCode: string | null | undefined): string[] {
|
||||
if (!bundeslandCode) return [];
|
||||
return GERMAN_CITIES_BY_BUNDESLAND[bundeslandCode] ?? [];
|
||||
// Akzeptiert sowohl 'BY' als auch 'DE-BY' (Backend-Schema sendet `DE-`-prefix)
|
||||
const code = bundeslandCode.startsWith('DE-') ? bundeslandCode.slice(3) : bundeslandCode;
|
||||
return GERMAN_CITIES_BY_BUNDESLAND[code] ?? [];
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user