diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-07-12 14:31:07 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2023-07-12 14:31:07 +0700 |
| commit | 3f890e6d482cefba37014e021cb4c2b8d5de2a9d (patch) | |
| tree | 042b32495fe8d9ccc8058a7fa5c13bb3ad43b211 /src | |
| parent | c2be9e77d22840eb33142ea2e694c3278613c4ef (diff) | |
cr
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 34 | ||||
| -rw-r--r-- | src/lib/product/components/Product/ProductDesktop.jsx | 4 |
2 files changed, 19 insertions, 19 deletions
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 6990b420..27cdda76 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -17,6 +17,7 @@ import { useRouter } from 'next/router' import VariantGroupCard from '@/lib/variant/components/VariantGroupCard' import axios from 'axios' import Image from '@/core/components/elements/Image/Image' +import imageNext from 'next/image' import MobileView from '@/core/components/views/MobileView' import DesktopView from '@/core/components/views/DesktopView' import ExpedisiList from '../api/ExpedisiList' @@ -136,15 +137,11 @@ const Checkout = () => { let dataVoucherIndex = listVouchers.findIndex((voucher) => voucher.code == code) let dataActiveVoucher = listVouchers[dataVoucherIndex] - console.log('ini data active', dataActiveVoucher, code, dataVoucherIndex) let countDiscount = 0 if (dataActiveVoucher.discountType === 'percentage') { - countDiscount = (totalAmount - totalDiscountAmount) * 0.1 - if ( - dataActiveVoucher.maxDiscountAmount > 0 && - countDiscount > dataActiveVoucher.maxDiscountAmount - ) { + countDiscount = (totalAmount - totalDiscountAmount) * (dataActiveVoucher.discountAmount/100) + if (dataActiveVoucher.maxDiscountAmount > 0 && countDiscount > dataActiveVoucher.maxDiscountAmount) { countDiscount = dataActiveVoucher.maxDiscountAmount } } else { @@ -331,10 +328,14 @@ const Checkout = () => { } const handleUseVoucher = async (code) => { - SetActiveVoucher(code) - SetFindVoucher(null) - document.getElementById('uniqCode').value = '' - SetButtonTerapkan(false) + if(code === activeVoucher){ + SetActiveVoucher(null) + }else{ + SetActiveVoucher(code) + SetFindVoucher(null) + document.getElementById('uniqCode').value = '' + SetButtonTerapkan(false) + } } const onChangeCodeVoucher = async (e) => { @@ -354,7 +355,7 @@ const Checkout = () => { > <div className='row'> <div className='flex justify-between items-center'> - <div className='flex w-[70%]'> + <div className='flex md:w-[70%]'> <input type='text' id='uniqCode' @@ -398,7 +399,7 @@ const Checkout = () => { </div> )} - <hr className='mt-14 my-4 border-gray_r-10' /> + <hr className='mt-10 my-4 border-gray_r-10' /> <div className=''> {!listVouchers ? ( <div className='flex items-center justify-center mt-4 mb-4'> @@ -418,7 +419,7 @@ const Checkout = () => { <div className={`border border-solid mb-5 w-full hover:cursor-pointer p-4 `}> <div className={`flex gap-x-3`}> - <div className='hidden md:w-auto md:block'> + <div className='hidden md:w-[250px] md:block md:h-[150px]'> <Image src={item.image} alt={item.name} className={`object-cover`} /> </div> <div className='w-full'> @@ -434,9 +435,8 @@ const Checkout = () => { className='btn-solid-red w-[102px] md:flex-none rounded-md' type='button' onClick={() => handleUseVoucher(item.code)} - disabled={activeVoucher === item.code} > - {activeVoucher === item.code ? 'Terpakai' : 'Pakai'} + {activeVoucher === item.code ? 'Batal' : 'Pakai'} </button> </div> </div> @@ -609,7 +609,7 @@ const Checkout = () => { <Image src={'/images/DISKONICON.svg'} alt={''} - className='object-contain object-center h-6 w-full rounded-md' + className='object-contain object-center h-6 rounded-md' /> </span> {activeVoucher ? ( @@ -823,7 +823,7 @@ const Checkout = () => { <div>{currencyFormat(totalAmount)}</div> </div> <div className='flex gap-x-2 justify-between'> - <div className='text-gray_r-11'>Total Diskon</div> + <div className='text-gray_r-11'>Diskon Produk</div> <div className='text-danger-500'>- {currencyFormat(totalDiscountAmount)}</div> </div> {activeVoucher && ( diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx index 6a87d022..cafab721 100644 --- a/src/lib/product/components/Product/ProductDesktop.jsx +++ b/src/lib/product/components/Product/ProductDesktop.jsx @@ -66,9 +66,9 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => { } const handleBuy = (variant) => { - const quantity = variantQuantityRefs.current[variant.id].value + const quantity = variantQuantityRefs.current[variant].value if (!validQuantity(quantity)) return - router.push(`/shop/checkout?productId=${variant.id}&quantity=${quantity}`) + router.push(`/shop/checkout?productId=${variant}&quantity=${quantity}`) } const variantSectionRef = useRef(null) |
