Added part of Map , RecentRequestCard
parent
9a61a5c90a
commit
eecb99ee5c
14
.env
14
.env
|
|
@ -1,10 +1,10 @@
|
|||
NEXT_PUBLIC_BASE_URL_APP="https://shahrbinapi.shetabdahi.ir/"
|
||||
|
||||
REACT_APP_APP_CITY= yazd
|
||||
REACT_APP_MUNICIPALITY_LOGO= Yazd-Municipality.png
|
||||
REACT_APP_LOGO= shahrbin_yazd.png
|
||||
REACT_APP_LATITUDE= 31.8974
|
||||
REACT_APP_LONGITUDE= 54.3569
|
||||
REACT_APP_PMI_TOKEN=p18879615a54484eb98d403da218956ecaa2740c42
|
||||
REACT_APP_MY_GOV_LINK= https://my.yazd.ir/api/oauth/authorize/?response_type=code&client_id=jwjOjhnZzct0AzNSacV0XYOvxOKXrLfnumM8hYPN&scope=read
|
||||
NEXT_PUBLIC_APP_CITY= yazd
|
||||
NEXT_PUBLIC_MUNICIPALITY_LOGO= Yazd-Municipality.png
|
||||
NEXT_PUBLIC_LOGO= shahrbin_yazd.png
|
||||
NEXT_PUBLIC_LATITUDE= 31.8974
|
||||
NEXT_PUBLIC_LONGITUDE= 54.3569
|
||||
NEXT_PUBLIC_PMI_TOKEN=p18879615a54484eb98d403da218956ecaa2740c42
|
||||
NEXT_PUBLIC_MY_GOV_LINK= https://my.yazd.ir/api/oauth/authorize/?response_type=code&client_id=jwjOjhnZzct0AzNSacV0XYOvxOKXrLfnumM8hYPN&scope=read
|
||||
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=pk.eyJ1IjoiZmFicmljOCIsImEiOiJjaWc5aTV1ZzUwMDJwdzJrb2w0dXRmc2d0In0.p6GGlfyV-WksaDV_KdN27A
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import React from "react";
|
|||
export default function page() {
|
||||
return (
|
||||
<section className="flex w-full md:grid md:grid-cols-2 h-full items-start flex-col overflow-y-auto p-5 scrollbar-thin scrollbar-thumb-yellow scrollbar-track-white">
|
||||
<RequestCard />
|
||||
<RequestCard isSelfRequest={true} />
|
||||
{/* <RequestList /> */}
|
||||
</section>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
"use client";
|
||||
import React, { useRef, useState } from "react";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import { getLocations } from "@/utils/CitizenReport";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { ThreeDots } from "react-loader-spinner";
|
||||
|
|
@ -18,17 +18,27 @@ const MapContainer = ReactMapboxGl({
|
|||
});
|
||||
|
||||
const OnMapRequests = () => {
|
||||
const [selected, setSelected] = useState(null);
|
||||
const [selected, setSelected] = useState<any | null>(null);
|
||||
const [citizenInstance, setCitizenInstance] = useState<any | null>(null);
|
||||
const [locations, setLocations] = useState<any | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
const CtizenInstances = localStorage.getItem("SH_CT_INSTANCE");
|
||||
setCitizenInstance(CtizenInstances);
|
||||
|
||||
console.log("🚀 ~ useEffect ~ CtizenInstancessssss:", citizenInstance);
|
||||
console.log("🚀 ~ useEffect ~ CtizenInstancessssssss:", CtizenInstances);
|
||||
|
||||
const defaultCoords = {
|
||||
// latitude: citizenInstance.latitude,
|
||||
// longitude: citizenInstance.longitude,
|
||||
};
|
||||
}, [citizenInstance]);
|
||||
|
||||
// refs
|
||||
const detailsRef = useRef(null);
|
||||
const wrappersRef = useRef(null);
|
||||
|
||||
const defaultCoords = {
|
||||
// latitude: instances[0].latitude,
|
||||
// longitude: instances[0].longitude,
|
||||
};
|
||||
|
||||
// hooks
|
||||
// const [detailsClicked, setDetailsClicked] = useClick({
|
||||
// element: detailsRef,
|
||||
|
|
@ -59,23 +69,28 @@ const OnMapRequests = () => {
|
|||
} = useQuery({
|
||||
queryKey: ["Locations"],
|
||||
queryFn: () => getLocations(),
|
||||
// refetchOnWindowFocus: false,
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
if (isSuccess) {
|
||||
console.log(LocationData?.locations[0].locations);
|
||||
const fetchedContent = LocationData?.locations[0].locations;
|
||||
console.log(fetchedContent);
|
||||
}
|
||||
useEffect(() => {
|
||||
if (LocationData) {
|
||||
console.log("🚀 ~ OnMapRequests ~ LocationData:", LocationData);
|
||||
console.log(
|
||||
"🚀 ~ OnMapRequestssss ~ LocationDataa:",
|
||||
LocationData?.data?.locations[0]?.locations
|
||||
);
|
||||
setLocations(LocationData?.data?.locations[0]?.locations);
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
if (isError) {
|
||||
console.log("have a errorrrrrrr ");
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="w-full h-full">
|
||||
{isLoading ? (
|
||||
<div className="flex justify-center text-center w-36">
|
||||
<div className="flex justify-center items-center text-center w-full h-full ">
|
||||
<ThreeDots
|
||||
visible={true}
|
||||
height="50"
|
||||
|
|
@ -93,51 +108,45 @@ const OnMapRequests = () => {
|
|||
// store.instance?.longitude || defaultCoords.longitude,
|
||||
// store.instance?.latitude || defaultCoords.latitude,
|
||||
// ]}
|
||||
center={[54.3683, 32.4279]}
|
||||
zoom={[10]}
|
||||
center={[31.887935423191124, 54.355335268625275]}
|
||||
containerStyle={{ height: "100%", width: "100%", borderRadius: 20 }}
|
||||
style={`https://api.parsimap.ir/styles/parsimap-streets-v11?key=${process.env.REACT_APP_PMI_TOKEN}`}
|
||||
style={`https://api.parsimap.ir/styles/parsimap-streets-v11?key=${process.env.NEXT_PUBLIC_PMI_TOKEN}`}
|
||||
// onClick={onMapClicked}
|
||||
>
|
||||
{/* {LocationData?.map((d) => (
|
||||
<Marker coordinates={[d.longitude, d.latitude]}>
|
||||
<img src={marker} onClick={() => showDetails(d)} />
|
||||
</Marker>
|
||||
))} */}
|
||||
{LocationData?.map(() => (
|
||||
<Marker>
|
||||
<img src={marker} onClick={() => showDetails()} />
|
||||
{locations?.map((d: any) => (
|
||||
<Marker
|
||||
key={d.reportId}
|
||||
coordinates={[d.longitude, d.latitude]}
|
||||
// coordinates={[ 31.887935423191124, 54.355335268625275,]}
|
||||
>
|
||||
<img src={marker} />
|
||||
{/* <img src={marker} onClick={() => showDetails(d)} /> */}
|
||||
</Marker>
|
||||
))}
|
||||
|
||||
<Marker
|
||||
// coordinates={[
|
||||
// selected?.address?.longitude || defaultCoords.latitude,
|
||||
// selected?.address?.latitude || defaultCoords.longitude,
|
||||
// ]}
|
||||
{/* Open CardData */}
|
||||
{/* <Marker
|
||||
coordinates={[
|
||||
31.887935423191124, 54.355335268625275,
|
||||
selected?.address?.longitude || defaultCoords.latitude,
|
||||
selected?.address?.latitude || defaultCoords.longitude,
|
||||
]}
|
||||
>
|
||||
<div
|
||||
ref={detailsRef}
|
||||
// className={cn.join("mapDetailsBox", selected ? "show" : "")}
|
||||
// style={{ width: wrappersRef?.current?.offsetWidth - 20 || 200 }}
|
||||
className={cn.join("mapDetailsBox", selected ? "show" : "")}
|
||||
style={{ width: wrappersRef?.current?.offsetWidth - 20 || 200 }}
|
||||
>
|
||||
{/* {selected && <RequestCard request={selected} />} */}
|
||||
{selected && <RequestCard request={selected} />}
|
||||
</div>
|
||||
</Marker>
|
||||
</Marker> */}
|
||||
<ZoomControl />
|
||||
</MapContainer>
|
||||
|
||||
// <MapContainer
|
||||
// style="mapbox://styles/mapbox/streets-v11" // You can choose different styles
|
||||
// center={[54.3683, 32.4279]} // Coordinates for Tehran, Iran
|
||||
// containerStyle={{
|
||||
// height: "400px",
|
||||
// width: "100%",
|
||||
// }}
|
||||
// />
|
||||
)}
|
||||
|
||||
{isError && <p>Map Failed</p>}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,40 +1,41 @@
|
|||
"use client";
|
||||
import React, { useEffect } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import OnMapRequests from "./OnMapRequests";
|
||||
import AllRequests from "./AllRequests";
|
||||
import NearestRequests from "./NearestRequests";
|
||||
import { TabRequests } from "./TabRequests";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getInstances } from "@/utils/CitizenCommon";
|
||||
// import UserContainer from "../User/UserContainer";
|
||||
// import { useRouter } from "next/navigation";
|
||||
// import { useMutation } from "@tanstack/react-query";
|
||||
// import { revoke } from "@/utils/authenticateApi";
|
||||
// import { useMutation } from "@tanstack/react-query";
|
||||
// import { deleteCookie, getCookie } from "cookies-next";
|
||||
|
||||
function RecentRequests() {
|
||||
const [citizenInstance, setCitizenInstance] = useState<any | null>(null);
|
||||
|
||||
// const router = useRouter();
|
||||
const {
|
||||
data: instancesData,
|
||||
isLoading,
|
||||
isError,
|
||||
isSuccess,
|
||||
refetch,
|
||||
} = useQuery({
|
||||
queryKey: ["Instances"],
|
||||
queryFn: () => getInstances(),
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
// const revokeMutation = useMutation({
|
||||
// mutationFn: revoke,
|
||||
// onSuccess: (res) => {},
|
||||
// onError: (err: any | string) => {},
|
||||
// });
|
||||
|
||||
// const logout = () => {
|
||||
// revokeMutation.mutate({
|
||||
// refreshToken: getCookie("Shahrbin_Refresh_Token"),
|
||||
// });
|
||||
// // saveToken(false);
|
||||
// deleteCookie("Shahrbin_Refresh_Token");
|
||||
// deleteCookie("Shahrbin_Token");
|
||||
// router.push("/");
|
||||
// };
|
||||
|
||||
// useEffect(() => {
|
||||
// if (!getCookie("Shahrbin_Token")) {
|
||||
// logout();
|
||||
// }
|
||||
// }, []);
|
||||
|
||||
useEffect(() => {
|
||||
if (instancesData) {
|
||||
console.log(instancesData);
|
||||
console.log(instancesData?.data);
|
||||
console.log(instancesData?.data[0]);
|
||||
localStorage.setItem("SH_CT_INSTANCE",JSON.stringify(instancesData?.data[0]));
|
||||
}
|
||||
}, [isSuccess]);
|
||||
|
||||
return (
|
||||
<section className="w-full flex flex-1 flex-row gap-8 overflow-hidden bg-white p-[10px]">
|
||||
{/* Right */}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,8 @@ import RequestCard from "../Requests/RequestCard";
|
|||
|
||||
const RequestList = () => {
|
||||
return (
|
||||
<section className="flex flex-1 w-full items-center flex-col overflow-y-scroll overflow-x-hidden pl-5 scrollbar-thin scrollbar-thumb-yellow scrollbar-track-white " >
|
||||
<RequestCard />
|
||||
<section className="flex flex-1 w-full items-center flex-col overflow-y-scroll overflow-x-hidden pl-5 scrollbar-thin scrollbar-thumb-yellow scrollbar-track-white ">
|
||||
<RequestCard isSelfRequest={false} />
|
||||
</section>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
"use client";
|
||||
import Image from "next/image";
|
||||
import React from "react";
|
||||
import React, { use, useEffect, useState } from "react";
|
||||
import img1 from "@/assets/images/no-image.jpeg";
|
||||
import RequestStatus from "./RequestStatus";
|
||||
import { MdLocationOn } from "react-icons/md";
|
||||
|
|
@ -8,59 +9,100 @@ import RequestViolation from "./RequestViolation";
|
|||
import RequestLike from "./RequestLike";
|
||||
import RequestComments from "./RequestComments";
|
||||
import Link from "next/link";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getCitizenReport } from "@/utils/CitizenReport";
|
||||
import { convertFullTime } from "@/lib/utils";
|
||||
|
||||
interface RequestCardProps {
|
||||
isSelfRequest?: boolean;
|
||||
}
|
||||
|
||||
const RequestCard: React.FC<RequestCardProps> = ({ isSelfRequest = false }) => {
|
||||
const [reportData, setReportData] = useState<any | null>(null);
|
||||
const [haveImage, sethaveImage] = useState<boolean | null>(null);
|
||||
const { data, isLoading, isError, isSuccess, refetch } = useQuery({
|
||||
queryKey: ["CitizenReport"],
|
||||
queryFn: () =>
|
||||
getCitizenReport({ PageNumber: 1, PageSize: 10, instanceId: 1 }),
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
console.log(data);
|
||||
console.log(data.data);
|
||||
console.log(data.data[0]);
|
||||
setReportData(data.data);
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
const RequestCard = () => {
|
||||
return (
|
||||
<Link
|
||||
href={`MyRequest/${1}`}
|
||||
className="w-full bg-white flex items-stretch mb-3 min-h-[170px] md:p-3 md:rounded-md md:border-0 md:shadow-[0_2px_5px_rgba(0,0,0,0.05)]"
|
||||
style={{ direction: "rtl" }}
|
||||
>
|
||||
<div className="w-full max-w-[100px] flex items-center justify-center">
|
||||
<Image
|
||||
src={img1}
|
||||
alt="11"
|
||||
className="w-full h-full rounded-md object-contain"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
{reportData?.map((item: any) => {
|
||||
return (
|
||||
<Link
|
||||
href={`MyRequest/${1}`}
|
||||
className="w-full bg-white flex items-stretch mb-3 min-h-[170px] md:p-3 md:rounded-md md:border-0 md:shadow-[0_2px_5px_rgba(0,0,0,0.05)]"
|
||||
style={{ direction: "rtl" }}
|
||||
key={item.id}
|
||||
>
|
||||
<div className="w-full max-w-[100px] flex items-center justify-center">
|
||||
<Image
|
||||
src={
|
||||
item && item.medias && item.medias.length > 0
|
||||
? `${process.env.NEXT_PUBLIC_BASE_URL_APP}${item.medias[0].url3}`
|
||||
: img1
|
||||
}
|
||||
alt="picture"
|
||||
quality={100}
|
||||
height={100}
|
||||
width={100}
|
||||
className="w-full h-full rounded-md object-contain"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex-1 pr-2">
|
||||
{/* 1 requestCardInfoRow */}
|
||||
<div className="w-full flex items-center justify-between mb-2">
|
||||
<p className="text-xs font-bold text-ellipsis">عنوان دسته بندی</p>
|
||||
<RequestStatus />
|
||||
</div>
|
||||
<div className="flex-1 pr-2">
|
||||
{/* 1 requestCardInfoRow */}
|
||||
<div className="w-full flex items-center justify-between mb-2">
|
||||
<p className="text-xs font-bold text-ellipsis">
|
||||
{item.categoryTitle}
|
||||
</p>
|
||||
<RequestStatus lastStatus={item.lastStatus} />
|
||||
</div>
|
||||
|
||||
{/* 2 */}
|
||||
<div className="w-full flex items-center justify-between mb-2">
|
||||
<div className="flex items-center text-sm text-gray-500 text-ellipsis">
|
||||
<MdLocationOn className="text-blue ml-1 text-xl" />
|
||||
<p className="line-clamp-1 ">م. آزادی، بل فرخی</p>
|
||||
</div>
|
||||
</div>
|
||||
{/* 2 */}
|
||||
<div className="w-full flex items-center justify-between mb-2">
|
||||
<div className="flex items-center text-sm text-gray-500 text-ellipsis">
|
||||
<MdLocationOn className="text-blue ml-1 text-xl" />
|
||||
<p className="line-clamp-1 ">{item.addressDetail}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 3 */}
|
||||
<div className="w-full flex items-center justify-between mb-2">
|
||||
<div className="text-xs text-gray-500">
|
||||
<span>کد رهگیری: </span>
|
||||
<span>21221212121</span>
|
||||
</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
<span> jul 28 2024 11:20</span>
|
||||
</div>
|
||||
</div>
|
||||
{/* 3 */}
|
||||
<div className="w-full flex items-center justify-between mb-2">
|
||||
<div className="text-xs text-gray-500">
|
||||
<span>کد رهگیری: </span>
|
||||
<span>{item.trackingNumber}</span>
|
||||
</div>
|
||||
<div className="text-xs text-gray-500">
|
||||
<span>{convertFullTime(item.sent)}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 4 */}
|
||||
<div className="w-full flex items-center justify-between mb-2">
|
||||
<RequestProcessIcon />
|
||||
<div className="flex items-center justify-center">
|
||||
<RequestViolation />
|
||||
<RequestLike />
|
||||
<RequestComments />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
{/* 4 */}
|
||||
<div className="w-full flex items-center justify-between mb-2">
|
||||
<RequestProcessIcon />
|
||||
<div className="flex items-center justify-center">
|
||||
<RequestViolation />
|
||||
<RequestLike />
|
||||
<RequestComments />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,14 @@
|
|||
import React from "react";
|
||||
|
||||
const RequestStatus = () => {
|
||||
interface RequestStatusProps {
|
||||
lastStatus?: String;
|
||||
}
|
||||
|
||||
const RequestStatus: React.FC<RequestStatusProps> = ({ lastStatus }) => {
|
||||
return (
|
||||
<>
|
||||
<span className="rounded-3xl bg-white text-ellipsis text-center py-[2px] px-1 text-xs font-bold min-h-6 flex items-center justify-center max-w-[80px] w-full text-black">
|
||||
آخرین وضعیت
|
||||
{lastStatus}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
|
|
|
|||
21
lib/utils.ts
21
lib/utils.ts
|
|
@ -1,6 +1,27 @@
|
|||
import { type ClassValue, clsx } from "clsx"
|
||||
import { twMerge } from "tailwind-merge"
|
||||
import dayjs from "dayjs";
|
||||
import utc from "dayjs/plugin/utc";
|
||||
import jalaliday from "jalaliday";
|
||||
|
||||
dayjs.extend(jalaliday);
|
||||
dayjs.extend(utc);
|
||||
export function cn(...inputs: ClassValue[]) {
|
||||
return twMerge(clsx(inputs))
|
||||
}
|
||||
|
||||
export function convertDate(date: string) {
|
||||
const convertedDate = dayjs(date + "Z")
|
||||
.calendar("jalali")
|
||||
.locale("fa")
|
||||
.format("YYYY/M/DD");
|
||||
return convertedDate;
|
||||
}
|
||||
|
||||
export function convertFullTime(date: string) {
|
||||
const convertedDate = dayjs(date + "Z")
|
||||
.calendar("jalali")
|
||||
.locale("fa")
|
||||
.format(" HH:mm ساعت YYYY/MM/DD");
|
||||
return convertedDate;
|
||||
}
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {};
|
||||
const nextConfig = { images: {
|
||||
domains: ["shahrbinapi.shetabdahi.ir"],
|
||||
},};
|
||||
|
||||
export default nextConfig;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,9 @@
|
|||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "^2.1.0",
|
||||
"cookies-next": "^4.1.1",
|
||||
"dayjs": "^1.11.11",
|
||||
"framer-motion": "^11.1.7",
|
||||
"jalaliday": "^2.3.0",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"lucide-react": "^0.365.0",
|
||||
"next": "14.1.4",
|
||||
|
|
@ -2006,6 +2008,11 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/dayjs": {
|
||||
"version": "1.11.11",
|
||||
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.11.tgz",
|
||||
"integrity": "sha512-okzr3f11N6WuqYtZSvm+F776mB41wRZMhKP+hc34YdW+KmtYYK9iqvHSwo2k9FEH3fhGXvOPV6yz2IcSrfRUDg=="
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
|
|
@ -3774,6 +3781,11 @@
|
|||
"@pkgjs/parseargs": "^0.11.0"
|
||||
}
|
||||
},
|
||||
"node_modules/jalaliday": {
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/jalaliday/-/jalaliday-2.3.0.tgz",
|
||||
"integrity": "sha512-B/m3TqsRrTFED/HBDqON6rPKe0MpoLxNICZ5uZeZ/scHJUHKQNr1n+wdZSj8MxrY1Bmo05gllZeNEw4beXd2oQ=="
|
||||
},
|
||||
"node_modules/jiti": {
|
||||
"version": "1.21.0",
|
||||
"resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.0.tgz",
|
||||
|
|
|
|||
|
|
@ -20,7 +20,9 @@
|
|||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "^2.1.0",
|
||||
"cookies-next": "^4.1.1",
|
||||
"dayjs": "^1.11.11",
|
||||
"framer-motion": "^11.1.7",
|
||||
"jalaliday": "^2.3.0",
|
||||
"jwt-decode": "^4.0.0",
|
||||
"lucide-react": "^0.365.0",
|
||||
"next": "14.1.4",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
import axios from "axios";
|
||||
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
||||
|
||||
// Get Instances
|
||||
export async function getInstances() {
|
||||
const data = await axios.get(`/api/CitizenCommon/ShahrbinInstances`, {
|
||||
|
||||
});
|
||||
console.log(data);
|
||||
|
||||
return data.data;
|
||||
}
|
||||
|
|
@ -1,16 +1,23 @@
|
|||
import axios from "axios";
|
||||
import { CookieValueTypes } from "cookies-next";
|
||||
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 Location
|
||||
export async function getLocations() {
|
||||
const data = await axios.get(`/api/CitizenReport/Locations`, {
|
||||
const data = await axios.get(`/api/CitizenReport/Locations?instanceId=1`, {
|
||||
});
|
||||
return data.data;
|
||||
}
|
||||
|
||||
// ResendOtp
|
||||
export async function resendOtp(payload: { otpToken: string | any}) {
|
||||
const data = await axios.post(
|
||||
`/api/Authenticate/ResendOtp`,
|
||||
|
|
@ -18,3 +25,19 @@ export async function resendOtp(payload: { otpToken: string | any}) {
|
|||
);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,15 @@
|
|||
import axios from "axios";
|
||||
import { getCookie } from "cookies-next";
|
||||
import { toast } from "sonner";
|
||||
|
||||
const api = axios.create({ baseURL: "https://shahrbinapi.shetabdahi.ir/" });
|
||||
|
||||
axios.interceptors.request.use(function (config) {
|
||||
const token = getCookie("Shahrbin_Token");
|
||||
config.headers.Authorization = token ? `Bearer ${token}` : "";
|
||||
return config;
|
||||
});
|
||||
|
||||
api.interceptors.response.use(
|
||||
function (response) {
|
||||
console.log(response);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,11 @@ const instance = { id: 1 };
|
|||
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
||||
let isRefreshing = false;
|
||||
|
||||
axios.interceptors.request.use(function (config) {
|
||||
const token = getCookie("Shahrbin_Token");
|
||||
config.headers.Authorization = token ? `Bearer ${token}` : "";
|
||||
return config;
|
||||
});
|
||||
|
||||
axios.interceptors.response.use(
|
||||
(response) => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue