From 41afc52f65230696421ee684e9ba9df3142e3088 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 12 Aug 2024 10:33:40 +0200 Subject: [PATCH] fix events and descriptor menu --- .../Zone/Card/ZoneDescriptorMenuItems.vue | 19 ++--------- .../Zone/Card/ZoneEventExclusionForm.vue | 32 ++++++++----------- 2 files changed, 17 insertions(+), 34 deletions(-) diff --git a/src/pages/Zone/Card/ZoneDescriptorMenuItems.vue b/src/pages/Zone/Card/ZoneDescriptorMenuItems.vue index f549bb8d4..00d45e738 100644 --- a/src/pages/Zone/Card/ZoneDescriptorMenuItems.vue +++ b/src/pages/Zone/Card/ZoneDescriptorMenuItems.vue @@ -8,13 +8,6 @@ import VnConfirm from 'components/ui/VnConfirm.vue'; import axios from 'axios'; -const $props = defineProps({ - zone: { - type: Object, - default: () => {}, - }, -}); - const { t } = useI18n(); const { push, currentRoute } = useRouter(); const zoneId = currentRoute.value.params.id; @@ -22,20 +15,14 @@ const zoneId = currentRoute.value.params.id; const actions = { clone: async () => { const opts = { message: t('Zone cloned'), type: 'positive' }; - let clonedZoneId; try { - const { data } = await axios.post(`Zones/${zoneId}/clone`, { - shipped: $props.zone.value.shipped, - }); - clonedZoneId = data; + const { data } = await axios.post(`Zones/${zoneId}/clone`, {}); + notify(opts); + push(`/zone/${data.id}/basic-data`); } catch (e) { opts.message = t('It was not able to clone the zone'); opts.type = 'negative'; - } finally { - notify(opts); - - if (clonedZoneId) push({ name: 'ZoneSummary', params: { id: clonedZoneId } }); } }, remove: async () => { diff --git a/src/pages/Zone/Card/ZoneEventExclusionForm.vue b/src/pages/Zone/Card/ZoneEventExclusionForm.vue index 721f4bbc3..5ab9a5f92 100644 --- a/src/pages/Zone/Card/ZoneEventExclusionForm.vue +++ b/src/pages/Zone/Card/ZoneEventExclusionForm.vue @@ -58,20 +58,12 @@ const arrayData = useArrayData('ZoneEvents'); const exclusionGeoCreate = async () => { try { - if (isNew.value) { - const params = { - zoneFk: parseInt(route.params.id), - date: dated.value, - geoIds: tickedNodes.value, - }; - await axios.post('Zones/exclusionGeo', params); - } else { - const params = { - zoneExclusionFk: props.event?.zoneExclusionFk, - geoIds: tickedNodes.value, - }; - await axios.post('Zones/updateExclusionGeo', params); - } + const params = { + zoneFk: parseInt(route.params.id), + date: dated.value, + geoIds: tickedNodes.value, + }; + await axios.post('Zones/exclusionGeo', params); await refetchEvents(); } catch (err) { console.error('Error creating exclusion geo: ', err); @@ -85,7 +77,7 @@ const exclusionCreate = async () => { { dated: dated.value }, ]); else - await axios.put(`Zones/${route.params.id}/exclusions/${props.event?.id}`, { + await axios.post(`Zones/${route.params.id}/exclusions`, { dated: dated.value, }); @@ -103,8 +95,8 @@ const onSubmit = async () => { const deleteEvent = async () => { try { if (!props.event) return; - const exclusionId = props.event?.zoneExclusionFk || props.event?.id; - await axios.delete(`Zones/${route.params.id}/exclusions/${exclusionId}`); + console.log('props.event: ', props.event); + await axios.delete(`Zones/${route.params.id}/exclusions`); await refetchEvents(); } catch (err) { console.error('Error deleting event: ', err); @@ -141,7 +133,11 @@ onMounted(() => { >