summaryrefslogtreecommitdiff
path: root/src/lib/checkout
diff options
context:
space:
mode:
authorIndoteknik . <andrifebriyadiputra@gmail.com>2025-05-26 12:37:08 +0700
committerIndoteknik . <andrifebriyadiputra@gmail.com>2025-05-26 12:37:08 +0700
commit2102158d77211991673aa7ed7cfacda69cceda2e (patch)
treec788fe583c25d172df93841f403389d01d9198dd /src/lib/checkout
parentca05a70e98e9066882de6394ffbd89db7af2cb9d (diff)
parent4ef92b4d9fea4fdd636d62194514b33ed3b3c387 (diff)
(andri) resolve conflict
Diffstat (limited to 'src/lib/checkout')
-rw-r--r--src/lib/checkout/components/Checkout.jsx57
-rw-r--r--src/lib/checkout/components/CheckoutSection.jsx2
-rw-r--r--src/lib/checkout/components/FinishCheckout.jsx9
3 files changed, 51 insertions, 17 deletions
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 637706a2..77c8ede7 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -55,7 +55,9 @@ function convertToInternational(number) {
}
const Checkout = () => {
- const PPN = process.env.NEXT_PUBLIC_PPN ? parseFloat(process.env.NEXT_PUBLIC_PPN) : 0;
+ const PPN = process.env.NEXT_PUBLIC_PPN
+ ? parseFloat(process.env.NEXT_PUBLIC_PPN)
+ : 0;
const router = useRouter();
const query = router.query.source ?? null;
const qVoucher = router.query.voucher ?? null;
@@ -181,16 +183,31 @@ const Checkout = () => {
if (!listVouchers) {
try {
setLoadingVoucher(true);
+ const productCategories = products
+ ?.reduce((categories, product) => {
+ if (product.categories && Array.isArray(product.categories)) {
+ product.categories.forEach((category) => {
+ if (category.id && !categories.includes(category.id)) {
+ categories.push(category.id);
+ }
+ });
+ }
+ return categories;
+ }, [])
+ .join(',');
+
let dataVoucher = await getVoucher(auth?.id, {
source: query,
type: 'all,brand',
- partner_id : auth?.partnerId,
+ partner_id: auth?.partnerId,
+ voucher_category: productCategories, // Add the product categories
});
SetListVoucher(dataVoucher);
let dataVoucherShipping = await getVoucher(auth?.id, {
source: query,
type: 'shipping',
+ voucher_category: productCategories, // Add the product categories
});
SetListVoucherShipping(dataVoucherShipping);
} finally {
@@ -200,10 +217,23 @@ const Checkout = () => {
};
const VoucherCode = async (code) => {
- // let dataVoucher = await findVoucher(code, auth.id, query);
+ const productCategories = products
+ ?.reduce((categories, product) => {
+ if (product.categories && Array.isArray(product.categories)) {
+ product.categories.forEach((category) => {
+ if (category.id && !categories.includes(category.id)) {
+ categories.push(category.id);
+ }
+ });
+ }
+ return categories;
+ }, [])
+ .join(',');
+
let dataVoucher = await getVoucher(auth?.id, {
source: query,
code: code,
+ voucher_category: productCategories, // Add the product categories
});
if (dataVoucher.length <= 0) {
SetFindVoucher(1);
@@ -1028,7 +1058,7 @@ const Checkout = () => {
)}
<Divider />
<SectionValidation address={selectedAddress.invoicing} />
- {/* <SectionExpedisi
+ <SectionExpedisi
address={selectedAddress.shipping}
listExpedisi={listExpedisi}
setSelectedExpedisi={setSelectedExpedisi}
@@ -1041,7 +1071,7 @@ const Checkout = () => {
<SectionListService
listserviceExpedisi={listserviceExpedisi}
setSelectedServiceType={setSelectedServiceType}
- /> */}
+ />
<div className='p-4 flex flex-col gap-y-4'>
{!!products &&
@@ -1123,7 +1153,9 @@ const Checkout = () => {
<div>{currencyFormat(cartCheckout?.subtotal)}</div>
</div>
<div className='flex gap-x-2 justify-between'>
- <div className='text-gray_r-11'>PPN {((PPN - 1) * 100).toFixed(0)}%</div>
+ <div className='text-gray_r-11'>
+ PPN {((PPN - 1) * 100).toFixed(0)}%
+ </div>
<div>{currencyFormat(cartCheckout?.tax)}</div>
</div>
<div className='flex gap-x-2 justify-between'>
@@ -1329,7 +1361,7 @@ const Checkout = () => {
{products && <SectionExpedition products={products} />}
<Divider />
<SectionValidation address={selectedAddress.invoicing} />
- {/* <SectionExpedisi
+ <SectionExpedisi
address={selectedAddress.shipping}
listExpedisi={listExpedisi}
setSelectedExpedisi={setSelectedExpedisi}
@@ -1342,7 +1374,7 @@ const Checkout = () => {
<SectionListService
listserviceExpedisi={listserviceExpedisi}
setSelectedServiceType={setSelectedServiceType}
- /> */}
+ />
<div className='p-4'>
<div className='font-medium mb-6'>Detail Pesanan</div>
@@ -1430,7 +1462,9 @@ const Checkout = () => {
<div>{currencyFormat(cartCheckout?.subtotal)}</div>
</div>
<div className='flex gap-x-2 justify-between'>
- <div className='text-gray_r-11'>PPN {((PPN - 1) * 100).toFixed(0)}%</div>
+ <div className='text-gray_r-11'>
+ PPN {((PPN - 1) * 100).toFixed(0)}%
+ </div>
<div>{currencyFormat(cartCheckout?.tax)}</div>
</div>
<div className='flex gap-x-2 justify-between'>
@@ -1630,7 +1664,8 @@ const SectionAddress = ({ address, label, url }) => (
);
const SectionValidation = ({ address }) =>
- address?.stateId == 0 && (
+ address?.stateId == 0 ||
+ (address?.rajaongkirCityId == 0 && (
<BottomPopup active={true} title='Update Alamat'>
<div className='leading-7 text-gray_r-12/80'>
Mohon untuk memperbarui alamat Anda dengan mengklik tombol di bawah ini.{' '}
@@ -1644,7 +1679,7 @@ const SectionValidation = ({ address }) =>
</Link>
</div>
</BottomPopup>
- );
+ ));
const SectionExpedisi = ({
address,
diff --git a/src/lib/checkout/components/CheckoutSection.jsx b/src/lib/checkout/components/CheckoutSection.jsx
index c82e15c7..c6be9056 100644
--- a/src/lib/checkout/components/CheckoutSection.jsx
+++ b/src/lib/checkout/components/CheckoutSection.jsx
@@ -33,7 +33,7 @@ export const SectionAddress = ({ address, label, url }) => {
};
export const SectionValidation = ({ address }) =>
- address?.stateId == 0 && (
+ address?.stateId == 0 || address?.rajaongkirCityId == 0 && (
<BottomPopup active={true} title='Update Alamat'>
<div className='leading-7 text-gray_r-12/80'>
Mohon untuk memperbarui alamat Anda dengan mengklik tombol di bawah ini.{' '}
diff --git a/src/lib/checkout/components/FinishCheckout.jsx b/src/lib/checkout/components/FinishCheckout.jsx
index 4a67b252..d533325e 100644
--- a/src/lib/checkout/components/FinishCheckout.jsx
+++ b/src/lib/checkout/components/FinishCheckout.jsx
@@ -53,13 +53,12 @@ const FinishCheckout = ({ query }) => {
height={isMobile ? 300 : 450}
/>
<div className='text-title-sm md:text-title-lg text-center font-semibold'>
- Terima Kasih atas Pembelian Kamu
+ Terima Kasih atas Pembelian di Indoteknik.com
</div>
+ <p className='text-title-sm md:text-title-lg font-semibold my-2'>No. Transaksi: <span className='text-red-500'>{query?.order_id?.replaceAll('-', '/')}</span></p>
<div className='flex flex-col justify-center items-center text-body-2 md:text-body-1 text-center mt-3 px-24 md:px-36 py-4 border-2 gap-y-2 rounded'>
- <p className='font-bold'>No. Transaksi</p>
- <p className='mb-2 font-medium text-red-500 text-xl'>
- {query?.order_id?.replaceAll('-', '/')}
- </p>
+ <p className="text-title-sm md:text-title-xl text-gray-500 mt-1">Estimasi Barang Siap pada Tanggal</p>
+ <p className="text-title-sm md:text-title-xl text-red-500 font-semibold my-2">{data?.expectedReadyToShip}</p>
<Link
href={`/my/quotations/${data?.id}`}
className='btn-solid-red rounded-md text-base'