From 21d23c4431d22467544ff762ee0e791355af6a1c Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Wed, 7 Feb 2024 12:54:36 +0000 Subject: [PATCH] refactor category list --- templates/tpos/index.html | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/templates/tpos/index.html b/templates/tpos/index.html index 4e778ee..2c63aa0 100644 --- a/templates/tpos/index.html +++ b/templates/tpos/index.html @@ -859,17 +859,13 @@
}, computed: { categoryList() { - return this.tposs.reduce((acc, tpos) => { - tpos.items.forEach(item => { - item.categories && - item.categories.forEach(category => { - if (!acc.includes(category)) { - acc.push(category) - } - }) - }) - return acc - }, []) + return Array.from( + new Set( + this.tposs.flatMap(tpos => + tpos.items.flatMap(item => item.categories || []) + ) + ) + ) } }, methods: {