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

console.log("user new v5")
export async function reset_password(prm) {
    try {
        var resp = await axios.post(URL + 'usergroupv6/reset_password', 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 save(prm) {
    try {
        var resp = await axios.post(URL + 'usergroupv6/addnewuser', 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 save_edit(prm) {
    try {
        var resp = await axios.post(URL + 'usergroupv6/edituser', 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 + 'usergroupv6/deleteuser', { 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
        };
    }
}

export async function lookup(token,id) {
    try {
        var resp = await axios.post(URL + 'usergroupv6/lookupuser', { 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
        };
    }
}
