diff options
Diffstat (limited to 'src/lib/checkout/components/Checkout.jsx')
| -rw-r--r-- | src/lib/checkout/components/Checkout.jsx | 34 |
1 files changed, 17 insertions, 17 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 && ( |
