From 9836f109c38d7f02c587329795e80e15ff33aafa Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Tue, 10 Oct 2023 17:09:23 +0700 Subject: add qty di nenu brang , filter ready stock, filter haga fix di page search --- .../product/components/ProductFilterDesktop.jsx | 77 ++++++++++++++++++++-- src/lib/product/components/ProductSearch.jsx | 19 +++++- 2 files changed, 88 insertions(+), 8 deletions(-) (limited to 'src/lib/product') diff --git a/src/lib/product/components/ProductFilterDesktop.jsx b/src/lib/product/components/ProductFilterDesktop.jsx index b64349c7..08766e07 100644 --- a/src/lib/product/components/ProductFilterDesktop.jsx +++ b/src/lib/product/components/ProductFilterDesktop.jsx @@ -26,6 +26,7 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu const [categoryValues, setCategory] = useState(query?.category?.split(',') || []) const [priceFrom, setPriceFrom] = useState(query?.priceFrom) const [priceTo, setPriceTo] = useState(query?.priceTo) + const [stock, setStock] = useState(query?.stock) const handleCategoriesChange = (event) => { const value = event.target.value @@ -46,6 +47,38 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu } } + const handleReadyStockChange = (event) => { + const value = event.target.value + const isChecked = event.target.checked + if (isChecked) { + setStock(value) + } else { + setStock(null) + } + } + + const handlePriceFromChange = async (type) => { + let priceFrom = null + let priceTo = null + switch (type) { + case(1): + priceFrom = 100000 + priceFrom = 200000 + break; + case(2): + priceFrom = 100000 + priceFrom = 200000 + break; + case(1): + priceFrom = 100000 + priceFrom = 200000 + break; + } + await setPriceFrom(priceFrom) + await setPriceTo(priceTo) + handleSubmit() + } + const handleSubmit = () => { let params = { q: router.query.q, @@ -53,7 +86,8 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu brand: brandValues.join(','), category: categoryValues.join(','), priceFrom, - priceTo + priceTo, + stock : stock } params = _.pickBy(params, _.identity) params = toQuery(params) @@ -74,14 +108,19 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu {brands.map((brand, index) => ( -
+
- {brand} +
+ {brand.brand} +
+ {brand.qty > 99 ? '99+' : brand.qty} +
+
))} @@ -143,9 +182,37 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu onChange={(e) => setPriceTo(e.target.value)} /> +
+ + +
+
+ + +
+ + + + + Ketersedian Stok + + + + + + + Ketersedian Stock + + + - -
-
- - +
+ {priceRange.map((price, i) => ( + + ))}
-- cgit v1.2.3 From f1d9a308f61e67f4c896608e73ac8413f61fa8af Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 11 Oct 2023 10:22:11 +0700 Subject: Add breadcrumb on detail product, search, brand, category page --- src/lib/product/components/Product/Breadcrumb.jsx | 69 +++++++++++++++++++++ src/lib/product/components/Product/Product.jsx | 38 +++++------- .../product/components/Product/ProductDesktop.jsx | 71 +++++++++++----------- .../product/components/Product/ProductMobile.jsx | 2 + src/lib/product/components/ProductSearch.jsx | 4 +- 5 files changed, 125 insertions(+), 59 deletions(-) create mode 100644 src/lib/product/components/Product/Breadcrumb.jsx (limited to 'src/lib/product') diff --git a/src/lib/product/components/Product/Breadcrumb.jsx b/src/lib/product/components/Product/Breadcrumb.jsx new file mode 100644 index 00000000..0554dba5 --- /dev/null +++ b/src/lib/product/components/Product/Breadcrumb.jsx @@ -0,0 +1,69 @@ +import odooApi from '@/core/api/odooApi' +import { createSlug } from '@/core/utils/slug' +import { + Breadcrumb as ChakraBreadcrumb, + BreadcrumbItem, + BreadcrumbLink, + Skeleton +} from '@chakra-ui/react' +import classNames from 'classnames' +import Link from 'next/link' +import { useQuery } from 'react-query' + +/** + * Renders a breadcrumb component based on the provided `productId`. + * + * @param {Object} props - The properties passed to the component. + * @param {number} props.productId - The ID of the product. + * @param {string} props.productName - The ID of the product. + * @return {ReactElement} The rendered breadcrumb component. + */ +const Breadcrumb = ({ productId, productName }) => { + const categories = useQuery( + `detail/categories/${productId}`, + async () => await odooApi('GET', `/api/v1/product/${productId}/category-breadcrumb`), + { + enabled: !!productId + } + ) + + return ( + + + + + Home + + + + {categories.data?.map((category) => ( + + + {category.name} + + + ))} + + + {productName} + + + + ) +} + +export default Breadcrumb diff --git a/src/lib/product/components/Product/Product.jsx b/src/lib/product/components/Product/Product.jsx index 54490c26..6e983c2e 100644 --- a/src/lib/product/components/Product/Product.jsx +++ b/src/lib/product/components/Product/Product.jsx @@ -36,29 +36,21 @@ const Product = ({ product, isVariant = false }) => { } }, [product, isVariant]) - if (isVariant == true) { - return ( - <> - - - - ) - } else { - return ( - <> - - - - ) - } + return isVariant == true ? ( + <> + + + + ) : ( + <> + + + + ) } export default Product diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 47e98c1a..ceb0cad7 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -24,6 +24,7 @@ import ColumnsSLA from './ColumnsSLA' import { useProductCartContext } from '@/contexts/ProductCartContext' import { Box, Skeleton, Tooltip } from '@chakra-ui/react' import { Info } from 'lucide-react' +import Breadcrumb from './Breadcrumb' const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { const router = useRouter() @@ -199,47 +200,49 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { return (
+
- {product?.flashSale?.remainingTime > 0 && lowestPrice?.price.discountPercentage > 0 && ( -
-
- -
-
-
-
- - {Math.floor(product.lowestPrice.discountPercentage)}% - -
-
- - - {product?.flashSale?.tag != 'false' || product?.flashSale?.tag - ? product?.flashSale?.tag - : 'FLASH SALE'} - -
-
- + {product?.flashSale?.remainingTime > 0 && + lowestPrice?.price.discountPercentage > 0 && ( +
+
+ +
+
+
+
+ + {Math.floor(product.lowestPrice.discountPercentage)}% + +
+
+ + + {product?.flashSale?.tag != 'false' || product?.flashSale?.tag + ? product?.flashSale?.tag + : 'FLASH SALE'} + +
+
+ +
-
- )} + )} {product.name} { const router = useRouter() @@ -160,6 +161,7 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { return ( +
{product?.flashSale?.remainingTime > 0 && activeVariant?.price.discountPercentage > 0 && (
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index df9aa91b..f6987051 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -117,7 +117,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { <> {productSearch.isLoading && } -
+

Produk

@@ -178,7 +178,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { -
+
Date: Wed, 11 Oct 2023 11:02:04 +0700 Subject: filter by limit rows --- src/lib/product/components/ProductFilter.jsx | 4 +-- src/lib/product/components/ProductSearch.jsx | 40 +++++++++++++++++++++++----- 2 files changed, 36 insertions(+), 8 deletions(-) (limited to 'src/lib/product') diff --git a/src/lib/product/components/ProductFilter.jsx b/src/lib/product/components/ProductFilter.jsx index 34357526..7dadc39e 100644 --- a/src/lib/product/components/ProductFilter.jsx +++ b/src/lib/product/components/ProductFilter.jsx @@ -48,8 +48,8 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr > {brands.map((brand, index) => ( - ))} diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index 3c3dbfd2..c79e355e 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -20,17 +20,20 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { const router = useRouter() const { page = 1 } = query const [q, setQ] = useState(query?.q || '*') + const [limit, setLimit] = useState(query?.limit || 30) if (defaultBrand) query.brand = defaultBrand.toLowerCase() - const { productSearch } = useProductSearch({ query: { ...query, q } }) + const { productSearch } = useProductSearch({ query: { ...query, q, limit } }) const [products, setProducts] = useState(null) const [spellings, setSpellings] = useState(null) const popup = useActive() + const numRows = [30, 50, 80, 100] + console.log('ini product search', productSearch.data) const pageCount = Math.ceil( - productSearch.data?.response.numFound / productSearch.data?.responseHeader.params.rows + productSearch.data?.response.numFound / limit ) const productStart = productSearch.data?.responseHeader.params.start - const productRows = productSearch.data?.responseHeader.params.rows + const productRows = limit const productFound = productSearch.data?.response.numFound useEffect(() => { @@ -101,7 +104,17 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { const handleOrderBy = (e) => { let params = { ...router.query, - orderBy: e.target.value + orderBy: e.target.value, + } + params = _.pickBy(params, _.identity) + params = toQuery(params) + router.push(`${prefixUrl}?${params}`) + } + + const handleLimit = (e) => { + let params = { + ...router.query, + limit: e.target.value, } params = _.pickBy(params, _.identity) params = toQuery(params) @@ -210,9 +223,9 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { {pageCount > 1 ? ( <> {productStart + 1}- - {productStart + productRows > productFound + {parseInt(productStart) + parseInt(productRows) > productFound ? productFound - : productStart + productRows} + : parseInt(productStart) + parseInt(productRows)}  dari  ) : ( @@ -247,6 +260,21 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { ))}
+
+ +
{productSearch.isLoading && } -- cgit v1.2.3 From cff358b2a7bb310e2b65cba5d843e9ffdda0f699 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Wed, 11 Oct 2023 14:07:58 +0700 Subject: Fix description and brand banner skeleton --- src/lib/product/components/Product/ProductDesktop.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/lib/product') diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index ceb0cad7..855c9f75 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -393,7 +393,7 @@ const ProductDesktop = ({ products, wishlist, toggleWishlist }) => { ))}
-
+
Date: Wed, 11 Oct 2023 14:37:47 +0700 Subject: filter di web mobile --- src/lib/product/components/ProductFilter.jsx | 81 +++++++++++++++++++++- .../product/components/ProductFilterDesktop.jsx | 8 +-- src/lib/product/components/ProductSearch.jsx | 38 +++++++--- 3 files changed, 109 insertions(+), 18 deletions(-) (limited to 'src/lib/product') diff --git a/src/lib/product/components/ProductFilter.jsx b/src/lib/product/components/ProductFilter.jsx index 7dadc39e..20c66a1f 100644 --- a/src/lib/product/components/ProductFilter.jsx +++ b/src/lib/product/components/ProductFilter.jsx @@ -3,6 +3,7 @@ import { useRouter } from 'next/router' import { useState } from 'react' import _ from 'lodash' import { toQuery } from 'lodash-contrib' +import { Checkbox } from '@chakra-ui/react' const orderOptions = [ { value: 'price-asc', label: 'Harga Terendah' }, @@ -20,6 +21,45 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr const [priceFrom, setPriceFrom] = useState(query?.priceFrom) const [priceTo, setPriceTo] = useState(query?.priceTo) + const [stock, setStock] = useState(query?.stock) + + const [activeRange, setActiveRange] = useState(null) + + const priceRange = [ + { + priceFrom: 100000, + priceTo: 200000 + }, + { + priceFrom: 200000, + priceTo: 300000 + }, + { + priceFrom: 300000, + priceTo: 400000 + }, + { + priceFrom: 400000, + priceTo: 500000 + } + ] + + const handlePriceFromChange = async (priceFromr, priceTor, index) => { + await setPriceFrom(priceFromr) + await setPriceTo(priceTor) + setActiveRange(index) + } + + const handleReadyStockChange = (event) => { + const value = event.target.value + const isChecked = event.target.checked + if (isChecked) { + setStock(value) + } else { + setStock(null) + } + } + const handleSubmit = () => { let params = { q: router.query.q, @@ -27,13 +67,23 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr brand, category, priceFrom, - priceTo + priceTo, + stock: stock } params = _.pickBy(params, _.identity) params = toQuery(params) router.push(`${prefixUrl}?${params}`) } + const formatCurrency = (value) => { + if (value >= 1000) { + const thousands = Math.floor(value / 1000) // Menghitung ribuan + return `Rp${thousands}k` + } else { + return `Rp${value}` + } + } + return (
@@ -49,7 +99,7 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr {brands.map((brand, index) => ( ))} @@ -106,6 +156,33 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr onChange={(e) => setPriceTo(e.target.value)} />
+
+ {priceRange.map((price, i) => ( + + ))} +
+
+
+ +
+ + Ketersedian Stok + +
diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index c79e355e..ef4580d6 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -28,10 +28,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { const popup = useActive() const numRows = [30, 50, 80, 100] - console.log('ini product search', productSearch.data) - const pageCount = Math.ceil( - productSearch.data?.response.numFound / limit - ) + const pageCount = Math.ceil(productSearch.data?.response.numFound / limit) const productStart = productSearch.data?.responseHeader.params.start const productRows = limit const productFound = productSearch.data?.response.numFound @@ -104,7 +101,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { const handleOrderBy = (e) => { let params = { ...router.query, - orderBy: e.target.value, + orderBy: e.target.value } params = _.pickBy(params, _.identity) params = toQuery(params) @@ -114,7 +111,7 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { const handleLimit = (e) => { let params = { ...router.query, - limit: e.target.value, + limit: e.target.value } params = _.pickBy(params, _.identity) params = toQuery(params) @@ -153,9 +150,9 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { {pageCount > 1 ? ( <> {productStart + 1}- - {productStart + productRows > productFound + {parseInt(productStart) + parseInt(productRows) > productFound ? productFound - : productStart + productRows} + : parseInt(productStart) + parseInt(productRows)}  dari  ) : ( @@ -175,9 +172,28 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => {
{productFound > 0 && ( - +
+
+ +
+
+ +
+
)}
-- cgit v1.2.3 From e4bce35fe6ec891bb8841bbfad981e97f5bb2aa8 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Wed, 11 Oct 2023 15:08:29 +0700 Subject: filter page brand --- src/lib/product/components/ProductFilter.jsx | 39 +++++++------- .../product/components/ProductFilterDesktop.jsx | 60 ++++++++++++---------- 2 files changed, 53 insertions(+), 46 deletions(-) (limited to 'src/lib/product') diff --git a/src/lib/product/components/ProductFilter.jsx b/src/lib/product/components/ProductFilter.jsx index 20c66a1f..40bfc824 100644 --- a/src/lib/product/components/ProductFilter.jsx +++ b/src/lib/product/components/ProductFilter.jsx @@ -87,24 +87,27 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr return (
- {!defaultBrand && ( -
- - -
- )} + {!router.pathname.includes('brands') && + !defaultBrand && ( +
+ + +
+ ) + } +
setBrand(e.target.value)} - > - - {brands.map((brand, index) => ( - - ))} - -
- ) - } - + {!router.pathname.includes('brands') && !defaultBrand && ( +
+ + +
+ )} +
diff --git a/src/lib/product/components/ProductFilterDesktop.jsx b/src/lib/product/components/ProductFilterDesktop.jsx index cdfd85e8..582dabea 100644 --- a/src/lib/product/components/ProductFilterDesktop.jsx +++ b/src/lib/product/components/ProductFilterDesktop.jsx @@ -156,12 +156,15 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu {categories.map((category, index) => (
- {category} +
+ {category.name} + ({category.qty}) +
))} diff --git a/src/lib/product/components/ProductSearch.jsx b/src/lib/product/components/ProductSearch.jsx index 3c954548..fd75d587 100644 --- a/src/lib/product/components/ProductSearch.jsx +++ b/src/lib/product/components/ProductSearch.jsx @@ -75,7 +75,9 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { ) { const brand = productSearch.data?.facetCounts?.facetFields?.manufactureName[i] const qty = productSearch.data?.facetCounts?.facetFields?.manufactureName[i + 1] - brands.push({ brand, qty }) + if (qty > 0) { + brands.push({ brand, qty }) + } } /*const brandsList = productSearch.data?.facetCounts?.facetFields?.manufactureName?.filter( (value, index) => { @@ -87,13 +89,22 @@ const ProductSearch = ({ query, prefixUrl, defaultBrand = null }) => { } )*/ - const categories = productSearch.data?.facetCounts?.facetFields?.categoryName?.filter( + const categories = [] + for (let i = 0; i < productSearch.data?.facetCounts?.facetFields?.categoryName.length; i += 2) { + const name = productSearch.data?.facetCounts?.facetFields?.categoryName[i] + const qty = productSearch.data?.facetCounts?.facetFields?.categoryName[i + 1] + if (qty > 0) { + categories.push({ name, qty }) + } + } + + /*const categories = productSearch.data?.facetCounts?.facetFields?.categoryName?.filter( (value, index) => { if (index % 2 === 0) { return true } } - ) + )*/ const orderOptions = [ { value: 'price-asc', label: 'Harga Terendah' }, -- cgit v1.2.3 From 43e59b8c7f8b742e5781a8a8b991afcf9aabb90e Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Sat, 14 Oct 2023 11:08:42 +0700 Subject: add information label if brand and categories in empty --- src/lib/product/components/ProductFilter.jsx | 36 ++++++++---- .../product/components/ProductFilterDesktop.jsx | 67 ++++++++++++---------- 2 files changed, 61 insertions(+), 42 deletions(-) (limited to 'src/lib/product') diff --git a/src/lib/product/components/ProductFilter.jsx b/src/lib/product/components/ProductFilter.jsx index 38e2d2c3..14eef0ba 100644 --- a/src/lib/product/components/ProductFilter.jsx +++ b/src/lib/product/components/ProductFilter.jsx @@ -96,12 +96,18 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr value={brand} onChange={(e) => setBrand(e.target.value)} > - - {brands.map((brand, index) => ( - - ))} + {brands.length > 0 ? ( + <> + + {brands.map((brand, index) => ( + + ))} + + ) : ( + + )}
)} @@ -114,12 +120,18 @@ const ProductFilter = ({ active, close, brands, categories, prefixUrl, defaultBr value={category} onChange={(e) => setCategory(e.target.value)} > - - {categories.map((category, index) => ( - - ))} + {categories.length > 0 ? ( + <> + + {categories.map((category, index) => ( + + ))} + + ) : ( + + )}
diff --git a/src/lib/product/components/ProductFilterDesktop.jsx b/src/lib/product/components/ProductFilterDesktop.jsx index 582dabea..e84d6526 100644 --- a/src/lib/product/components/ProductFilterDesktop.jsx +++ b/src/lib/product/components/ProductFilterDesktop.jsx @@ -111,7 +111,6 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu return ( <> - {!router.pathname.includes('brands') && ( @@ -123,21 +122,25 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu - {brands.map((brand, index) => ( -
- -
- {brand.brand} - ({brand.qty}) -
-
-
- ))} + {brands && brands.length > 0 ? ( + brands.map((brand, index) => ( +
+ +
+ {brand.brand} + ({brand.qty}) +
+
+
+ )) + ) : ( +
Brands tidak tersedia
+ )}
@@ -153,21 +156,25 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu - {categories.map((category, index) => ( -
- -
+ {categories && categories.length > 0 ? ( + categories.map((category, index) => ( +
+ +
{category.name} ({category.qty})
-
-
- ))} + +
+ )) + ) : ( +
Kategori tidak tersedia
+ )} @@ -218,7 +225,7 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu - + {/* Ketersedian Stok @@ -236,7 +243,7 @@ const ProductFilterDesktop = ({ brands, categories, prefixUrl, defaultBrand = nu Ketersedian Stock
- + */}
-
+
{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 }) => {