summaryrefslogtreecommitdiff
path: root/src/lib/product/components/Product/ProductMobile.jsx
diff options
context:
space:
mode:
authortrisusilo <tri.susilo@altama.co.id>2023-07-24 03:32:03 +0000
committertrisusilo <tri.susilo@altama.co.id>2023-07-24 03:32:03 +0000
commit4fcb73a336a6025a0ead194b317543efcd4f0e4b (patch)
tree20ea651ea2c02be2bae2c2915ca5ab7ff2f95538 /src/lib/product/components/Product/ProductMobile.jsx
parentd61b3ca0213395099e4cea9ace8172d4e622fb52 (diff)
parent984f1b13b408ee9652072392d6312d609b353315 (diff)
Merged in Feature/promotion_programvaoucher (pull request #15)
Feature/promotion programvaoucher
Diffstat (limited to 'src/lib/product/components/Product/ProductMobile.jsx')
-rw-r--r--src/lib/product/components/Product/ProductMobile.jsx22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx
index 667a4ba1..fa1e2521 100644
--- a/src/lib/product/components/Product/ProductMobile.jsx
+++ b/src/lib/product/components/Product/ProductMobile.jsx
@@ -14,6 +14,7 @@ import { toast } from 'react-hot-toast'
import { createSlug } from '@/core/utils/slug'
import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
import whatsappUrl from '@/core/utils/whatsappUrl'
+import PromotionType from '@/lib/promotinProgram/components/PromotionType'
import { gtagAddToCart } from '@/core/utils/googleTag'
const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
@@ -24,6 +25,9 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
const [informationTab, setInformationTab] = useState(informationTabOptions[0].value)
const [addCartAlert, setAddCartAlert] = useState(false)
+ const [promotionType, setPromotionType] = useState(false)
+ const [promotionActiveId, setPromotionActiveId] = useState(null)
+
const getLowestPrice = () => {
const prices = product.variants.map((variant) => variant.price)
const lowest = prices.reduce((lowest, price) => {
@@ -38,7 +42,8 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
name: product.name,
price: getLowestPrice(),
stock: product.stockTotal,
- weight: product.weight
+ weight: product.weight,
+ hasProgram: false
})
const variantOptions = product.variants?.map((variant) => ({
@@ -66,7 +71,8 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
name: variant.parent.name + variantAttributes,
price: variant.price,
stock: variant.stock,
- weight: variant.weight
+ weight: variant.weight,
+ hasProgram: variant.hasProgram
})
}
}, [selectedVariant, product])
@@ -90,6 +96,7 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
updateItemCart({
productId: activeVariant.id,
quantity,
+ programLineId: promotionActiveId,
selected: true
})
setAddCartAlert(true)
@@ -187,6 +194,17 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
isSearchable={product.variantTotal > 10}
/>
</div>
+ {activeVariant.hasProgram && (
+ <div className='mt-5'>
+ <PromotionType
+ variantId={product.variants[0].id}
+ setPromotionActiveId={setPromotionActiveId}
+ promotionActiveId={promotionActiveId}
+ quantity={quantity}
+ ></PromotionType>
+ </div>
+ )}
+
<div className='mt-4 mb-2'>Jumlah</div>
<div className='flex gap-x-3'>
<div className='w-2/12'>