// const URL = "/one-api/v1/masterdata/";
const URL = "/one-api/mockup/masterdata/accounting/";

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

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

export async function xdelete(token,id) {
    try {
        var resp = await axios.post(URL + 'divisi/delete', 
        { id: id, token:token });
        if (resp.status != 200) {
            return {
                status: "ERR",
                message: resp.statusText
            };
        }
        let data = resp.data;
        return data;
    } catch (e) {
        return {
            status: "ERR",
            message: e.message
        };
    }
}

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