fixed, bankcard, adresses, id card, tarif name dropdown menu in edit mode
This commit is contained in:
@@ -165,8 +165,9 @@ export default function ContractForm() {
|
||||
useEffect(() => {
|
||||
// Only reset tariff if:
|
||||
// 1. Contract has been loaded (or we're creating new)
|
||||
// 2. Provider actually changed (not null -> value which happens on load)
|
||||
if (isContractLoaded && previousProviderId !== null && selectedProviderId !== previousProviderId) {
|
||||
// 2. Provider actually changed (not empty/null -> value which happens on load)
|
||||
// Note: previousProviderId can be '' (empty string) initially, so we need to check for truthy
|
||||
if (isContractLoaded && previousProviderId && selectedProviderId !== previousProviderId) {
|
||||
setValue('tariffId', '');
|
||||
}
|
||||
setPreviousProviderId(selectedProviderId);
|
||||
@@ -188,10 +189,18 @@ export default function ContractForm() {
|
||||
}
|
||||
}, [contractCategoriesData, isEdit, setValue, watch]);
|
||||
|
||||
// Reset form when contract data AND dropdown data are loaded
|
||||
// This ensures dropdowns can properly display the selected values
|
||||
// Bootstrap: Set customerId first so customerDetail can load (needed for dropdowns)
|
||||
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;
|
||||
reset({
|
||||
customerId: c.customerId.toString(),
|
||||
@@ -312,7 +321,7 @@ export default function ContractForm() {
|
||||
// Mark contract as loaded so provider change detection works correctly
|
||||
setIsContractLoaded(true);
|
||||
}
|
||||
}, [contract, reset, platformsData, contractCategoriesData]);
|
||||
}, [contract, reset, platformsData, contractCategoriesData, providersData, customerDetail]);
|
||||
|
||||
// Watch für Enddatum-Berechnung
|
||||
const startDate = watch('startDate');
|
||||
|
||||
Reference in New Issue
Block a user