|
|
@@ -1,5 +1,6 @@
|
|
|
import { get, post, del, put } from "../config/request";
|
|
|
import axiosAPI from "../config/axios";
|
|
|
+import { createLog } from "./log";
|
|
|
|
|
|
export const getPelaporan = async (token, query = {}) => {
|
|
|
try {
|
|
|
@@ -52,6 +53,7 @@ export const getPelaporanPublic = async ({ number, noHp }) => {
|
|
|
|
|
|
export const createPelaporan = async (token, data) => {
|
|
|
const res = await axiosAPI.post("/laporan/create", data, { headers: { Authorization: token } });
|
|
|
+ await createLog(token, { aktivitas: "Berhasil Membuat pelaporan" });
|
|
|
return res.data;
|
|
|
};
|
|
|
|
|
|
@@ -88,9 +90,12 @@ export const createLaporanPublic = async (token, data) => {
|
|
|
export const updateLaporan = async (token, id, data) => {
|
|
|
try {
|
|
|
const res = await axiosAPI.put(`/laporan/update/${id}`, data, { headers: { Authorization: token } });
|
|
|
+ if (data.aktif === "false") await createLog(token, { aktivitas: `Berhasil menutup laporan, id: ${id}` });
|
|
|
+ await createLog(token, { aktivitas: `Berhasil mengubah data laporan, id: ${id}` });
|
|
|
return res.data;
|
|
|
} catch (error) {
|
|
|
console.log("error", error.response.data);
|
|
|
+ await createLog(token, { aktivitas: `Gagal mengubah data pelaporan, id: ${id}` });
|
|
|
return false;
|
|
|
}
|
|
|
};
|