summaryrefslogtreecommitdiff
path: root/src/lib/checkout/api/getVoucher.js
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-08-20 16:12:25 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-08-20 16:12:25 +0700
commit5c5eef9d62efd83f52f7c37dacb94d50ff7cb915 (patch)
tree7fdef4f99f0f42e2d99a40bfd5b81f1ca5f4ef30 /src/lib/checkout/api/getVoucher.js
parent004a9a644aed65d5c02263f19cce8b7c3000f354 (diff)
parent6d302bb338e26810a7f90326b84086217f1f4ae0 (diff)
Merge branch 'release' into Feature/category-management
Diffstat (limited to 'src/lib/checkout/api/getVoucher.js')
-rw-r--r--src/lib/checkout/api/getVoucher.js45
1 files changed, 29 insertions, 16 deletions
diff --git a/src/lib/checkout/api/getVoucher.js b/src/lib/checkout/api/getVoucher.js
index 07cf376e..779cef43 100644
--- a/src/lib/checkout/api/getVoucher.js
+++ b/src/lib/checkout/api/getVoucher.js
@@ -1,21 +1,34 @@
-import odooApi from '@/core/api/odooApi'
+import odooApi from '@/core/api/odooApi';
+import { getAuth } from '@/core/utils/auth'
-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;
+};
+
+
+export const getVoucherNew = async (source) => {
+ const id = getAuth()?.id;
+ const dataVoucher = await odooApi('GET', `/api/v1/user/${id}/voucher?${source}`)
+
return dataVoucher
-}
+
+} \ No newline at end of file