fixed, bankcard, adresses, id card, tarif name dropdown menu in edit mode
This commit is contained in:
parent
68f36a4a5b
commit
88e5f47158
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" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<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">
|
||||
</head>
|
||||
<body>
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
|
|
|
|||
Loading…
Reference in New Issue