|
|
@@ -0,0 +1,84 @@
|
|
|
+import axiosAPI from "../config/axios";
|
|
|
+import { createLog } from "./log";
|
|
|
+
|
|
|
+import { getCsrf } from "./security";
|
|
|
+
|
|
|
+export const addCatatan = async (token, id, data, _csrf) => {
|
|
|
+ const res = await axiosAPI.post(`/catatan/${id}`, data, { headers: { Authorization: token } });
|
|
|
+ await log(token, id)
|
|
|
+ return res.data;
|
|
|
+};
|
|
|
+export const updateCatatan = async (token, id, data, _csrf) => {
|
|
|
+ const res = await axiosAPI.put(`/catatan/${id}`, data, { headers: { Authorization: token } });
|
|
|
+ await log(token, id)
|
|
|
+ return res.data;
|
|
|
+};
|
|
|
+
|
|
|
+export const getAllCatatan = async (token, id, menu) => {
|
|
|
+ try {
|
|
|
+ let url = `/catatan/${id}?menu=${menu}`;
|
|
|
+ const res = await axiosAPI.get(url, { headers: { Authorization: token } });
|
|
|
+ return res.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error", error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+};
|
|
|
+export const getOneCatatan = async (token, id) => {
|
|
|
+ try {
|
|
|
+ let url = `/catatan/detail/${id}`;
|
|
|
+ const res = await axiosAPI.get(url, { headers: { Authorization: token } });
|
|
|
+ return res.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error", error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+};
|
|
|
+export const deleteCatatan = async (token, id) => {
|
|
|
+ try {
|
|
|
+ let url = `/catatan/${id}`;
|
|
|
+ const res = await axiosAPI.delete(url, { headers: { Authorization: token } });
|
|
|
+ return res.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error", error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+};
|
|
|
+// export const deletePeserta = async (token, data, id) => {
|
|
|
+// try {
|
|
|
+// let url = `/catatan/hadir/${id}`;
|
|
|
+// const res = await axiosAPI.delete(url, data, { headers: { Authorization: token } });
|
|
|
+// return res.data;
|
|
|
+// } catch (error) {
|
|
|
+// console.log("error", error);
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// };
|
|
|
+export const deletePeserta = async (token, data, id) => {
|
|
|
+ console.log(data)
|
|
|
+ try {
|
|
|
+ const res = await axiosAPI.delete(`/catatan/hadir/${id}`, {
|
|
|
+ headers: { Authorization: token },
|
|
|
+ data: data // Correctly passing the data in the request body
|
|
|
+ }); return res.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error", error.response.data);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+export const addDaftarHadirPeserta = async (token, data, id) => {
|
|
|
+ try {
|
|
|
+ const res = await axiosAPI.post(`/catatan/hadir/${id}`, data, { headers: { Authorization: token } });
|
|
|
+ return res.data;
|
|
|
+ } catch (error) {
|
|
|
+ console.log("error", error.response.data);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+};
|
|
|
+const log = async (token, id) => {
|
|
|
+ const getToken = await getCsrf();
|
|
|
+ const _csrf = getToken.token;
|
|
|
+ await createLog(token, { aktivitas: `Berhasil menambah evaluasi, id: ${id}`, menu: "Pemeriksaan", _csrf: _csrf });
|
|
|
+
|
|
|
+}
|