summaryrefslogtreecommitdiff
path: root/src/lib/checkout/api/getVoucher.js
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2024-04-03 10:31:14 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2024-04-03 10:31:14 +0700
commit50425ea134852897bf125aae0f68a1642eb3b3b8 (patch)
tree01203332dcc58c67d5285621f35cf5ac7d774867 /src/lib/checkout/api/getVoucher.js
parenta44ddf0ff093e09a0c70c61c0f65287bb7fdcbf3 (diff)
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;
+};