summaryrefslogtreecommitdiff
path: root/src-migrate/services
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2024-06-21 11:01:35 +0700
committerit-fixcomart <it@fixcomart.co.id>2024-06-21 11:01:35 +0700
commit220190db66bcc1c6db78180c593f21e9cf8f363c (patch)
tree1517faa9636a6b3b2cc8d468a57b1fe476c229d7 /src-migrate/services
parent208b234320b6c42491a4e87a1c3db3abab9c1715 (diff)
parent1cf754b4d8da1aa28700ffc3dad67081f6daf9a5 (diff)
Merge branch 'promotion-program' into feature/all-promotion
Diffstat (limited to 'src-migrate/services')
-rw-r--r--src-migrate/services/banner.ts14
-rw-r--r--src-migrate/services/cart.ts28
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,
});
};