From 55f4e2dc6e25dd425ad0a2b8763f8b8de0305e70 Mon Sep 17 00:00:00 2001 From: it-fixcomart Date: Fri, 14 Jun 2024 17:08:42 +0700 Subject: update promotion-program --- src/pages/shop/promo/[slug].tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/pages/shop/promo/[slug].tsx b/src/pages/shop/promo/[slug].tsx index c53bcf0e..1248ba35 100644 --- a/src/pages/shop/promo/[slug].tsx +++ b/src/pages/shop/promo/[slug].tsx @@ -45,17 +45,26 @@ export default function PromoDetail() { const popup = useActive(); useEffect(() => { - // Initialize brandValues based on router.query.brand if (router.query.brand) { - const brandsArray = Array.isArray(router.query.brand) ? router.query.brand : [router.query.brand]; + let brandsArray: string[] = []; + if (Array.isArray(router.query.brand)) { + brandsArray = router.query.brand; + } else if (typeof router.query.brand === 'string') { + brandsArray = router.query.brand.split(',').map((brand) => brand.trim()); + } setBrandValues(brandsArray); } else { setBrandValues([]); } - // Initialize categoryValues based on router.query.category if (router.query.category) { - const categoriesArray = Array.isArray(router.query.category) ? router.query.category : [router.query.category]; + let categoriesArray: string[] = []; + + if (Array.isArray(router.query.category)) { + categoriesArray = router.query.category; + } else if (typeof router.query.category === 'string') { + categoriesArray = router.query.category.split(',').map((category) => category.trim()); + } setCategoryValues(categoriesArray); } else { setCategoryValues([]); @@ -467,6 +476,7 @@ const FilterChoicesComponent = ({ /> ))} + {console.log("categoryValues",categoryValues)} {priceFrom && priceTo && ( -- cgit v1.2.3