From 85e0a7e47db518fb5fb2531b2ea7c6d50408875f Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 20 Oct 2023 14:02:51 +0700 Subject: logo brand di page brand --- src/lib/brand/components/Brand.jsx | 24 +++------------- src/lib/product/components/ProductSearch.jsx | 41 ++++++++++++++-------------- 2 files changed, 25 insertions(+), 40 deletions(-) (limited to 'src/lib') diff --git a/src/lib/brand/components/Brand.jsx b/src/lib/brand/components/Brand.jsx index 4afbcb3e..78a9d5bd 100644 --- a/src/lib/brand/components/Brand.jsx +++ b/src/lib/brand/components/Brand.jsx @@ -20,8 +20,8 @@ const swiperBanner = { modules: [Pagination, Autoplay] } -const Brand = ({ id }) => { - const { brand } = useBrand({ id }) +const Brand = ({ brand }) => { + // const { brand } = useBrand({ id }) return ( <> @@ -91,7 +91,7 @@ const Brand = ({ id }) => { -
+
{ ))} -
-
Produk dari brand:
- {brand?.data?.logo && ( - {brand?.data?.name} - )} - {!brand?.data?.logo && ( -
- {brand?.data?.name} -
- )} -
+ )}
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index a4e3d872..630e3a74 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -19,14 +19,17 @@ import { HStack, Image, Tag, TagCloseButton, TagLabel } from '@chakra-ui/react' import odooApi from '@/core/api/odooApi' import { formatCurrency } from '@/core/utils/formatValue' -const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { +const ProductSearch = ({ query, prefixUrl, defaultBrand = null, brand = null }) => { const router = useRouter() const { page = 1 } = query const [q, setQ] = useState(query?.q || '*') const [limit, setLimit] = useState(query?.limit || 30) const [orderBy, setOrderBy] = useState(router.query?.orderBy || 'popular') if (defaultBrand) query.brand = defaultBrand.toLowerCase() - const { productSearch } = useProductSearch({ query: { ...query, q, limit, orderBy } , operation : router?.pathname?.includes('brands') ? 'OR' : 'AND' }) + const { productSearch } = useProductSearch({ + query: { ...query, q, limit, orderBy }, + operation: router?.pathname?.includes('brands') ? 'OR' : 'AND' + }) const [products, setProducts] = useState(null) const [spellings, setSpellings] = useState(null) const [bannerPromotionHeader, setBannerPromotionHeader] = useState(null) @@ -34,7 +37,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { const popup = useActive() const numRows = [30, 50, 80, 100] const [brandValues, setBrand] = useState( - !router.pathname.includes('brands') ? query.brand ? query.brand.split(',') : [] : [] + !router.pathname.includes('brands') ? (query.brand ? query.brand.split(',') : []) : [] ) const [categoryValues, setCategory] = useState(query?.category?.split(',') || []) const [priceFrom, setPriceFrom] = useState(query?.priceFrom || null) @@ -87,15 +90,6 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { brands.push({ brand, qty }) } } - /*const brandsList = productSearch.data?.facetCounts?.facetFields?.manufactureName?.filter( - (value, index) => { - if (index % 2 === 0) { - const brand = value - const qty = index + 1 - brands.push({ brand, qty }) - } - } - )*/ const categories = [] for (let i = 0; i < productSearch.data?.facetCounts?.facetFields?.categoryName.length; i += 2) { @@ -106,14 +100,6 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { } } - /*const categories = productSearch.data?.facetCounts?.facetFields?.categoryName?.filter( - (value, index) => { - if (index % 2 === 0) { - return true - } - } - )*/ - const orderOptions = [ { value: 'price-asc', label: 'Harga Terendah' }, { value: 'price-desc', label: 'Harga Tertinggi' }, @@ -309,6 +295,21 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
+
+
Produk dari brand:
+ {brand?.data?.logo && ( + {brand?.data?.name} + )} + {!brand?.data?.logo && ( +
+ {brand?.data?.name} +
+ )} +