const URL = "/one-api/mockup/purchase/order/PurchaseOrderService/";

export async function getDaftarSupplier(params) {
    try {
        var response = await axios.post(URL + "getDaftarSupplier", 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 getDaftarCabang(params) {
    try {
        var response = await axios.post(URL + "getDaftarCabang", 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 getDaftarRequestJasa(params) {
    try {
        var response = await axios.post(URL + "searchRequestJasa", 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 getDaftarPOJasa(params) {
    try {
        var response = await axios.post(URL + "getDaftarPOJasa", 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 getDataKontrakPOJasa(params) {
    try {
        var response = await axios.post(URL + "getDataKontrakPOJasa", 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 createPOjasa(params) {
    try {
        var response = await axios.post(URL + "createPOjasa", 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 deletePOjasa(params) {
    try {
        var response = await axios.post(URL + "deletePOjasa", 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 updateApprovalPO(params) {
    try {
        var response = await axios.post(URL + "updateApprovalPO", 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 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 editPOjasa(params) {
    try {
        const response = await axios.post(URL + "editPOjasa", 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 getDaftarAttachment(params) {
    try {
        const response = await axios.post(URL + "getDaftarAttachment", 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
        };
    }
}