import { addLog } from "./log";

export const addCabutSanksi = async ({ noSanksi, ptId }, data) => {
	try {
		const res = await fetch(`http://localhost:5000/cabut-sanksi/add?noSanksi=${noSanksi}&ptId=${ptId}`, {
			method: "POST",
			body: data,
		});
		const result = await res.json();
		console.log(result);
		// addLog({ status: "SUCCESS", action: "CREATE", from: { id: result.added._id, data: "cabut-sanksi" }, description: "membuat permohonan cabut-sanksi" });
		return result;
	} catch (error) {
		console.log("error", error);
		addLog({ status: "FAIL", action: "ADD", from: { data: "cabut-sanksi" }, description: error.message || "membuat permohonan banding" });
		return false;
	}
};

export const addJawabanCabutSanksi = async ({ noSanksi, ptId }, data) => {
	try {
		const res = await fetch(`http://localhost:5000/cabut-sanksi/jawaban/add?noSanksi=${noSanksi}&ptId=${ptId}`, {
			method: "POST",
			body: data,
		});
		const result = await res.json();
		console.log(result);
		// addLog({ status: "SUCCESS", action: "CREATE", from: { id: result.added._id, data: "cabut-sanksi" }, description: "membuat jawaban permohonan cabut-sanksi" });
		return result;
	} catch (error) {
		console.log("error", error);
		// addLog({ status: "FAIL", action: "ADD", from: { data: "cabut-sanksi" }, description: error.message || "membuat jawaban permohonan banding" });
		return false;
	}
};
