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

export async function search(params) {
    try {
        var resp = await axios.post(URL + 'RequestmutasiApproved/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 + 'RequestmutasiApproved/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 + 'RequestmutasiApproved/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 + 'RequestmutasiApproved/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 + 'RequestmutasiApproved/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 + 'RequestmutasiApproved/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 + 'RequestmutasiApproved/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 + 'RequestmutasiApproved/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 + 'RequestmutasiApproved/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 + 'RequestmutasiApproved/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
        };
    }
}


export async function getApproveLevel(params) {
    try {
        var resp = await axios.post(URL + 'RequestmutasiApproved/getApproveLevel', 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 approveMutasiRequest(params) {
    try {
        var resp = await axios.post(URL + 'RequestmutasiApproved/approveMutasiRequest', 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 rejectMutasiRequest(params) {
    try {
        var resp = await axios.post(URL + 'RequestmutasiApproved/rejectMutasiRequest', 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
        };
    }
}
