diff --git a/src/pages/Zone/ZoneDeliveryPanel.vue b/src/pages/Zone/ZoneDeliveryPanel.vue index 7c182a698..f7f77ed98 100644 --- a/src/pages/Zone/ZoneDeliveryPanel.vue +++ b/src/pages/Zone/ZoneDeliveryPanel.vue @@ -3,45 +3,22 @@ import { onMounted, ref, reactive } from 'vue'; import { useI18n } from 'vue-i18n'; import VnSelect from 'src/components/common/VnSelect.vue'; - import { useArrayData } from 'src/composables/useArrayData'; -import axios from 'axios'; import useNotify from 'src/composables/useNotify.js'; -import { watch } from 'vue'; +import FetchData from 'src/components/FetchData.vue'; const { t } = useI18n(); const { notify } = useNotify(); -const deliveryMethodFk = ref(null); -const deliveryMethods = ref([]); +const deliveryMethodFk = ref('delivery'); +const deliveryMethods = ref({}); const formData = reactive({}); const arrayData = useArrayData('ZoneDeliveryDays', { url: 'Zones/getEvents', }); -const fetchDeliveryMethods = async (filter) => { - try { - const params = { filter: JSON.stringify(filter) }; - const { data } = await axios.get('DeliveryMethods', { params }); - return data.map((deliveryMethod) => deliveryMethod.id); - } catch (err) { - console.error('Error fetching delivery methods: ', err); - } -}; - -watch( - () => deliveryMethodFk.value, - async (val) => { - let filter; - if (val === 'pickUp') filter = { where: { code: 'PICKUP' } }; - else filter = { where: { code: { inq: ['DELIVERY', 'AGENCY'] } } }; - - deliveryMethods.value = await fetchDeliveryMethods(filter); - }, - { immediate: true } -); - +const deliveryMethodsConfig = { pickUp: ['PICKUP'], delivery: ['AGENCY', 'DELIVERY'] }; const fetchData = async (params) => { try { const { data } = params @@ -70,6 +47,22 @@ onMounted(async () => { +