public.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { get, post, del, put } from "../config/request";
  2. import axiosAPI from "../config/axios";
  3. import { createLog } from "./log";
  4. import { getCsrf } from "./security";
  5. export const addPesertaPleno = async (token, data) => {
  6. const getToken = await getCsrf();
  7. const _csrf = getToken.token;
  8. try {
  9. const res = await axiosAPI.post(`/public/sanksi/add-peserta-pleno?_csrf=${_csrf}`, data, { headers: { Authorization: token } });
  10. return res.data;
  11. } catch (error) {
  12. console.log("error", error.response.data);
  13. return false;
  14. }
  15. };
  16. export const getOneLaporanPublic = async (id, query = {}) => {
  17. try {
  18. let url = `public/laporan/${id}`;
  19. if (query != null) {
  20. const { aktif, all } = query;
  21. url += "?";
  22. const parseURL = [];
  23. if (all) {
  24. parseURL.push(`all=true`);
  25. }
  26. if (aktif === false) {
  27. parseURL.push(`aktif=false`);
  28. }
  29. url += parseURL.join("&");
  30. }
  31. const res = await axiosAPI.get(url);
  32. return res.data;
  33. } catch (error) {
  34. console.log("error", error);
  35. return false;
  36. }
  37. };