const URL = "/one-api/mockup/purchase/transfer/TransferRequestNP/";
const URL_SJ = "/one-api/mockup/purchase/suratjalan/SuratJalan/";

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

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

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

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

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

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

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

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

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

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