From 1558b600bebe044c32716cc08c72780a30660b73 Mon Sep 17 00:00:00 2001 From: Jon Date: Thu, 23 May 2024 09:20:16 +0200 Subject: [PATCH] refactor: refs #5447 changed warehouse filter --- src/pages/Travel/ExtraCommunityFilter.vue | 39 +++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/pages/Travel/ExtraCommunityFilter.vue b/src/pages/Travel/ExtraCommunityFilter.vue index 7fe628180..6123b0384 100644 --- a/src/pages/Travel/ExtraCommunityFilter.vue +++ b/src/pages/Travel/ExtraCommunityFilter.vue @@ -7,6 +7,7 @@ import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue'; import VnSelect from 'src/components/common/VnSelect.vue'; import VnInput from 'src/components/common/VnInput.vue'; import VnInputDate from 'components/common/VnInputDate.vue'; +import axios from 'axios'; const { t } = useI18n(); const props = defineProps({ @@ -34,6 +35,30 @@ const decrement = (paramsObj, key) => { paramsObj[key]--; }; + +const warehouseAm = ref([]); +const warehouses = async () => { + const warehouses = await axios.get('Warehouses'); + const countries = await axios.get('Countries'); + const continents = await axios.get('Continents'); + + const countryContinent = countries.data.reduce((acc, c) => { + acc[c.id] = c.continentFk; + return acc; + }, {}); + + const continentAMId = continents.data.find((continent) => continent.code === 'AM').id; + + const countriesInAM = Object.keys(countryContinent).filter( + (countryId) => countryContinent[countryId] === continentAMId.toString() + ); + + warehouseAm.value = warehouses.data.filter((w) => + countriesInAM.includes(w.countryFk.toString()) + ); + console.log('warehouseAm: ', warehouseAm.value); +}; +warehouses();