public.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 addDaftarHadirPeserta = async (token, data) => {
  17. const getToken = await getCsrf();
  18. const _csrf = getToken.token;
  19. try {
  20. const res = await axiosAPI.post(`/signature?_csrf=${_csrf}`, data, { headers: { Authorization: token } });
  21. return res.data;
  22. } catch (error) {
  23. console.log("error", error.response.data);
  24. return false;
  25. }
  26. };
  27. export const getDaftarHadirPeserta = async (token, id, query = {}) => {
  28. try {
  29. let url = `/signature/${id}`;
  30. const res = await axiosAPI.get(url, { headers: { Authorization: token } });
  31. return res.data;
  32. } catch (error) {
  33. console.log("error", error);
  34. return false;
  35. }
  36. };
  37. export const getOneLaporanPublic = async (id, query = {}) => {
  38. try {
  39. let url = `public/laporan/${id}`;
  40. if (query != null) {
  41. const { aktif, all } = query;
  42. url += "?";
  43. const parseURL = [];
  44. if (all) {
  45. parseURL.push(`all=true`);
  46. }
  47. if (aktif === false) {
  48. parseURL.push(`aktif=false`);
  49. }
  50. url += parseURL.join("&");
  51. }
  52. const res = await axiosAPI.get(url);
  53. return res.data;
  54. } catch (error) {
  55. console.log("error", error);
  56. return false;
  57. }
  58. };