import axios from "@/lib/axios"; import type { IPost, ISyncItem } from "@/lib/utils"; class ProductApiService { item_per_page = 10; async index(filter?: { skip?: number; limit?: number; order?: string; where?: Record; }) { const defaultFilter = { skip: 0, limit: 10, order: "updatedAt desc", where: { account: "prology_net", status: "Updated", }, }; return axios({ method: "POST", data: { urlAPI: "/api/ebay-listing/listing-get-list", filter: { ...defaultFilter, ...filter, // merge filter vào defaultFilter where: { ...defaultFilter.where, ...filter?.where, // merge where riêng để không mất account/status mặc định }, }, }, }); } async get(data: IPost) { return axios({ method: "POST", data: { urlAPI: "/api/product-model/get-info/" + data.id, pageCurrent: "/productdata/products/edit/" + data.id, }, }); } async sync(data: ISyncItem[]) { return axios({ url: "sync", method: "POST", data, }); } async getPublistedProducts() { return axios({ url: "data", }); } } export const productApi = new ProductApiService();