From e56aa6587f83aa081deba72df0f8cd3d6d09fdd6 Mon Sep 17 00:00:00 2001 From: carlosfonseca Date: Wed, 28 Feb 2024 06:37:15 -0500 Subject: [PATCH] Solucion a comentarios 25 --- src/pages/Customer/Card/CustomerUnpaid.vue | 32 ++++++++++++++++------ 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/pages/Customer/Card/CustomerUnpaid.vue b/src/pages/Customer/Card/CustomerUnpaid.vue index e91f00c68..f33f5d73a 100644 --- a/src/pages/Customer/Card/CustomerUnpaid.vue +++ b/src/pages/Customer/Card/CustomerUnpaid.vue @@ -43,19 +43,35 @@ watch( ); const getData = async (id) => { + const filter = { clientFk: id }; try { - const { data } = await axios.get(`ClientUnpaids/${id}`); - unpaidClient.value = true; - amount.value = data.amount; - dated.value = data.dated; - initialData.value = data; + const { data } = await axios.get('ClientUnpaids', { + params: { filter: JSON.stringify(filter) }, + }); + const unpaid = data.find((element) => element.clientFk == id); + if (unpaid) { + setValues(unpaid); + } else { + defaultValues(); + } } catch (error) { - unpaidClient.value = false; - initialData.value.amount = null; - setInitialData(); + defaultValues(); } }; +const setValues = (data) => { + unpaidClient.value = true; + amount.value = data.amount; + dated.value = data.dated; + initialData.value = data; +}; + +const defaultValues = () => { + unpaidClient.value = false; + initialData.value.amount = null; + setInitialData(); +}; + const setInitialData = () => { amount.value = initialData.value.amount; dated.value = initialData.value.dated;