From a698514b32353d8f6386ce8ba8c20941ab65f569 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Mon, 26 Feb 2024 15:12:12 +0700 Subject: Add qty append on upsert cart api --- src-migrate/services/cart.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'src-migrate/services') 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, }); }; -- cgit v1.2.3 From 59e4c1cf1b45497bc98cbc13c57e33e1a256a22e Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Thu, 25 Apr 2024 11:33:09 +0700 Subject: Add side and bottom banner on search --- src-migrate/services/banner.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src-migrate/services/banner.ts (limited to 'src-migrate/services') diff --git a/src-migrate/services/banner.ts b/src-migrate/services/banner.ts new file mode 100644 index 00000000..1b46ba06 --- /dev/null +++ b/src-migrate/services/banner.ts @@ -0,0 +1,11 @@ +import odooApi from '~/libs/odooApi'; +import { IBanner } from '~/types/banner'; + +export const getBanner = async ({ + type, +}: { + type: string; +}): Promise => { + const searchParams = new URLSearchParams({ type }); + return await odooApi('GET', `/api/v1/banner?${searchParams.toString()}`); +}; -- cgit v1.2.3