diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/components/elements/Popup/BottomPopup.jsx | 6 | ||||
| -rw-r--r-- | src/lib/cart/components/Cart.jsx | 4 | ||||
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 23 |
3 files changed, 22 insertions, 11 deletions
diff --git a/src/core/components/elements/Popup/BottomPopup.jsx b/src/core/components/elements/Popup/BottomPopup.jsx index c244330c..5828d222 100644 --- a/src/core/components/elements/Popup/BottomPopup.jsx +++ b/src/core/components/elements/Popup/BottomPopup.jsx @@ -48,9 +48,9 @@ const BottomPopup = ({ children, active = false, title, close }) => { <DesktopView> <motion.div - initial={{ bottom: '35%', opacity: 0 }} - animate={{ bottom: '30%', opacity: 1 }} - exit={{ bottom: '25%', opacity: 0 }} + initial={{ bottom: '40%', opacity: 0 }} + animate={{ bottom: '35%', opacity: 1 }} + exit={{ bottom: '30%', opacity: 0 }} transition={transition} className='fixed left-1/2 -translate-x-1/2 w-2/5 border border-gray_r-6 rounded-xl z-[60] p-4 pt-0 bg-white' > diff --git a/src/lib/cart/components/Cart.jsx b/src/lib/cart/components/Cart.jsx index d646420c..7ebee14b 100644 --- a/src/lib/cart/components/Cart.jsx +++ b/src/lib/cart/components/Cart.jsx @@ -93,11 +93,11 @@ const Cart = () => { quantity -= value break case 'BLUR': - if (value != '') return + if (value != '' && value > 0) return quantity = 1 break default: - quantity = value + quantity = value != '' && value < 1 ? 1 : value break } productsToUpdate[productIndex].quantity = quantity diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 57d217a7..048bb24e 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -19,6 +19,7 @@ import axios from 'axios' import Image from '@/core/components/elements/Image/Image' import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' +import variantPriceApi from '@/lib/variant/api/variantPriceApi' const Checkout = () => { const router = useRouter() @@ -77,11 +78,21 @@ const Checkout = () => { } const dataProducts = await CartApi({ variantIds }) - const dataProductsQuantity = _.map(dataProducts, (o) => ({ - ...o, - quantity: query.quantity ? query.quantity : getItemCart({ productId: o.id }).quantity - })) - setProducts(dataProductsQuantity) + const productsWithQuantity = dataProducts.map(async (product) => { + const productPrice = await variantPriceApi({ id: product.id }) + return { + ...product, + price: { + price: productPrice.priceExclude, + discountPercentage: productPrice.discount, + priceDiscount: productPrice.priceExcludeAfterDiscount + }, + quantity: query.quantity ? query.quantity : getItemCart({ productId: product.id }).quantity + } + }) + Promise.all(productsWithQuantity).then((resolvedProducts) => { + setProducts(resolvedProducts) + }) } loadProducts() }, [router]) @@ -439,7 +450,7 @@ const Checkout = () => { <p className='text-caption-2 text-gray_r-11 mt-2'>Ukuran dokumen PO Maksimal 5MB</p> <hr className='my-4 border-gray_r-6' /> - + <button className='w-full btn-yellow mt-4' onClick={checkout} |
