const URL = "/one-api/mockup/mutasi/";

export async function search(params) {
    try {
        var resp = await axios.post(URL + 'Requestmutasi/search', params);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getCategory(params) {
    try {
        var resp = await axios.post(URL + 'Requestmutasi/getCategory', params);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getBranchAsal(params) {
    try {
        var resp = await axios.post(URL + 'Requestmutasi/getBranchAsal', params);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getBranchTujuan(params) {
    try {
        var resp = await axios.post(URL + 'Requestmutasi/getBranchTujuan', params);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getReceiveOrderPo(params) {
    try {
        var resp = await axios.post(URL + 'Requestmutasi/getReceiveOrderPo', params);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getItemReceive(params) {
    try {
        var resp = await axios.post(URL + 'Requestmutasi/getItemReceive', params);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function saveMutasi(params) {
    try {
        var resp = await axios.post(URL + 'Requestmutasi/saveMutasi', params);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function getItemMutasiUpdate(params) {
    try {
        var resp = await axios.post(URL + 'Requestmutasi/getItemMutasiUpdate', params);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function saveEditMutasi(params) {
    try {
        var resp = await axios.post(URL + 'Requestmutasi/saveEditMutasi', params);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}

export async function deleteMutasi(params) {
    try {
        var resp = await axios.post(URL + 'Requestmutasi/deleteMutasi', params);
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (error) {
        return {
            status: "ERR",
            message: error.message
        };
    }
}
