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

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

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