summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortrisusilo48 <tri.susilo@altama.co.id>2024-11-07 12:59:56 +0700
committertrisusilo48 <tri.susilo@altama.co.id>2024-11-07 12:59:56 +0700
commitebba81f144b860eaf3bd7a9ef2b1c63a2ff021e0 (patch)
treedbcc68f5c6dd750c41f3b1fbc5c3c2331f58c994 /src/lib
parented0adaad2125b46a6c039ce89b38b3cbb8379342 (diff)
get couries biteship
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/checkout/api/ExpedisiList.js25
-rw-r--r--src/lib/checkout/components/Checkout.jsx58
-rw-r--r--src/lib/checkout/components/SectionExpedition.tsx12
-rw-r--r--src/lib/checkout/stores/useAdress.js6
4 files changed, 44 insertions, 57 deletions
diff --git a/src/lib/checkout/api/ExpedisiList.js b/src/lib/checkout/api/ExpedisiList.js
index ca22bec1..110295b7 100644
--- a/src/lib/checkout/api/ExpedisiList.js
+++ b/src/lib/checkout/api/ExpedisiList.js
@@ -1,8 +1,23 @@
-import odooApi from '@/core/api/odooApi'
+import odooApi from '@/core/api/odooApi';
+import axios from 'axios';
+import biteShipAPI from '../../../core/api/biteShip';
const ExpedisiList = async () => {
- const dataExpedisi = await odooApi('GET', '/api/v1/courier')
- return dataExpedisi
-}
+ const dataExpedisi = await odooApi('GET', '/api/v1/courier');
+ return dataExpedisi;
+};
-export default ExpedisiList
+const GetRatesCourierBiteship = async ({ destination, items }) => {
+ const couriers = process.env.NEXT_PUBLIC_BITESHIP_CODE_COURIERS;
+ let body = {
+ destination,
+ couriers: couriers,
+ items
+ };
+
+ const featch = await biteShipAPI('POST', '/v1/rates/couriers', body);
+
+ return featch;
+};
+
+export { GetRatesCourierBiteship, ExpedisiList} ;
diff --git a/src/lib/checkout/components/Checkout.jsx b/src/lib/checkout/components/Checkout.jsx
index 97254ec0..6da27745 100644
--- a/src/lib/checkout/components/Checkout.jsx
+++ b/src/lib/checkout/components/Checkout.jsx
@@ -269,58 +269,6 @@ const Checkout = () => {
};
}, []);
- const hitungDiscountVoucher = (code, source) => {
- let countDiscount = 0;
- if (source === 'voucher') {
- let dataVoucherIndex = listVouchers.findIndex(
- (voucher) => voucher.code == code
- );
- let dataActiveVoucher = listVouchers[dataVoucherIndex];
-
- countDiscount = dataActiveVoucher.discountVoucher;
- } else {
- let dataVoucherIndex = listVoucherShippings.findIndex(
- (voucher) => voucher.code == code
- );
- let dataActiveVoucher = listVoucherShippings[dataVoucherIndex];
-
- countDiscount = dataActiveVoucher.discountVoucher;
- }
-
- /*if (dataActiveVoucher.discountType === 'percentage') {
- countDiscount = cartCheckout?.subtotal * (dataActiveVoucher.discountAmount / 100)
- if (
- dataActiveVoucher.maxDiscountAmount > 0 &&
- countDiscount > dataActiveVoucher.maxDiscountAmount
- ) {
- countDiscount = dataActiveVoucher.maxDiscountAmount
- }
- } else {
- countDiscount = dataActiveVoucher.discountAmount
- }*/
-
- return countDiscount;
- };
-
- // useEffect(() => {
- // if (!listVouchers) return;
- // if (!activeVoucher) return;
-
- // console.log('voucher')
- // const countDiscount = hitungDiscountVoucher(activeVoucher, 'voucher');
-
- // SetDiscountVoucher(countDiscount);
- // }, [activeVoucher, listVouchers]);
-
- // useEffect(() => {
- // if (!listVoucherShippings) return;
- // if (!activeVoucherShipping) return;
-
- // const countDiscount = hitungDiscountVoucher(activeVoucherShipping, 'voucher_shipping');
-
- // SetDiscountVoucherOngkir(countDiscount);
- // }, [activeVoucherShipping, listVoucherShippings]);
-
useEffect(() => {
if (qVoucher === 'PASTIHEMAT' && listVouchers) {
let code = qVoucher;
@@ -1698,6 +1646,12 @@ const SectionValidation = ({ address }) =>
</BottomPopup>
);
+const SectionExpedisiBiteship = ({ listExpedisi, setSelectedExpedisi }) => (
+ <>
+ </>
+);
+
+
const SectionExpedisi = ({
address,
listExpedisi,
diff --git a/src/lib/checkout/components/SectionExpedition.tsx b/src/lib/checkout/components/SectionExpedition.tsx
new file mode 100644
index 00000000..d2dd5763
--- /dev/null
+++ b/src/lib/checkout/components/SectionExpedition.tsx
@@ -0,0 +1,12 @@
+import React from 'react';
+import { GetRatesCourierBiteship } from '../api/ExpedisiList';
+import { useQuery } from 'react-query';
+
+export default function SectionExpedition() {
+ let destination = {}
+ let items = {}
+ const fetchExpedition = async () => await GetRatesCourierBiteship({destination, items});
+ const {data : coursers, isLoading} = useQuery('expedition-'+destination, fetchExpedition)
+
+ return <div>SectionExpedition</div>;
+} \ No newline at end of file
diff --git a/src/lib/checkout/stores/useAdress.js b/src/lib/checkout/stores/useAdress.js
new file mode 100644
index 00000000..1c17258d
--- /dev/null
+++ b/src/lib/checkout/stores/useAdress.js
@@ -0,0 +1,6 @@
+import { create } from "zustand";
+
+export const useAddress = create((set) => ({
+ address: {},
+ setAddress: (address) => set({ address }),
+})); \ No newline at end of file