import axiosAPI from "../config/axios";
import { createLog } from "./log";

export const addKeberatan = async (token, id, data) => {
	try {
		const res = await axiosAPI.post(`/sanksi/keberatan/create/${id}`, data, { headers: { Authorization: token } });
		await createLog(token, { aktivitas: `Berhasil mengajukan keberatan, id: ${id}` });
		return res.data;
	} catch (error) {
		console.log("error", error);
		await createLog(token, { aktivitas: `Gagal mengajukan keberatan, id: ${id}` });
		return false;
	}
};

export const addJawabanKeberatan = async (token, id, data) => {
	try {
		const res = await axiosAPI.post(`/sanksi/keberatan/jawaban/create/${id}`, data, { headers: { Authorization: token } });
		await createLog(token, { aktivitas: `Berhasil menjawab pengajuan keberatan, id: ${id}` });
		return res.data;
	} catch (error) {
		console.log("error", error);
		await createLog(token, { aktivitas: `Gagal menjawab pengajuan keberatan, id: ${id}` });
		return false;
	}
};
