import axios from "@/config/axios";

export const getAutoSave = async ({ laporan, sanksi, id }) => {
    try {
        let url = "";
        if (laporan) {
            url += `/auto/save/${id}?laporan=true`;
        }
        if (sanksi) {
            url += `/auto/save/${id}?sanksi=true`;
        }
        const res = await axios.get(url);
        return res.data;
    } catch (error) {
        console.log("error", error);
        return false;
    }
};

export const inputAutoSave = async ({ token, laporan, sanksi, id, data }) => {
    try {
        let url = "";
        if (laporan) {
            url += `/auto/save/${id}?laporan=true`;
        }
        if (sanksi) {
            url += `/auto/save/${id}?sanksi=true`;
        }
        const res = await axios.post(url, data, { headers: { Authorization: token } });
        return res.data;
    } catch (error) {
        console.log("error", error);
        return false;
    }
};