fixed, bankcard, adresses, id card, tarif name dropdown menu in edit mode
This commit is contained in:
parent
2b23ed64c4
commit
fdef6d1d3b
File diff suppressed because one or more lines are too long
|
|
@ -5,7 +5,7 @@
|
||||||
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<title>OpenCRM</title>
|
<title>OpenCRM</title>
|
||||||
<script type="module" crossorigin src="/assets/index-CooZFd_R.js"></script>
|
<script type="module" crossorigin src="/assets/index-H1r24hX1.js"></script>
|
||||||
<link rel="stylesheet" crossorigin href="/assets/index-DWDTTlpk.css">
|
<link rel="stylesheet" crossorigin href="/assets/index-DWDTTlpk.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
|
||||||
|
|
@ -165,8 +165,9 @@ export default function ContractForm() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Only reset tariff if:
|
// Only reset tariff if:
|
||||||
// 1. Contract has been loaded (or we're creating new)
|
// 1. Contract has been loaded (or we're creating new)
|
||||||
// 2. Provider actually changed (not null -> value which happens on load)
|
// 2. Provider actually changed (not empty/null -> value which happens on load)
|
||||||
if (isContractLoaded && previousProviderId !== null && selectedProviderId !== previousProviderId) {
|
// Note: previousProviderId can be '' (empty string) initially, so we need to check for truthy
|
||||||
|
if (isContractLoaded && previousProviderId && selectedProviderId !== previousProviderId) {
|
||||||
setValue('tariffId', '');
|
setValue('tariffId', '');
|
||||||
}
|
}
|
||||||
setPreviousProviderId(selectedProviderId);
|
setPreviousProviderId(selectedProviderId);
|
||||||
|
|
@ -188,10 +189,18 @@ export default function ContractForm() {
|
||||||
}
|
}
|
||||||
}, [contractCategoriesData, isEdit, setValue, watch]);
|
}, [contractCategoriesData, isEdit, setValue, watch]);
|
||||||
|
|
||||||
// Reset form when contract data AND dropdown data are loaded
|
// Bootstrap: Set customerId first so customerDetail can load (needed for dropdowns)
|
||||||
// This ensures dropdowns can properly display the selected values
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (contract?.data && platformsData?.data && contractCategoriesData?.data) {
|
if (isEdit && contract?.data && !customerId) {
|
||||||
|
setValue('customerId', contract.data.customerId.toString());
|
||||||
|
}
|
||||||
|
}, [isEdit, contract, customerId, setValue]);
|
||||||
|
|
||||||
|
// Reset form when contract data AND ALL dropdown data are loaded
|
||||||
|
// This ensures dropdowns can properly display the selected values
|
||||||
|
// We need customerDetail for addresses/bankCards/documents and providersData for tariffs
|
||||||
|
useEffect(() => {
|
||||||
|
if (contract?.data && platformsData?.data && contractCategoriesData?.data && providersData?.data && customerDetail?.data) {
|
||||||
const c = contract.data;
|
const c = contract.data;
|
||||||
reset({
|
reset({
|
||||||
customerId: c.customerId.toString(),
|
customerId: c.customerId.toString(),
|
||||||
|
|
@ -312,7 +321,7 @@ export default function ContractForm() {
|
||||||
// Mark contract as loaded so provider change detection works correctly
|
// Mark contract as loaded so provider change detection works correctly
|
||||||
setIsContractLoaded(true);
|
setIsContractLoaded(true);
|
||||||
}
|
}
|
||||||
}, [contract, reset, platformsData, contractCategoriesData]);
|
}, [contract, reset, platformsData, contractCategoriesData, providersData, customerDetail]);
|
||||||
|
|
||||||
// Watch für Enddatum-Berechnung
|
// Watch für Enddatum-Berechnung
|
||||||
const startDate = watch('startDate');
|
const startDate = watch('startDate');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue