This commit is contained in:
Casey 2026-02-20 10:56:40 -06:00
parent 6c703c2c3b
commit 6ff5a09ad4
24 changed files with 270688 additions and 237967 deletions

View file

@ -117,8 +117,7 @@
:id="`contacts-${index}`"
v-model="address.contacts"
:options="contactOptions"
optionLabel="label"
dataKey="value"
optionLabel="label" optionValue="value" dataKey="value"
:disabled="isSubmitting || contactOptions.length === 0"
placeholder="Select contacts"
class="w-full"
@ -130,8 +129,9 @@
<Select
:id="`primaryContact-${index}`"
v-model="address.primaryContact"
:options="address.contacts"
optionLabel="label"
:options="getPrimaryContactOptions(address.contacts)"
optionLabel="label"
optionValue="value"
dataKey="value"
:disabled="isSubmitting || !address.contacts || address.contacts.length === 0"
placeholder="Select primary contact"
@ -256,6 +256,11 @@ const formatAddressLine = (index, field, event) => {
localFormData.value.addresses[index][field] = formatted;
};
const getPrimaryContactOptions = (selectedContactIndexes) => {
if (!selectedContactIndexes || selectedContactIndexes.length === 0) return [];
return contactOptions.value.filter(opt => selectedContactIndexes.includes(opt.value));
};
const handleBillingChange = (selectedIndex) => {
// If the selected address is now checked as billing
if (localFormData.value.addresses[selectedIndex].isBillingAddress) {
@ -267,12 +272,12 @@ const handleBillingChange = (selectedIndex) => {
}
});
// Auto-select all contacts (store full objects)
// Auto-select all contacts (store indexes only)
if (contactOptions.value.length > 0) {
localFormData.value.addresses[selectedIndex].contacts = [...contactOptions.value];
localFormData.value.addresses[selectedIndex].contacts = contactOptions.value.map(o => o.value);
}
// Auto-select primary contact (store full object)
// Auto-select primary contact (store index only)
const allOpts = contactOptions.value;
if (allOpts.length > 0) {
// Try to find the primary from localFormData contacts
@ -280,12 +285,12 @@ const handleBillingChange = (selectedIndex) => {
const primaryIndex = localFormData.value.contacts.findIndex((c) => c.isPrimary);
if (primaryIndex !== -1) {
const primaryOpt = allOpts.find((o) => o.value === primaryIndex);
localFormData.value.addresses[selectedIndex].primaryContact = primaryOpt || allOpts[0];
localFormData.value.addresses[selectedIndex].primaryContact = (primaryOpt || allOpts[0]).value;
} else {
localFormData.value.addresses[selectedIndex].primaryContact = allOpts[0];
localFormData.value.addresses[selectedIndex].primaryContact = allOpts[0].value;
}
} else {
localFormData.value.addresses[selectedIndex].primaryContact = allOpts[0];
localFormData.value.addresses[selectedIndex].primaryContact = allOpts[0].value;
}
}
} else {