124 lines
2.9 KiB
TypeScript
124 lines
2.9 KiB
TypeScript
import axios from "axios";
|
|
import { CookieValueTypes, getCookie } from "cookies-next";
|
|
|
|
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
|
// axios.defaults.baseURL = "https://shahrbinapi.shetabdahi.ir/";
|
|
|
|
axios.interceptors.request.use(function (config) {
|
|
const token = getCookie("Shahrbin_Token");
|
|
config.headers.Authorization = token ? `Bearer ${token}` : "";
|
|
return config;
|
|
});
|
|
|
|
// Get CitizenReport
|
|
export async function getCitizenReport({
|
|
PageNumber = 1,
|
|
PageSize = 10,
|
|
instanceId = 1,
|
|
}: {
|
|
PageNumber?: number;
|
|
PageSize?: number;
|
|
instanceId?: number;
|
|
}) {
|
|
const data = await axios.get(
|
|
`/api/CitizenReport?instanceId=${instanceId}&PageNumber=${PageNumber}&PageSize=${PageSize}`,
|
|
{}
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
// Post CitizenReport
|
|
export async function postCitizenReport(payload: {
|
|
instanceId: number;
|
|
categoryId: number;
|
|
comments: string;
|
|
address: {
|
|
regionId: number;
|
|
latitude: number;
|
|
longitude: number;
|
|
detail: string;
|
|
};
|
|
attachments: [];
|
|
isIdentityVisible: true;
|
|
}) {
|
|
const data = await axios.post(`api/api/CitizenReport`, payload);
|
|
return data.data;
|
|
}
|
|
|
|
|
|
// Get CitizenReport Nearest
|
|
export async function getCitizenReportNearest({
|
|
PageNumber = 1,
|
|
PageSize = 10,
|
|
instanceId = 1,
|
|
}: {
|
|
PageNumber?: number;
|
|
PageSize?: number;
|
|
instanceId?: number;
|
|
}) {
|
|
const data = await axios.get(
|
|
`/api/CitizenReport/Nearest?instanceId=${instanceId}&PageNumber=${PageNumber}&PageSize=${PageSize}`,
|
|
{}
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
|
|
// Get Location
|
|
export async function getLocations() {
|
|
const data = await axios.get(`/api/CitizenReport/Locations?instanceId=1`);
|
|
return data.data;
|
|
}
|
|
|
|
// Get Location {ID}
|
|
export async function getSingleLocations(id: any) {
|
|
const data = await axios.get(`/api/CitizenReport/Locations/${id}`);
|
|
return data.data;
|
|
}
|
|
|
|
|
|
// Get CitizenReport Mine
|
|
export async function getCitizenReportMine({
|
|
PageNumber = 1,
|
|
PageSize = 10,
|
|
}: {
|
|
PageNumber?: number;
|
|
PageSize?: number;
|
|
}) {
|
|
const data = await axios.get(
|
|
`/api/CitizenReport/Mine?PageNumber=${PageNumber}&PageSize=${PageSize}`
|
|
);
|
|
return data.data;
|
|
}
|
|
|
|
// Get CitizenReport Mine {Id}
|
|
export async function getSingleCitizenReportMine(id: string) {
|
|
const data = await axios.get(`/api/CitizenReport/Mine/${id}`);
|
|
return data.data;
|
|
}
|
|
|
|
|
|
// Put CitizenReport Like
|
|
export async function SetLike({
|
|
id,
|
|
isLiked,
|
|
}: {
|
|
id: string;
|
|
isLiked: boolean;
|
|
}) {
|
|
const data = await axios.put(`/api/CitizenReport/Like/${id}?isLiked=${isLiked}`);
|
|
return data.data;
|
|
}
|
|
|
|
|
|
// Post CitizenReport Comment {id}
|
|
export async function postComment(id: string, comment: string) {
|
|
const data = await axios.post(`/api/CitizenReport/Comment/${id}`, { comment });
|
|
return data.data;
|
|
}
|
|
|
|
// Get CitizenReport Comment {id}
|
|
export async function getComments(id: string) {
|
|
const data = await axios.get(`/api/CitizenReport/Comments/${id}`);
|
|
return data.data;
|
|
} |