From 6bd88bdb765c1ecc0518abeca77eca25bde2857b Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 17 Oct 2023 14:57:48 +0700 Subject: add lebel product terjual di product card dan product detail, bugfix queri solr untuk filter brand --- .../product/components/Product/ProductDesktop.jsx | 9 +++++++-- .../product/components/Product/ProductMobile.jsx | 11 ++++++++--- src/lib/product/components/ProductCard.jsx | 23 +++++++++++----------- src/lib/product/components/ProductSearch.jsx | 6 +++--- 4 files changed, 29 insertions(+), 20 deletions(-) (limited to 'src/lib/product') diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 701750b2..ab4943eb 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -25,6 +25,7 @@ import { useProductCartContext } from '@/contexts/ProductCartContext' import { Box, Skeleton, Tooltip } from '@chakra-ui/react' import { Info } from 'lucide-react' import Breadcrumb from './Breadcrumb' +import { sellingProductFormat } from '@/core/utils/formatValue' const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { const router = useRouter() @@ -418,7 +419,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { -
+
{product.variants.length > 1 && product.lowestPrice.priceDiscount > 0 && (
Harga mulai dari:
)} @@ -447,7 +448,11 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { )}
)} */} - + {product?.qtySold > 0 && ( +
+ {sellingProductFormat(product?.qtySold) + ' Terjual'} +
+ )} {lowestPrice?.isFlashsale && lowestPrice?.price.discountPercentage > 0 ? ( <>
diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index 70ac1cbc..ef2c0002 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -21,6 +21,7 @@ import ImageNext from 'next/image' import CountDown2 from '@/core/components/elements/CountDown/CountDown2' import Breadcrumb from './Breadcrumb' import useAuth from '@/core/hooks/useAuth' +import { sellingProductFormat } from '@/core/utils/formatValue' const ProductMobile = ({ product, wishlist, toggleWishlist }) => { const router = useRouter() @@ -62,7 +63,8 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { price: getLowestPrice(), stock: product.stockTotal, weight: product.weight, - hasProgram: false + hasProgram: false, + qtySold: product.qtySold }) const variantOptions = product.variants?.map((variant) => { @@ -105,7 +107,8 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { stock: variant.stock, weight: variant.weight, hasProgram: variant.hasProgram, - isFlashsale: variant.isFlashsale + isFlashsale: variant.isFlashsale, + qtySold: variant.qtySold } setActiveVariant(newActiveVariant) @@ -245,7 +248,9 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {

{activeVariant?.name}

- + {product?.qtySold > 0 && ( +
{sellingProductFormat(activeVariant?.qtySold) + ' Terjual'}
+ )} {product.variants.length > 1 && activeVariant.price.priceDiscount > 0 && !selectedVariant && ( diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 3b96ac32..72a3260e 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -1,6 +1,7 @@ import Image from '@/core/components/elements/Image/Image' import Link from '@/core/components/elements/Link/Link' import currencyFormat from '@/core/utils/currencyFormat' +import { sellingProductFormat } from '@/core/utils/formatValue' import { createSlug } from '@/core/utils/slug' import whatsappUrl from '@/core/utils/whatsappUrl' import ImageNext from 'next/image' @@ -123,12 +124,11 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => {
)} - {product?.stockTotal > 0 && ( -
-
Ready Stock
-
{product?.stockTotal > 5 ? '> 5' : '< 5'}
-
- )} +
+ {product?.stockTotal > 0 &&
Ready Stock
} + {/*
{product?.stockTotal > 5 ? '> 5' : '< 5'}
*/} + {product?.qtySold > 0 &&
{sellingProductFormat(product?.qtySold) + ' Terjual'}
} +
) @@ -229,12 +229,11 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { )} - {product?.stockTotal > 0 && ( -
-
Ready Stock
-
{product?.stockTotal > 5 ? '> 5' : '< 5'}
-
- )} +
+ {product?.stockTotal > 0 &&
Ready Stock
} + {/*
{product?.stockTotal > 5 ? '> 5' : '< 5'}
*/} + {product?.qtySold > 0 &&
{sellingProductFormat(product?.qtySold) + ' Terjual'}
} +
) diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index fd75d587..dc9796f2 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -70,11 +70,11 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { const brands = [] for ( let i = 0; - i < productSearch.data?.facetCounts?.facetFields?.manufactureName.length; + i < productSearch.data?.facetCounts?.facetFields?.manufactureNameS.length; i += 2 ) { - const brand = productSearch.data?.facetCounts?.facetFields?.manufactureName[i] - const qty = productSearch.data?.facetCounts?.facetFields?.manufactureName[i + 1] + const brand = productSearch.data?.facetCounts?.facetFields?.manufactureNameS[i] + const qty = productSearch.data?.facetCounts?.facetFields?.manufactureNameS[i + 1] if (qty > 0) { brands.push({ brand, qty }) } -- cgit v1.2.3 From f03be42400890aaa4b5a8480b9f1da9c2004a6fc Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 17 Oct 2023 15:03:14 +0700 Subject: Cr title line jadi max 3 --- src/lib/product/components/ProductCard.jsx | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'src/lib/product') diff --git a/src/lib/product/components/ProductCard.jsx b/src/lib/product/components/ProductCard.jsx index 72a3260e..c60e4f87 100644 --- a/src/lib/product/components/ProductCard.jsx +++ b/src/lib/product/components/ProductCard.jsx @@ -83,9 +83,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { )} {product?.name} @@ -186,9 +184,7 @@ const ProductCard = ({ product, simpleTitle, variant = 'vertical' }) => { )} {product?.name} -- cgit v1.2.3 From b29f07808f52d0b9b6ad9c76b182a6ccebb82c5e Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 17 Oct 2023 15:38:56 +0700 Subject: default filter by popular --- src/lib/product/components/ProductFilter.jsx | 2 +- src/lib/product/components/ProductSearch.jsx | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/lib/product') diff --git a/src/lib/product/components/ProductFilter.jsx b/src/lib/product/components/ProductFilter.jsx index 14eef0ba..69738b33 100644 --- a/src/lib/product/components/ProductFilter.jsx +++ b/src/lib/product/components/ProductFilter.jsx @@ -15,7 +15,7 @@ const orderOptions = [ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBrand = null }) => { const router = useRouter() const { query } = router - const [order, setOrder] = useState(query?.orderBy) + const [order, setOrder] = useState(query?.orderBy || 'popular') const [brand, setBrand] = useState(query?.brand) const [category, setCategory] = useState(query?.category) const [priceFrom, setPriceFrom] = useState(query?.priceFrom) diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index dc9796f2..9d59b305 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -23,8 +23,9 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { 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 } }) + const { productSearch } = useProductSearch({ query: { ...query, q, limit, orderBy } }) const [products, setProducts] = useState(null) const [spellings, setSpellings] = useState(null) const [bannerPromotionHeader, setBannerPromotionHeader] = useState(null) @@ -303,10 +304,9 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {