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') }} -