import { addLog } from "./log";

export const insertPemeriksaan = async ({ number, ptId }, data) => {
	try {
		const requestOptions = {
			method: "POST",
			body: data,
		};

		const res = await fetch(`http://localhost:5000/pelaporan/pemeriksaan/create?number=${number}&ptId=${ptId}`, requestOptions);
		const result = await res.json();
		addLog({ status: "SUCCESS", action: "ADD", from: { id: result.added._id, data: "pemeriksaan" }, description: "menambah evaluasi" });
		return result;
	} catch (error) {
		console.log("error", error);
		addLog({ status: "FAIL", action: "ADD", from: { data: "pemeriksaan" }, description: error.message || "menambah evaluasi" });
		return false;
	}
};
