| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | 
							- // import { API_URL } from "@/env";
 
- import axios from "../config/axios";
 
- export const getPelanggaranId = async (id) => {
 
- 	try {
 
- 		const data = { id };
 
- 		const myHeaders = new Headers();
 
- 		myHeaders.append("Content-Type", "application/json");
 
- 		const raw = JSON.stringify(data);
 
- 		const requestOptions = {
 
- 			method: "POST",
 
- 			body: raw,
 
- 			headers: myHeaders,
 
- 		};
 
- 		const res = await fetch(API_URL + "/pelanggaran", requestOptions);
 
- 		return await res.json();
 
- 	} catch (error) {
 
- 		console.log("error", error);
 
- 		return false;
 
- 	}
 
- };
 
- export const getPelanggaran = async (token, query) => {
 
- 	try {
 
- 		let url = "/pelanggaran";
 
- 		if (query != null) {
 
- 			const { id } = query;
 
- 			url += "?";
 
- 			const parseURL = [];
 
- 			if (id) {
 
- 				parseURL.push(`id=${id}`);
 
- 			}
 
- 			url += parseURL.join("&");
 
- 		}
 
- 		const res = await axios.get(url, {
 
- 			headers: {
 
- 				Authorization: token,
 
- 			},
 
- 		});
 
- 		return await res.data;
 
- 	} catch (error) {
 
- 		console.log("error", error);
 
- 		return false;
 
- 	}
 
- };
 
- export const getPelanggaranPublic = async (token) => {
 
- 	try {
 
- 		const res = await axios.get("/public/pelanggaran");
 
- 		return await res.data;
 
- 	} catch (error) {
 
- 		console.log("error", error);
 
- 		return false;
 
- 	}
 
- };
 
 
  |