import { ApiHelper } from '/js/util/api.js';

export const PackingSaleOrderDataService = {
    GetProductListWithStock: async function (queryData) {
        return await ApiHelper.sendRequest('/api/PackingSaleOrder/GetProductListWithStock', "POST", queryData);
    },
    GetProduct: async function (id) {
        return (await ApiHelper.sendRequest(`/api/PackingSaleOrder/GetProduct?id=${id}`, "GET"));
    },
    GetAvailableStockList: async function (productId, attrId) {
        return await ApiHelper.sendRequest(`/api/PackingSaleOrder/GetAvailableStockList?productId=${productId}&attrId=${attrId}`, "GET");
    },
    AddProduct: async function (data) {
        return await ApiHelper.sendRequest('/api/PackingSaleOrder/AddProduct', "POST", data);
    },
    Create: async function (data) {
        return await ApiHelper.sendRequest('/api/PackingSaleOrder/Create', "POST", data);
    },
    Update: async function (data) {
        return await ApiHelper.sendRequest('/api/PackingSaleOrder/Update', 'PATCH', data);
    },
    Delete: async function (id) {
        return await ApiHelper.sendRequest(`/api/PackingSaleOrder/Delete?id=${id}`, "DELETE");
    },
    GetOrderAddress: async function (queryData) {
        return await ApiHelper.sendRequest('/api/PackingSaleOrder/GetOrderAddress', "POST", queryData);
    },
    GetOrder: async function (id) {
        return (await ApiHelper.sendRequest(`/api/PackingSaleOrder/GetOrder?id=${id}`, "GET"));
    },
    GetPackingByOrderId: async function (id) {
        return (await ApiHelper.sendRequest(`/api/PackingSaleOrder/GetPackingByOrderId?id=${id}`, "GET")).data;
    },
    ConfirmQC: async function (id) {
        return await ApiHelper.sendRequest(`/api/PackingSaleOrder/ConfirmQC?id=${id}`, "PATCH");
    },
    RestoreQC: async function (id) {
        return await ApiHelper.sendRequest(`/api/PackingSaleOrder/RestoreQC?id=${id}`, "PATCH");
    }
}