summaryrefslogtreecommitdiff
path: root/src-migrate/services/productVariant.ts
blob: 9fec4d1fc3d3821667cda703c1ea9cfa5a3004ba (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';
import { IProductVariantSLA } from '~/types/productVariant';
import { CategoryPromo, IPromotion } from '~/types/promotion';

export const getVariantById = async (variantId: number) => {
  const url = `/api/product-variant/${variantId}`;
  return await fetch(url).then((res) => res.json());
};

export const getVariantPromoByCategory = async (
  variantId: number,
  type: CategoryPromo
): Promise<{ data: IPromotion[] }> => {
  const url = `/api/product-variant/${variantId}/promotion/${type}`;
  return await fetch(url).then((res) => res.json());
};

export const getVariantSLA = async (
  variantId: number
): Promise<IProductVariantSLA> => {
  const url = `/api/v1/product_variant/${variantId}/stock`;
  return await odooApi('GET', url);
};