const URL = "/one-api/mockup/receive-item-po/ReceiveOrderService/";

export async function getListingVendor(params) {
    try {
        var response = await axios.post(URL + "getListingVendor", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getListBranch(params) {
    try {
        var response = await axios.post(URL + "getListBranch", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getDaftarStaff(params) {
    try {
        var response = await axios.post(URL + "getDaftarStaff", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function searchOrderJasa(params) {
    try {
        var response = await axios.post(URL + "searchOrderJasa", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function saveReceiveOrderJasa(params) {
    try {
        var response = await axios.post(URL + "saveReceiveOrderJasa", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getListingROJasa(params) {
    try {
        const response = await axios.post(URL + "getListingROJasa", params)
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            }
        };

        const data = response.data
        return data
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function uploadAttachment(params) {
    try {
        var response = await axios.post(URL + "uploadAttachment", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getListAttachment(params) {
    try {
        var response = await axios.post(URL + "getListAttachment", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function deleteReceiveOrder(params) {
    try {
        var response = await axios.post(URL + "deleteReceiveOrder", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getDetailDataROJasa(params) {
    try {
        var response = await axios.post(URL + "getDetailDataROJasa", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function confirmReceiveOrder(params) {
    try {
        var response = await axios.post(URL + "confirmReceiveOrder", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function saveEditReceiveOrderJasa(params) {
    try {
        var response = await axios.post(URL + "editReceiveOrderJasa", params);
        if (response.status !== 200) {
            return {
                status: "ERR",
                message: response.statusText
            };
        }

        let data = response.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}