summaryrefslogtreecommitdiff
path: root/src-migrate/services
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2023-12-15 17:15:32 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2023-12-15 17:15:32 +0700
commitc9366090153e8aba3a673b2b77cbc8acc24e59a5 (patch)
tree9bad672e511d5585bb4be5b4e3190aca7c4a16af /src-migrate/services
parenta5321d82f4b5e8404f575f1d62e92d0322d78db9 (diff)
Update promotion program feature
Diffstat (limited to 'src-migrate/services')
-rw-r--r--src-migrate/services/auth.ts24
-rw-r--r--src-migrate/services/banner.ts0
-rw-r--r--src-migrate/services/cart.ts29
-rw-r--r--src-migrate/services/pageContent.ts11
4 files changed, 35 insertions, 29 deletions
diff --git a/src-migrate/services/auth.ts b/src-migrate/services/auth.ts
index a5d02754..1cc09c10 100644
--- a/src-migrate/services/auth.ts
+++ b/src-migrate/services/auth.ts
@@ -15,39 +15,23 @@ const BASE_PATH = '/api/v1/user';
export const registerUser = async (
data: RegisterProps
): Promise<RegisterResApiProps> => {
- const response = await odooApi('POST', `${BASE_PATH}/register`, data);
-
- return response;
+ return await odooApi('POST', `${BASE_PATH}/register`, data);
};
export const activationUserToken = async (
params: ActivationTokenProps
): Promise<ActivationTokenResApiProps> => {
- const response = await odooApi(
- 'POST',
- `${BASE_PATH}/activation-token`,
- params
- );
-
- return response;
+ return await odooApi('POST', `${BASE_PATH}/activation-token`, params);
};
export const activationUserOTP = async (
params: ActivationOtpProps
): Promise<ActivationOtpResApiProps> => {
- const response = await odooApi('POST', `${BASE_PATH}/activation-otp`, params);
-
- return response;
+ return await odooApi('POST', `${BASE_PATH}/activation-otp`, params);
};
export const activationReq = async (
params: ActivationReqProps
): Promise<ActivationReqResApiProps> => {
- const response = await odooApi(
- 'POST',
- `${BASE_PATH}/activation-request`,
- params
- );
-
- return response;
+ return await odooApi('POST', `${BASE_PATH}/activation-request`, params);
};
diff --git a/src-migrate/services/banner.ts b/src-migrate/services/banner.ts
deleted file mode 100644
index e69de29b..00000000
--- a/src-migrate/services/banner.ts
+++ /dev/null
diff --git a/src-migrate/services/cart.ts b/src-migrate/services/cart.ts
new file mode 100644
index 00000000..b238be3d
--- /dev/null
+++ b/src-migrate/services/cart.ts
@@ -0,0 +1,29 @@
+import odooApi from '~/common/libs/odooApi';
+
+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'
+) => {
+ 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,
+ });
+};
+
+export const deleteUserCart = async (userId: number, ids: number[]) => {
+ return await odooApi(
+ 'DELETE',
+ `/api/v1/user/${userId}/cart?ids=${ids.join(',')}`
+ );
+};
diff --git a/src-migrate/services/pageContent.ts b/src-migrate/services/pageContent.ts
index 24f2c2f0..16146059 100644
--- a/src-migrate/services/pageContent.ts
+++ b/src-migrate/services/pageContent.ts
@@ -1,14 +1,7 @@
import odooApi from '~/common/libs/odooApi';
export const getPageContent = async ({ path }: { path: string }) => {
- const params = new URLSearchParams({
- url_path: path,
- });
+ const params = new URLSearchParams({ url_path: path });
- const pageContent = await odooApi(
- 'GET',
- `/api/v1/page-content?${params.toString()}`
- );
-
- return pageContent;
+ return await odooApi('GET', `/api/v1/page-content?${params.toString()}`);
};