diff options
Diffstat (limited to 'src-migrate/services')
| -rw-r--r-- | src-migrate/services/banner.ts | 14 | ||||
| -rw-r--r-- | src-migrate/services/cart.ts | 28 |
2 files changed, 26 insertions, 16 deletions
diff --git a/src-migrate/services/banner.ts b/src-migrate/services/banner.ts index cb7b19cc..1b46ba06 100644 --- a/src-migrate/services/banner.ts +++ b/src-migrate/services/banner.ts @@ -1,13 +1,11 @@ import odooApi from '~/libs/odooApi'; import { IBanner } from '~/types/banner'; -type GetBannerProps = { +export const getBanner = async ({ + type, +}: { type: string; -}; - -export const getBanner = async (params: GetBannerProps): Promise<IBanner[]> => { - const url = `/api/v1/banner`; - const searchParams = new URLSearchParams(params); - - return await odooApi('GET', `${url}?${searchParams}`); +}): Promise<IBanner[]> => { + const searchParams = new URLSearchParams({ type }); + return await odooApi('GET', `/api/v1/banner?${searchParams.toString()}`); }; diff --git a/src-migrate/services/cart.ts b/src-migrate/services/cart.ts index 73967073..11f87125 100644 --- a/src-migrate/services/cart.ts +++ b/src-migrate/services/cart.ts @@ -4,20 +4,32 @@ export const getUserCart = async (userId: number) => { return await odooApi('GET', `/api/v1/user/${userId}/cart`); }; -export const upsertUserCart = async ( - userId: number, - type: 'product' | 'promotion', - id: number, - qty: number, - selected: boolean, - source: 'buy' | 'add_to_cart' = 'add_to_cart' -) => { +interface UpsertUserCartProps { + userId: number; + type: 'product' | 'promotion'; + id: number; + qty: number; + selected: boolean; + source?: 'buy' | 'add_to_cart'; + qtyAppend?: boolean; +} + +export const upsertUserCart = async ({ + userId, + type, + id, + qty, + selected, + source = 'add_to_cart', + qtyAppend = false, +}: UpsertUserCartProps) => { return await odooApi('POST', `/api/v1/user/${userId}/cart/create-or-update`, { product_id: type === 'product' ? id : null, qty, selected, program_line_id: type === 'promotion' ? id : null, source, + qty_append: qtyAppend, }); }; |
