diff --git a/src/pages/Zone/Card/ZoneEventExclusionForm.vue b/src/pages/Zone/Card/ZoneEventExclusionForm.vue index 5581273b2..fd3e588af 100644 --- a/src/pages/Zone/Card/ZoneEventExclusionForm.vue +++ b/src/pages/Zone/Card/ZoneEventExclusionForm.vue @@ -66,10 +66,7 @@ const excludeType = computed({ const arrayData = useArrayData('ZoneEvents'); const exclusionGeoCreate = async () => { - if (await hasTickets(route.params.id, dated.value)) { - await handleHasTickets(); - return; - } + if (await zoneHasTickets(route.params.id, dated.value)) return; const params = { zoneFk: parseInt(route.params.id), @@ -92,10 +89,7 @@ const exclusionCreate = async () => { }; const zoneIds = props.zoneIds?.length ? props.zoneIds : [route.params.id]; for (const id of zoneIds) { - if (await hasTickets(id, dated.value)) { - await handleHasTickets(); - return; - } + if (await zoneHasTickets(id, dated.value)) return; const url = `Zones/${id}/exclusions`; let today = moment(dated.value); @@ -133,7 +127,7 @@ const exclusionCreate = async () => { await refetchEvents(); }; -const hasTickets = async (zoneId, date) => { +const zoneHasTickets = async (zoneId, date) => { const filter = { where: { zoneFk: zoneId, @@ -142,15 +136,15 @@ const hasTickets = async (zoneId, date) => { }; const params = { filter: JSON.stringify(filter) }; const { data } = await axios.get('Tickets', { params }); - return data.length > 0; -}; - -const handleHasTickets = async (zoneId, date) => { - quasar.notify({ - message: t('eventsExclusionForm.cantCloseZone'), - type: 'negative', - }); - await refetchEvents(); + if (data.length > 0) { + quasar.notify({ + message: t('eventsExclusionForm.cantCloseZone'), + type: 'negative', + }); + await refetchEvents(); + return true; + } + return false; }; const onSubmit = async () => {