From b21abf40d212302ce1320f958f5d2751e7e776ad Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Mon, 6 May 2024 15:15:35 +0200 Subject: [PATCH] fix: Update from-to when cmpaign changes --- ...stomerNotificationsCampaignConsumption.vue | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/pages/Customer/Notifications/CustomerNotificationsCampaignConsumption.vue b/src/pages/Customer/Notifications/CustomerNotificationsCampaignConsumption.vue index 34cb0c307..5a4c63925 100644 --- a/src/pages/Customer/Notifications/CustomerNotificationsCampaignConsumption.vue +++ b/src/pages/Customer/Notifications/CustomerNotificationsCampaignConsumption.vue @@ -5,6 +5,7 @@ import axios from 'axios'; import useNotify from 'src/composables/useNotify'; import { useValidator } from 'src/composables/useValidator'; import VnRow from 'components/ui/VnRow.vue'; +import VnSelectFilter from 'components/common/VnSelectFilter.vue'; import VnInputDate from 'components/common/VnInputDate.vue'; import FetchData from 'src/components/FetchData.vue'; import { watch } from 'vue'; @@ -28,18 +29,25 @@ const { notify } = useNotify(); const { t } = useI18n(); const validationsStore = useValidator(); const campaignParams = ref(null); +const campaignsOptions = ref(null); const moreFields = ref([]); const popupProxyRef = ref(null); const upcomingOptions = ref(null); - -watch(selectedRows, () => { - const from = new Date(upcomingOptions.value.dated); - from.setDate(from.getDate() - upcomingOptions.value.scopeDays); +const campaignChange = ({ name }) => { + const campaign = campaignsOptions.value.find((c) => c.code === name); + handleDates(campaign); +}; +const handleDates = (campaign) => { + const from = new Date(campaign.dated); + from.setDate(from.getDate() - campaign.scopeDays); campaignParams.value = { - code: upcomingOptions.value.code, + code: campaign.code, from: from, - to: upcomingOptions.value.dated, + to: campaign.dated, }; +}; +watch(selectedRows, () => { + handleDates(upcomingOptions.value); }); const onSubmit = async () => { try { @@ -90,14 +98,15 @@ onMounted(async () => { - {{ campaignParams }} {{ t('Campaign consumption') }} -