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

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