Typspezifische Zusatzinfos in Vertragslisten
Jede Vertragszeile zeigt jetzt eine kontextspezifische Zusatzinfo an: - Strom/Gas: "Lieferadresse: Musterstr. 12, 12345 Berlin" - DSL/Glasfaser/Kabel: "Anschlussadresse: ..." - Mobilfunk: "Rufnummer: 0171 1234567" (Hauptkarte bevorzugt) - KFZ: "Kennzeichen: HB-AB 123" Sichtbar in: - Admin-Vertragsliste (/contracts) - Portal-Vertragsliste (Baumansicht) - Kunden-Detail → Verträge-Tab Backend: getAllContracts + getContractTreeForCustomer liefern mobileDetails (mit simCards), carInsuranceDetails und address mit. Frontend: Neuer Helper utils/contractInfo.ts mit getContractTypeInfo, aus dem sowohl Label als auch Wert pro Typ kommt. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
interface ContractInfoData {
|
||||
type: string;
|
||||
address?: { street: string; houseNumber: string; postalCode: string; city: string } | null;
|
||||
mobileDetails?: {
|
||||
phoneNumber: string | null;
|
||||
simCards: { phoneNumber: string | null; isMain: boolean }[];
|
||||
} | null;
|
||||
carInsuranceDetails?: { licensePlate: string | null } | null;
|
||||
}
|
||||
|
||||
export interface ContractTypeInfo {
|
||||
label: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export function getContractTypeInfo(contract: ContractInfoData): ContractTypeInfo | null {
|
||||
const { type } = contract;
|
||||
|
||||
if (type === 'ELECTRICITY' || type === 'GAS') {
|
||||
const a = contract.address;
|
||||
if (!a) return null;
|
||||
return {
|
||||
label: 'Lieferadresse',
|
||||
value: `${a.street} ${a.houseNumber}, ${a.postalCode} ${a.city}`,
|
||||
};
|
||||
}
|
||||
|
||||
if (type === 'DSL' || type === 'FIBER' || type === 'CABLE') {
|
||||
const a = contract.address;
|
||||
if (!a) return null;
|
||||
return {
|
||||
label: 'Anschlussadresse',
|
||||
value: `${a.street} ${a.houseNumber}, ${a.postalCode} ${a.city}`,
|
||||
};
|
||||
}
|
||||
|
||||
if (type === 'MOBILE') {
|
||||
const md = contract.mobileDetails;
|
||||
if (!md) return null;
|
||||
const mainSim = md.simCards?.find((s) => s.isMain && s.phoneNumber);
|
||||
const anySim = md.simCards?.find((s) => s.phoneNumber);
|
||||
const phone = mainSim?.phoneNumber || anySim?.phoneNumber || md.phoneNumber;
|
||||
if (!phone) return null;
|
||||
return { label: 'Rufnummer', value: phone };
|
||||
}
|
||||
|
||||
if (type === 'CAR_INSURANCE') {
|
||||
const plate = contract.carInsuranceDetails?.licensePlate;
|
||||
if (!plate) return null;
|
||||
return { label: 'Kennzeichen', value: plate };
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user