diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-08-15 14:20:30 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-08-15 14:20:30 +0700 |
| commit | 4fb570559e293d506819059ce42836562a2fb4d2 (patch) | |
| tree | 4546cfa08d7be7342c80e2a1fa25a3d56dcbdeb1 /src/lib/product | |
| parent | bbbd7ccaab3102558dc82cbd051947b0e579360c (diff) | |
<iman> update search product using name
Diffstat (limited to 'src/lib/product')
| -rw-r--r-- | src/lib/product/components/Product/ProductDesktopVariant.jsx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/product/components/Product/ProductDesktopVariant.jsx b/src/lib/product/components/Product/ProductDesktopVariant.jsx index b8ec0580..c8a5a205 100644 --- a/src/lib/product/components/Product/ProductDesktopVariant.jsx +++ b/src/lib/product/components/Product/ProductDesktopVariant.jsx @@ -137,20 +137,25 @@ const ProductDesktopVariant = ({ }); } }; + const regex = /\b(?![A-Z\s]+\b)[A-Za-z\s]+\b/g; + const matches = product?.parent?.name?.match(regex); + const extractedName = matches ? matches.join(' ').trim() : ''; + console.log("extractedName",extractedName) const productSimilarQuery = [ product?.name, `fq=-product_id_i:${product.id}`, `fq=-manufacture_id_i:${product.manufacture?.id || 0}`, ].join('&'); - + const [productSimilarInBrand, setProductSimilarInBrand] = useState(null); - + useEffect(() => { const loadProductSimilarInBrand = async () => { const productSimilarQuery = [ product?.name, `fq=-product_id_i:${product.id}`, + `fq=display_name_s:${extractedName}`, ].join('&'); const dataProductSimilar = await productSimilarApi({ query: productSimilarQuery, |
