Kunde: persönliche Du/Sie-Präferenz pro Mitarbeiter

Neue Tabelle UserCustomerSalutation (PK userId+customerId,
preference 'DU'|'SIE'). Fehlender Eintrag → Fallback auf
Customer.useInformalAddress (Kunden-Default).

Backend:
- customerService: get/set/clearSalutationPreference mit Fallback-
  Logik. Response enthält immer effektive Präferenz + `source`
  ('user' | 'customer-default'), damit die UI den Standard-Text
  anzeigen kann.
- customerController: 3 Endpunkte GET/PUT/DELETE
  /:customerId/salutation-preference. userId aus dem JWT, canAccessCustomer
  greift.

Frontend:
- customerApi: 3 neue Methoden.
- CustomerDetail: neues Feld "Anrede für mich" mit Du/Sie-Toggle
  und Zurücksetzen-Link. Wird nur Mitarbeitern angezeigt, nicht
  Portal-Usern.
- Bestehendes Feld "Anrede per" bekommt Hinweis "Standard für alle
  Mitarbeiter", damit die Semantik der beiden Felder klar ist.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-07-06 00:34:51 +02:00
parent d14db3de2f
commit 57959cd782
7 changed files with 311 additions and 1 deletions
+21
View File
@@ -205,6 +205,27 @@ export const customerApi = {
const res = await api.delete<ApiResponse<void>>(`/customers/${customerId}/representatives/${representativeId}`);
return res.data;
},
// Persönliche Anrede-Präferenz (Du/Sie) des eingeloggten Mitarbeiters
// für einen bestimmten Kunden. Fehlender Override → Kunden-Default.
getSalutationPreference: async (customerId: number) => {
const res = await api.get<ApiResponse<{ preference: 'DU' | 'SIE'; source: 'user' | 'customer-default' }>>(
`/customers/${customerId}/salutation-preference`,
);
return res.data;
},
setSalutationPreference: async (customerId: number, preference: 'DU' | 'SIE') => {
const res = await api.put<ApiResponse<{ preference: 'DU' | 'SIE'; source: 'user' | 'customer-default' }>>(
`/customers/${customerId}/salutation-preference`,
{ preference },
);
return res.data;
},
clearSalutationPreference: async (customerId: number) => {
const res = await api.delete<ApiResponse<{ preference: 'DU' | 'SIE'; source: 'user' | 'customer-default' }>>(
`/customers/${customerId}/salutation-preference`,
);
return res.data;
},
searchForRepresentative: async (customerId: number, search: string) => {
const res = await api.get<ApiResponse<CustomerSummary[]>>(`/customers/${customerId}/representatives/search`, { params: { search } });
return res.data;