| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 | 
							- import axios from "@/config/axios";
 
- import axios2 from "axios";
 
- export const createPengunjung = async (_csrf) => {
 
- 	try {
 
- 		const jsonip = await axios2.get("https://ip-api.io/json");
 
- 		const res = await axios.post(`/pengunjung/create?_csrf=${_csrf}`, {
 
- 			os: navigator.userAgentData.platform,
 
- 			ipv4: jsonip.data.ip,
 
- 			location: {
 
- 				country: jsonip.data.country_name,
 
- 				region: jsonip.data.region_name,
 
- 				city: jsonip.data.city,
 
- 				lat: jsonip.data.latitude,
 
- 				lon: jsonip.data.longitude,
 
- 				timezone: jsonip.data.time_zone,
 
- 			},
 
- 		});
 
- 		return res.data;
 
- 	} catch (error) {
 
- 		console.log("error", error);
 
- 		return false;
 
- 	}
 
- };
 
- export const getPengunjung = async (token) => {
 
- 	try {
 
- 		const res = await axios.get(`/pengunjung?tahun=${new Date().getFullYear()}`, { headers: { Authorization: token } });
 
- 		return res.data;
 
- 	} catch (error) {
 
- 		console.log("error", error);
 
- 		return false;
 
- 	}
 
- };
 
- export const getPengunjungPublic = async ({ bulan, tahun }) => {
 
- 	try {
 
- 		let url = "/public/pengunjung";
 
- 		if (bulan || tahun) {
 
- 			url += "?";
 
- 			const parseURL = [];
 
- 			if (bulan) {
 
- 				parseURL.push(`bulan=${bulan}`);
 
- 			}
 
- 			if (tahun) {
 
- 				parseURL.push(`tahun=${tahun}`);
 
- 			}
 
- 			url += parseURL.join("&");
 
- 		}
 
- 		const res = await axios.get(url);
 
- 		return res.data;
 
- 	} catch (error) {
 
- 		console.log("error", error);
 
- 		return false;
 
- 	}
 
- };
 
 
  |