summaryrefslogtreecommitdiff
path: root/src-migrate/services
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2024-02-26 15:12:12 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2024-02-26 15:12:12 +0700
commita698514b32353d8f6386ce8ba8c20941ab65f569 (patch)
tree0c60dc5897b5fb5936025342ae24d8b115f024ce /src-migrate/services
parent55d476a4666150a013a308deb6cb99513778ac22 (diff)
Add qty append on upsert cart api
Diffstat (limited to 'src-migrate/services')
-rw-r--r--src-migrate/services/cart.ts28
1 files changed, 20 insertions, 8 deletions
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,
});
};