summaryrefslogtreecommitdiff
path: root/src-migrate/services/wishlist.ts
blob: 6fb8cb2ea568723f93a566e2c02e42e933d4d188 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import odooApi from '~/libs/odooApi';

export const getUserWishlist = async (
  userId: number,
  searchParams: {
    product_id?: string;
  } = {}
): Promise<{ product_total: number }> => {
  const url = `/api/v1/user/${userId}/wishlist`;
  const searchParamsObj = new URLSearchParams(searchParams);

  return await odooApi('GET', url + '?' + searchParamsObj.toString());
};

export const upsertUserWishlist = async (
  userId: number,
  productId: number
): Promise<{ id: number }> => {
  const url = `/api/v1/user/${userId}/wishlist/create-or-delete`;
  const data = { product_id: productId };

  return await odooApi('POST', url, data);
};