From 59cb81177a858e3a03a0f54458e0ae03af868557 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9rik=20BENOIST?= Date: Sat, 23 Dec 2023 09:27:13 +0100 Subject: [PATCH] fix: variables affectation --- src/pages/store/list/index.vue | 40 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/pages/store/list/index.vue b/src/pages/store/list/index.vue index ba0e007..0738fee 100644 --- a/src/pages/store/list/index.vue +++ b/src/pages/store/list/index.vue @@ -19,47 +19,49 @@ const selectedCountry = ref() const selectedBrand = ref() const selectedNbPos = ref() +// for reload process const storesList = ref('') +const isLoading = ref(false) + const searchQuery = ref('') // Data table options -const { data: storesListData } = await useApi(createUrl('/stores')) -const isLoading = ref(false) +const { data: dtListData } = await useApi(createUrl('/stores')) -storesList.value = storesListData.value +storesList.value = dtListData.value const options = ref({ page: 1, itemsPerPage: 10, sortBy: [''], sortDesc: [false] }) -const brand = computed(() => { - const allBrands = storesList.value.map((store: { enseigne: any }) => store.enseigne) +const country = computed(() => { + const allItems = storesList.value.map((store: { pays: any }) => store.pays) // eslint-disable-next-line @typescript-eslint/no-shadow - const uniqueBrands = allBrands.filter((brand: any, index: any, self: string | any[]) => self.indexOf(brand) === index) - const sortedBrands = uniqueBrands.sort() + const uniqueItems = allItems.filter((country: any, index: any, self: string | any[]) => self.indexOf(country) === index) + const sortedItems = uniqueItems.sort() // eslint-disable-next-line @typescript-eslint/no-shadow - return sortedBrands.map((brand: any) => ({ title: brand, value: brand })) + return sortedItems.map((country: any) => ({ title: country, value: country })) }) -const country = computed(() => { - const allCountries = storesList.value.map((store: { pays: any }) => store.pays) +const brand = computed(() => { + const allItems = storesList.value.map((store: { enseigne: any }) => store.enseigne) // eslint-disable-next-line @typescript-eslint/no-shadow - const uniqueCountries = allCountries.filter((country: any, index: any, self: string | any[]) => self.indexOf(country) === index) - const sortedCountries = uniqueCountries.sort() + const uniqueItems = allItems.filter((brand: any, index: any, self: string | any[]) => self.indexOf(brand) === index) + const sortedItems = uniqueItems.sort() // eslint-disable-next-line @typescript-eslint/no-shadow - return sortedCountries.map((country: any) => ({ title: country, value: country })) + return sortedItems.map((brand: any) => ({ title: brand, value: brand })) }) const nbPos = computed(() => { - const allNbPos = storesList.value.map((store: { nbcaisses: number }) => store.nbcaisses) - const uniqueNbPos = Array.from(new Set(allNbPos)) as number[] // Utilisez une assertion de type - const sortedNbPos = uniqueNbPos.sort((a, b) => a - b) // Triez les nombres en ordre croissant + const allItems = storesList.value.map((store: { nbcaisses: number }) => store.nbcaisses) + const uniqueItems = Array.from(new Set(allItems)) as number[] // Utilisez une assertion de type + const sortedItems = uniqueItems.sort((a, b) => a - b) // Triez les nombres en ordre croissant // eslint-disable-next-line @typescript-eslint/no-shadow - return sortedNbPos.map((nbPos: number) => ({ title: nbPos, value: nbPos })) + return sortedItems.map((nbPos: number) => ({ title: nbPos, value: nbPos })) }) -const filteredStoresList = computed(() => { +const filteredData = computed(() => { let filtered = storesList.value // If a brand is selected, filter the records for this brand @@ -212,7 +214,7 @@ const reloadStores = async () => {