diff options
| author | trisusilo48 <tri.susilo@altama.co.id> | 2024-07-11 11:28:37 +0700 |
|---|---|---|
| committer | trisusilo48 <tri.susilo@altama.co.id> | 2024-07-11 11:28:37 +0700 |
| commit | 4009290d0cc0d762fa3aba6ef8a8bcb0423d51d2 (patch) | |
| tree | b20eaad0cbdcbf9a4bed98cbc50c26acfeadda91 /src/lib/checkout/api/getVoucher.js | |
| parent | 64448e6d7db7bc4f389f53344a80d93f529f7d8c (diff) | |
| parent | d551570b1a4c08d415e299f37eba86879ba96b57 (diff) | |
Merge branch 'dev/voucher-shipment' into development
# Conflicts:
# src/lib/checkout/components/Checkout.jsx
Diffstat (limited to 'src/lib/checkout/api/getVoucher.js')
| -rw-r--r-- | src/lib/checkout/api/getVoucher.js | 37 |
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; +}; |
