From 8876e48c35f41b77e61ba90bd95ab4c993d67e9e Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Mon, 27 Mar 2023 11:27:48 +0700 Subject: page search & page brand --- src/lib/product/components/ProductSearch.jsx | 258 +++++++++++++++++++++------ 1 file changed, 199 insertions(+), 59 deletions(-) (limited to 'src/lib/product/components/ProductSearch.jsx') diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index 52bd5119..3078eac5 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -7,8 +7,15 @@ import _ from 'lodash' import ProductSearchSkeleton from './Skeleton/ProductSearchSkeleton' import ProductFilter from './ProductFilter' import useActive from '@/core/hooks/useActive' +import MobileView from '@/core/components/views/MobileView' +import DesktopView from '@/core/components/views/DesktopView' +import NextImage from 'next/image' +import { ChevronDownIcon } from '@heroicons/react/24/outline' +import ProductFilterDesktop from './ProductFilterDesktop' +import { useRouter } from 'next/router' const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { + const router = useRouter() const { page = 1 } = query if (defaultBrand) query.brand = defaultBrand.toLowerCase() const { productSearch } = useProductSearch({ query }) @@ -35,6 +42,29 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { } ) + const [open, setOpen] = useState(1) + const [order, setOrder] = useState(query?.orderBy) + + const handleOpen = (value) => { + setOpen(open === value ? 0 : value) + } + const orderOptions = [ + { value: 'price-asc', label: 'Harga Terendah' }, + { value: 'price-desc', label: 'Harga Tertinggi' }, + { value: 'popular', label: 'Populer' }, + { value: 'stock', label: 'Ready Stock' } + ] + + const handleOrderBy = (e) => { + let params = { + ...router.query, + orderBy: e.target.value + } + params = _.pickBy(params, _.identity) + params = toQuery(params) + router.push(`${prefixUrl}?${params}`) + } + useEffect(() => { if (!products) { setProducts(productSearch.data?.response?.products) @@ -46,70 +76,180 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { } return ( -
-

Produk

- -
- {productFound > 0 ? ( - <> - Menampilkan  - {pageCount > 1 ? ( + <> + +
+

Produk

+ +
+ {productFound > 0 ? ( <> - {productStart + 1}- - {productStart + productRows > productFound - ? productFound - : productStart + productRows} -  dari  + Menampilkan  + {pageCount > 1 ? ( + <> + {productStart + 1}- + {productStart + productRows > productFound + ? productFound + : productStart + productRows} +  dari  + + ) : ( + '' + )} + {productFound} +  produk{' '} + {query.q && ( + <> + untuk pencarian {query.q} + + )} ) : ( - '' + 'Mungkin yang anda cari' )} - {productFound} -  produk{' '} - {query.q && ( - <> - untuk pencarian {query.q} - - )} - - ) : ( - 'Mungkin yang anda cari' - )} -
- - - -
- {products && - products.map((product) => ( - + + + +
+ {products && + products.map((product) => ( + + ))} +
+ + + + +
+ + +
+
+ - ))} -
- - - - -
+
+
+

Hasil Pencarian

+
+
+ {productFound > 0 ? ( + <> + Menampilkan  + {pageCount > 1 ? ( + <> + {productStart + 1}- + {productStart + productRows > productFound + ? productFound + : productStart + productRows} +  dari  + + ) : ( + '' + )} + {productFound} +  produk{' '} + {query.q && ( + <> + untuk pencarian {query.q} + + )} + + ) : ( + 'Mungkin yang anda cari' + )} +
+
+ {/*
+ +
*/} +
+ +
+
+
+
+ {products && + products.map((product) => ( + + ))} +
+
+
+ +
+ + Barang yang anda cari tidak ada?{' '} + + Hubungi Kami + + +
+
+ + +
+
+
+ + ) } -- cgit v1.2.3