diff options
| author | it-fixcomart <it@fixcomart.co.id> | 2024-07-11 15:13:10 +0700 |
|---|---|---|
| committer | it-fixcomart <it@fixcomart.co.id> | 2024-07-11 15:13:10 +0700 |
| commit | 2d4f116eff62474a7b4b3af18a6053e031c03ff1 (patch) | |
| tree | 257c48affa3432b98492559b8b62ac77f99e6cf0 /src/lib/checkout/api/checkoutApi.js | |
| parent | c575aa3cbe740de143b5571ec4bfb7a8084946d7 (diff) | |
| parent | 8e881598fd7ea7b1b495209db13831bbfc324aa6 (diff) | |
Merge branch 'development' of https://bitbucket.org/altafixco/next-indoteknik into development
Diffstat (limited to 'src/lib/checkout/api/checkoutApi.js')
| -rw-r--r-- | src/lib/checkout/api/checkoutApi.js | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/src/lib/checkout/api/checkoutApi.js b/src/lib/checkout/api/checkoutApi.js index 24f1868a..fd982fff 100644 --- a/src/lib/checkout/api/checkoutApi.js +++ b/src/lib/checkout/api/checkoutApi.js @@ -1,28 +1,20 @@ -import odooApi from '@/core/api/odooApi' -import { getAuth } from '@/core/utils/auth' +import odooApi from '@/core/api/odooApi'; +import { getAuth } from '@/core/utils/auth'; export const checkoutApi = async ({ data }) => { - const auth = getAuth() + const auth = getAuth(); const dataCheckout = await odooApi( 'POST', `/api/v1/partner/${auth.partnerId}/sale_order/checkout`, data - ) - return dataCheckout -} + ); + return dataCheckout; +}; -export const getProductsCheckout = async (voucher, query) => { - const id = getAuth()?.id - let products - if(voucher && query){ - products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout?voucher=${voucher}&source=buy`) - }else if (voucher){ - products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout?voucher=${voucher}`) - }else if (query) { - products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout?source=buy`) - }else{ - products = await odooApi('GET',`/api/v1/user/${id}/sale_order/checkout`) - } - - return products -} +export const getProductsCheckout = async (query) => { + const queryParam = new URLSearchParams(query); + const userId = getAuth()?.id; + const url = `/api/v1/user/${userId}/sale_order/checkout?${queryParam.toString()}`; + const result = await odooApi('GET', url); + return result; +}; |
