summaryrefslogtreecommitdiff
path: root/src/lib/checkout/api/getVoucher.js
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-04-05 07:42:54 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-04-05 07:42:54 +0000
commitd551570b1a4c08d415e299f37eba86879ba96b57 (patch)
tree9bce735e93158ea1aaa1a3be6ca013cc22507b35 /src/lib/checkout/api/getVoucher.js
parent8eb374869c950c3879d0b463729d1f078b38325a (diff)
parent50425ea134852897bf125aae0f68a1642eb3b3b8 (diff)
Merged in feature/voucher-shipment (pull request #133)
Add voucher shipping feature
Diffstat (limited to 'src/lib/checkout/api/getVoucher.js')
-rw-r--r--src/lib/checkout/api/getVoucher.js37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/lib/checkout/api/getVoucher.js b/src/lib/checkout/api/getVoucher.js
index 07cf376e..54c8cce5 100644
--- a/src/lib/checkout/api/getVoucher.js
+++ b/src/lib/checkout/api/getVoucher.js
@@ -1,21 +1,24 @@
-import odooApi from '@/core/api/odooApi'
+import odooApi from '@/core/api/odooApi';
-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 getVoucher = async (id, query) => {
+ const queryParam = new URLSearchParams(query);
+ const url = `/api/v1/user/${id}/voucher?${queryParam.toString()}`;
+ const dataVoucher = await odooApi('GET', url);
+ return dataVoucher;
+};
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}`)
+ 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
-}
+ return dataVoucher;
+};