Merge pull request 'Hotfix[CustomerAddress]: Fixed buttons disabled when there are no changes' (!1641) from Hotfix-CustomerAddress into master
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1641
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Jon Elias 2025-04-01 06:08:11 +00:00
commit 9f05984e80
1 changed files with 17 additions and 1 deletions

View File

@ -93,10 +93,26 @@ const updateAddressTicket = async () => {
};
const updateObservations = async (payload) => {
await axios.post('AddressObservations/crud', payload);
await axios.post('AddressObservations/crud', cleanPayload(payload));
notes.value = [];
deletes.value = [];
};
function cleanPayload(payload) {
['creates', 'deletes', 'updates'].forEach((prop) => {
if (prop === 'creates' || prop === 'updates') {
payload[prop] = payload[prop].filter(
(item) => item.description !== '' && item.observationTypeFk !== '',
);
} else {
payload[prop] = payload[prop].filter(
(item) => item !== null && item !== undefined,
);
}
});
return payload;
}
async function updateAll({ data, payload }) {
await updateObservations(payload);
await updateAddress(data);