| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import axios from "@/config/axios";
- import axios2 from "axios";
- export const getLog = async (token, laporan_id) => {
- try {
- let url = `/pemantauan/${laporan_id}?all=true`;
- const res = await axios.get(url, {
- headers: {
- Authorization: token,
- },
- });
- return res.data;
- } catch (error) {
- console.log("error", error);
- return false;
- }
- };
- export const getLogPT = async (token) => {
- try {
- let url = `/pemantauan/pt`;
- const res = await axios.get(url, {
- headers: {
- Authorization: token,
- },
- });
- return res.data;
- } catch (error) {
- console.log("error", error);
- return false;
- }
- };
- export const getLogPublic = async ({ no_hp, no_laporan }) => {
- try {
- const res = await axios.get(`/public/pemantauan?no_hp=${no_hp}&no_laporan=${no_laporan}`);
- return res.data;
- } catch (error) {
- console.log("error", error);
- return false;
- }
- };
- export const createLog = async (token, data) => {
- try {
- const jsonip = await axios2.get("https://jsonip.com", { mode: "cors" });
- const res = await axios.post("/log", { os: navigator.userAgentData.platform, ipv4: jsonip.data.ip, ...data }, { headers: { Authorization: token } });
- return res.data;
- } catch (error) {
- console.log("error", error);
- return false;
- }
- };
- export const getLog2 = async (token, query = {}) => {
- try {
- let url = "/log";
- if (query != null) {
- const { fromDate, toDate } = query;
- url += "?";
- const parseURL = [];
- if (fromDate) {
- parseURL.push(`from_date=${fromDate}`);
- }
- if (toDate) {
- parseURL.push(`to_date=${toDate}`);
- }
- url += parseURL.join("&")
- }
- const res = await axios.get(url, { headers: { Authorization: token } });
- return res.data
- } catch (error) {
- console.log("error", error);
- return false;
- }
- };
|