diff options
| author | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-12 09:47:01 +0700 |
|---|---|---|
| committer | Rafi Zadanly <zadanlyr@gmail.com> | 2023-09-12 09:47:01 +0700 |
| commit | 916973828a2088cf6d5d867ec7a9aefe9f95bf0d (patch) | |
| tree | 02075b4606b6f0c538b0e7833322f9142cbcf51c /src/lib/product/components/Product/ProductMobile.jsx | |
| parent | de08ef4031c69550e32b2e8d18abc76c1030fe4d (diff) | |
| parent | fc1d22565e08db8c49fa21b498ec1e02455c5c9b (diff) | |
Merge branch 'master' into development
Diffstat (limited to 'src/lib/product/components/Product/ProductMobile.jsx')
| -rw-r--r-- | src/lib/product/components/Product/ProductMobile.jsx | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx index d25d0861..56f20aac 100644 --- a/src/lib/product/components/Product/ProductMobile.jsx +++ b/src/lib/product/components/Product/ProductMobile.jsx @@ -62,12 +62,25 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { hasProgram: false }) - const variantOptions = product.variants?.map((variant) => ({ - value: variant.id, - label: - (variant.code ? `[${variant.code}] ` : '') + - (variant.attributes.length > 0 ? variant.attributes.join(', ') : product.name) - })) + const variantOptions = product.variants?.map((variant) => { + let label = [] + if (variant.isFlashsale) { + label.push("<span class='blink-color-flash-sale'>🗲</span>") + } + if (variant.code) { + label.push(`[${variant.code}]`) + } + if (variant.attributes.length > 0) { + label.push(variant.attributes.join(', ')) + } else { + label.push(product.name) + } + + return { + value: variant.id, + label: label.join(' ') + } + }) useEffect(() => { const fetchData = async () => { @@ -279,6 +292,7 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => { name='variant' classNamePrefix='form-select' options={variantOptions} + formatOptionLabel={({ label }) => <div dangerouslySetInnerHTML={{ __html: label }} />} className='mt-2' value={selectedVariant} onChange={(option) => setSelectedVariant(option)} |
