From a7574b1276d751824b0c16c0696133ea1517223a Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Thu, 3 Aug 2023 17:06:09 +0700 Subject: voucher --- src/lib/checkout/components/Checkout.jsx | 161 +++++++++++++++++++------------ 1 file changed, 97 insertions(+), 64 deletions(-) (limited to 'src/lib') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 53ac63e1..9ffac61a 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -301,7 +301,7 @@ const Checkout = () => { voucher: activeVoucher, type: 'sale_order' } - if(query){ + if (query) { data.source = 'buy' } if (poNumber.current.value) data.po_number = poNumber.current.value @@ -491,6 +491,81 @@ const Checkout = () => { )}
+ {item.canApply && ( + + )} + {!item.canApply && item.applyStatus === 'UM' && ( + + )} + + {!item.canApply && + item.applyStatus === 'MPA' && + item.manufactureNames != '' && ( + + )} + + {!item.canApply && + item.applyStatus === 'MPA' && + item.manufactureNames === '' && ( + + )} + + {!item.canApply && + item.has_flashsale_products && + item.apply_status === 'UM' && ( + + )} +
{item.name} @@ -516,7 +591,7 @@ const Checkout = () => {
-
+

Kode Voucher :{' '} @@ -528,51 +603,30 @@ const Checkout = () => { )}

+
+ + + Berakhir dalam{' '} + {item.remainingTime} lagi{' '} + +

- {!item.canApply && - item.applyStatus === 'MPA' && - item.manufactureNames != '' && ( -

- Tambah produk{' '} - {item.manufactureNames} senilai{' '} - - {currencyFormat(item.differenceToApply)} - {' '} - untuk pakai promo ini -

- )} - {!item.canApply && - item.applyStatus === 'MPA' && - item.manufactureNames === '' && ( -

- Tambah{' '} - - {currencyFormat(item.differenceToApply)} - {' '} - untuk pakai promo ini{' '} -

- )} - {!item.canApply && item.applyStatus === 'UM' && ( -

- Tambah produk{' '} - {item.manufactureNames} senilai{' '} - - {currencyFormat(item.minPurchaseAmount)} - {' '} - untuk pakai promo ini -

- )} - {item.canApply && ( -

- Potensi potongan sebesar{' '} - - {currencyFormat(item.discountVoucher)} - -

- )} {/* {item.canApply === false ? 'Tambah ' + currencyFormat(item.differenceToApply) + @@ -580,27 +634,6 @@ const Checkout = () => { : 'Potensi potongan sebesar ' + currencyFormat(hitungDiscountVoucher(item.code))} */}

-
-
- - - Berakhir dalam {item.remainingTime}{' '} - lagi{' '} - -
-- cgit v1.2.3 From 77a5ab2d7dd9967e41d9c365e6e5dd45a2d32db2 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 4 Aug 2023 13:31:19 +0700 Subject: bugs fix voucher --- src/lib/checkout/api/getVoucher.js | 18 ++++++++++++++---- src/lib/checkout/components/Checkout.jsx | 6 +++--- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'src/lib') diff --git a/src/lib/checkout/api/getVoucher.js b/src/lib/checkout/api/getVoucher.js index 57d8acf5..07cf376e 100644 --- a/src/lib/checkout/api/getVoucher.js +++ b/src/lib/checkout/api/getVoucher.js @@ -1,11 +1,21 @@ import odooApi from '@/core/api/odooApi' -export const getVoucher = async (id) => { - const dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher`) +export const getVoucher = async (id, source) => { + let dataVoucher = null + if(source){ + dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?source=${source}`) + }else { + dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher`) + } return dataVoucher } -export const findVoucher = async (code, id) => { - const dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?code=${code}`) +export const findVoucher = async (code, id, source) => { + let dataVoucher = null + if(source){ + dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?code=${code}&source=${source}`) + }else{ + dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?code=${code}`) + } return dataVoucher } diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 53ac63e1..c6ea73f2 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -107,7 +107,7 @@ const Checkout = () => { const voucher = async () => { if (!listVouchers) { try { - let dataVoucher = await getVoucher(auth?.id) + let dataVoucher = await getVoucher(auth?.id, query) SetListVoucher(dataVoucher) } finally { setLoadingVoucher(false) @@ -115,7 +115,7 @@ const Checkout = () => { } } const VoucherCode = async (code) => { - let dataVoucher = await findVoucher(code, auth.id) + let dataVoucher = await findVoucher(code, auth.id, query) if (dataVoucher.length <= 0) { SetFindVoucher(1) return @@ -427,7 +427,7 @@ const Checkout = () => {
- {!loadingVoucher && listVouchers.length === 0 ? ( + {!loadingVoucher && listVouchers?.length === 0 ? (

Tidak ada voucher tersedia

-- cgit v1.2.3 From 71748842100e833472c56194e57c309539478dd3 Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Fri, 4 Aug 2023 14:30:21 +0700 Subject: cr voucher --- src/lib/checkout/components/Checkout.jsx | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/lib') diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx index 9ffac61a..5265a794 100644 --- a/src/lib/checkout/components/Checkout.jsx +++ b/src/lib/checkout/components/Checkout.jsx @@ -490,7 +490,7 @@ const Checkout = () => {
)} -
+
{item.canApply && (
{

)} + {!item.canApply && item.applyStatus === 'MPA-HF' && ( + + )} {!item.canApply && item.applyStatus === 'UM' && ( )} - - {!item.canApply && - item.has_flashsale_products && - item.apply_status === 'UM' && ( - - )} -
{item.name} -- cgit v1.2.3