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/"
|
NEXT_PUBLIC_BASE_URL_APP="https://shahrbinapi.shetabdahi.ir/"
|
||||||
|
|
||||||
REACT_APP_APP_CITY= yazd
|
NEXT_PUBLIC_APP_CITY= yazd
|
||||||
REACT_APP_MUNICIPALITY_LOGO= Yazd-Municipality.png
|
NEXT_PUBLIC_MUNICIPALITY_LOGO= Yazd-Municipality.png
|
||||||
REACT_APP_LOGO= shahrbin_yazd.png
|
NEXT_PUBLIC_LOGO= shahrbin_yazd.png
|
||||||
REACT_APP_LATITUDE= 31.8974
|
NEXT_PUBLIC_LATITUDE= 31.8974
|
||||||
REACT_APP_LONGITUDE= 54.3569
|
NEXT_PUBLIC_LONGITUDE= 54.3569
|
||||||
REACT_APP_PMI_TOKEN=p18879615a54484eb98d403da218956ecaa2740c42
|
NEXT_PUBLIC_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_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
|
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN=pk.eyJ1IjoiZmFicmljOCIsImEiOiJjaWc5aTV1ZzUwMDJwdzJrb2w0dXRmc2d0In0.p6GGlfyV-WksaDV_KdN27A
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import React from "react";
|
||||||
export default function page() {
|
export default function page() {
|
||||||
return (
|
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">
|
<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 /> */}
|
{/* <RequestList /> */}
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"use client";
|
"use client";
|
||||||
import React, { useRef, useState } from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import { getLocations } from "@/utils/CitizenReport";
|
import { getLocations } from "@/utils/CitizenReport";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { ThreeDots } from "react-loader-spinner";
|
import { ThreeDots } from "react-loader-spinner";
|
||||||
|
|
@ -18,17 +18,27 @@ const MapContainer = ReactMapboxGl({
|
||||||
});
|
});
|
||||||
|
|
||||||
const OnMapRequests = () => {
|
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
|
// refs
|
||||||
const detailsRef = useRef(null);
|
const detailsRef = useRef(null);
|
||||||
const wrappersRef = useRef(null);
|
const wrappersRef = useRef(null);
|
||||||
|
|
||||||
const defaultCoords = {
|
|
||||||
// latitude: instances[0].latitude,
|
|
||||||
// longitude: instances[0].longitude,
|
|
||||||
};
|
|
||||||
|
|
||||||
// hooks
|
// hooks
|
||||||
// const [detailsClicked, setDetailsClicked] = useClick({
|
// const [detailsClicked, setDetailsClicked] = useClick({
|
||||||
// element: detailsRef,
|
// element: detailsRef,
|
||||||
|
|
@ -59,23 +69,28 @@ const OnMapRequests = () => {
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["Locations"],
|
queryKey: ["Locations"],
|
||||||
queryFn: () => getLocations(),
|
queryFn: () => getLocations(),
|
||||||
// refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isSuccess) {
|
useEffect(() => {
|
||||||
console.log(LocationData?.locations[0].locations);
|
if (LocationData) {
|
||||||
const fetchedContent = LocationData?.locations[0].locations;
|
console.log("🚀 ~ OnMapRequests ~ LocationData:", LocationData);
|
||||||
console.log(fetchedContent);
|
console.log(
|
||||||
}
|
"🚀 ~ OnMapRequestssss ~ LocationDataa:",
|
||||||
|
LocationData?.data?.locations[0]?.locations
|
||||||
|
);
|
||||||
|
setLocations(LocationData?.data?.locations[0]?.locations);
|
||||||
|
}
|
||||||
|
}, [isSuccess]);
|
||||||
|
|
||||||
if (isError) {
|
if (isError) {
|
||||||
console.log("have a errorrrrrrr ");
|
console.log("have a errorrrrrrr ");
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="w-full h-full">
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="flex justify-center text-center w-36">
|
<div className="flex justify-center items-center text-center w-full h-full ">
|
||||||
<ThreeDots
|
<ThreeDots
|
||||||
visible={true}
|
visible={true}
|
||||||
height="50"
|
height="50"
|
||||||
|
|
@ -93,51 +108,45 @@ const OnMapRequests = () => {
|
||||||
// store.instance?.longitude || defaultCoords.longitude,
|
// store.instance?.longitude || defaultCoords.longitude,
|
||||||
// store.instance?.latitude || defaultCoords.latitude,
|
// store.instance?.latitude || defaultCoords.latitude,
|
||||||
// ]}
|
// ]}
|
||||||
center={[54.3683, 32.4279]}
|
zoom={[10]}
|
||||||
|
center={[31.887935423191124, 54.355335268625275]}
|
||||||
containerStyle={{ height: "100%", width: "100%", borderRadius: 20 }}
|
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}
|
// onClick={onMapClicked}
|
||||||
>
|
>
|
||||||
{/* {LocationData?.map((d) => (
|
{locations?.map((d: any) => (
|
||||||
<Marker coordinates={[d.longitude, d.latitude]}>
|
<Marker
|
||||||
<img src={marker} onClick={() => showDetails(d)} />
|
key={d.reportId}
|
||||||
</Marker>
|
coordinates={[d.longitude, d.latitude]}
|
||||||
))} */}
|
// coordinates={[ 31.887935423191124, 54.355335268625275,]}
|
||||||
{LocationData?.map(() => (
|
>
|
||||||
<Marker>
|
<img src={marker} />
|
||||||
<img src={marker} onClick={() => showDetails()} />
|
{/* <img src={marker} onClick={() => showDetails(d)} /> */}
|
||||||
</Marker>
|
</Marker>
|
||||||
))}
|
))}
|
||||||
|
|
||||||
<Marker
|
{/* Open CardData */}
|
||||||
// coordinates={[
|
{/* <Marker
|
||||||
// selected?.address?.longitude || defaultCoords.latitude,
|
coordinates={[
|
||||||
// selected?.address?.latitude || defaultCoords.longitude,
|
31.887935423191124, 54.355335268625275,
|
||||||
// ]}
|
selected?.address?.longitude || defaultCoords.latitude,
|
||||||
|
selected?.address?.latitude || defaultCoords.longitude,
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
ref={detailsRef}
|
ref={detailsRef}
|
||||||
// className={cn.join("mapDetailsBox", selected ? "show" : "")}
|
className={cn.join("mapDetailsBox", selected ? "show" : "")}
|
||||||
// style={{ width: wrappersRef?.current?.offsetWidth - 20 || 200 }}
|
style={{ width: wrappersRef?.current?.offsetWidth - 20 || 200 }}
|
||||||
>
|
>
|
||||||
{/* {selected && <RequestCard request={selected} />} */}
|
{selected && <RequestCard request={selected} />}
|
||||||
</div>
|
</div>
|
||||||
</Marker>
|
</Marker> */}
|
||||||
<ZoomControl />
|
<ZoomControl />
|
||||||
</MapContainer>
|
</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>}
|
{isError && <p>Map Failed</p>}
|
||||||
</>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,39 +1,40 @@
|
||||||
"use client";
|
"use client";
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import OnMapRequests from "./OnMapRequests";
|
import OnMapRequests from "./OnMapRequests";
|
||||||
import AllRequests from "./AllRequests";
|
import AllRequests from "./AllRequests";
|
||||||
import NearestRequests from "./NearestRequests";
|
import NearestRequests from "./NearestRequests";
|
||||||
import { TabRequests } from "./TabRequests";
|
import { TabRequests } from "./TabRequests";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { getInstances } from "@/utils/CitizenCommon";
|
||||||
// import UserContainer from "../User/UserContainer";
|
// import UserContainer from "../User/UserContainer";
|
||||||
// import { useRouter } from "next/navigation";
|
// import { useRouter } from "next/navigation";
|
||||||
// import { useMutation } from "@tanstack/react-query";
|
// import { useMutation } from "@tanstack/react-query";
|
||||||
// import { revoke } from "@/utils/authenticateApi";
|
|
||||||
// import { deleteCookie, getCookie } from "cookies-next";
|
// import { deleteCookie, getCookie } from "cookies-next";
|
||||||
|
|
||||||
function RecentRequests() {
|
function RecentRequests() {
|
||||||
|
const [citizenInstance, setCitizenInstance] = useState<any | null>(null);
|
||||||
|
|
||||||
// const router = useRouter();
|
// const router = useRouter();
|
||||||
|
const {
|
||||||
|
data: instancesData,
|
||||||
|
isLoading,
|
||||||
|
isError,
|
||||||
|
isSuccess,
|
||||||
|
refetch,
|
||||||
|
} = useQuery({
|
||||||
|
queryKey: ["Instances"],
|
||||||
|
queryFn: () => getInstances(),
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
});
|
||||||
|
|
||||||
// const revokeMutation = useMutation({
|
useEffect(() => {
|
||||||
// mutationFn: revoke,
|
if (instancesData) {
|
||||||
// onSuccess: (res) => {},
|
console.log(instancesData);
|
||||||
// onError: (err: any | string) => {},
|
console.log(instancesData?.data);
|
||||||
// });
|
console.log(instancesData?.data[0]);
|
||||||
|
localStorage.setItem("SH_CT_INSTANCE",JSON.stringify(instancesData?.data[0]));
|
||||||
// const logout = () => {
|
}
|
||||||
// revokeMutation.mutate({
|
}, [isSuccess]);
|
||||||
// refreshToken: getCookie("Shahrbin_Refresh_Token"),
|
|
||||||
// });
|
|
||||||
// // saveToken(false);
|
|
||||||
// deleteCookie("Shahrbin_Refresh_Token");
|
|
||||||
// deleteCookie("Shahrbin_Token");
|
|
||||||
// router.push("/");
|
|
||||||
// };
|
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (!getCookie("Shahrbin_Token")) {
|
|
||||||
// logout();
|
|
||||||
// }
|
|
||||||
// }, []);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="w-full flex flex-1 flex-row gap-8 overflow-hidden bg-white p-[10px]">
|
<section className="w-full flex flex-1 flex-row gap-8 overflow-hidden bg-white p-[10px]">
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ import RequestCard from "../Requests/RequestCard";
|
||||||
|
|
||||||
const RequestList = () => {
|
const RequestList = () => {
|
||||||
return (
|
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 " >
|
<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 />
|
<RequestCard isSelfRequest={false} />
|
||||||
</section>
|
</section>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
|
"use client";
|
||||||
import Image from "next/image";
|
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 img1 from "@/assets/images/no-image.jpeg";
|
||||||
import RequestStatus from "./RequestStatus";
|
import RequestStatus from "./RequestStatus";
|
||||||
import { MdLocationOn } from "react-icons/md";
|
import { MdLocationOn } from "react-icons/md";
|
||||||
|
|
@ -8,59 +9,100 @@ import RequestViolation from "./RequestViolation";
|
||||||
import RequestLike from "./RequestLike";
|
import RequestLike from "./RequestLike";
|
||||||
import RequestComments from "./RequestComments";
|
import RequestComments from "./RequestComments";
|
||||||
import Link from "next/link";
|
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 (
|
return (
|
||||||
<Link
|
<div>
|
||||||
href={`MyRequest/${1}`}
|
{reportData?.map((item: any) => {
|
||||||
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)]"
|
return (
|
||||||
style={{ direction: "rtl" }}
|
<Link
|
||||||
>
|
href={`MyRequest/${1}`}
|
||||||
<div className="w-full max-w-[100px] flex items-center justify-center">
|
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)]"
|
||||||
<Image
|
style={{ direction: "rtl" }}
|
||||||
src={img1}
|
key={item.id}
|
||||||
alt="11"
|
>
|
||||||
className="w-full h-full rounded-md object-contain"
|
<div className="w-full max-w-[100px] flex items-center justify-center">
|
||||||
/>
|
<Image
|
||||||
</div>
|
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">
|
<div className="flex-1 pr-2">
|
||||||
{/* 1 requestCardInfoRow */}
|
{/* 1 requestCardInfoRow */}
|
||||||
<div className="w-full flex items-center justify-between mb-2">
|
<div className="w-full flex items-center justify-between mb-2">
|
||||||
<p className="text-xs font-bold text-ellipsis">عنوان دسته بندی</p>
|
<p className="text-xs font-bold text-ellipsis">
|
||||||
<RequestStatus />
|
{item.categoryTitle}
|
||||||
</div>
|
</p>
|
||||||
|
<RequestStatus lastStatus={item.lastStatus} />
|
||||||
|
</div>
|
||||||
|
|
||||||
{/* 2 */}
|
{/* 2 */}
|
||||||
<div className="w-full flex items-center justify-between mb-2">
|
<div className="w-full flex items-center justify-between mb-2">
|
||||||
<div className="flex items-center text-sm text-gray-500 text-ellipsis">
|
<div className="flex items-center text-sm text-gray-500 text-ellipsis">
|
||||||
<MdLocationOn className="text-blue ml-1 text-xl" />
|
<MdLocationOn className="text-blue ml-1 text-xl" />
|
||||||
<p className="line-clamp-1 ">م. آزادی، بل فرخی</p>
|
<p className="line-clamp-1 ">{item.addressDetail}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 3 */}
|
{/* 3 */}
|
||||||
<div className="w-full flex items-center justify-between mb-2">
|
<div className="w-full flex items-center justify-between mb-2">
|
||||||
<div className="text-xs text-gray-500">
|
<div className="text-xs text-gray-500">
|
||||||
<span>کد رهگیری: </span>
|
<span>کد رهگیری: </span>
|
||||||
<span>21221212121</span>
|
<span>{item.trackingNumber}</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="text-xs text-gray-500">
|
<div className="text-xs text-gray-500">
|
||||||
<span> jul 28 2024 11:20</span>
|
<span>{convertFullTime(item.sent)}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* 4 */}
|
{/* 4 */}
|
||||||
<div className="w-full flex items-center justify-between mb-2">
|
<div className="w-full flex items-center justify-between mb-2">
|
||||||
<RequestProcessIcon />
|
<RequestProcessIcon />
|
||||||
<div className="flex items-center justify-center">
|
<div className="flex items-center justify-center">
|
||||||
<RequestViolation />
|
<RequestViolation />
|
||||||
<RequestLike />
|
<RequestLike />
|
||||||
<RequestComments />
|
<RequestComments />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
const RequestStatus = () => {
|
interface RequestStatusProps {
|
||||||
|
lastStatus?: String;
|
||||||
|
}
|
||||||
|
|
||||||
|
const RequestStatus: React.FC<RequestStatusProps> = ({ lastStatus }) => {
|
||||||
return (
|
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">
|
<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>
|
</span>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
21
lib/utils.ts
21
lib/utils.ts
|
|
@ -1,6 +1,27 @@
|
||||||
import { type ClassValue, clsx } from "clsx"
|
import { type ClassValue, clsx } from "clsx"
|
||||||
import { twMerge } from "tailwind-merge"
|
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[]) {
|
export function cn(...inputs: ClassValue[]) {
|
||||||
return twMerge(clsx(inputs))
|
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} */
|
/** @type {import('next').NextConfig} */
|
||||||
const nextConfig = {};
|
const nextConfig = { images: {
|
||||||
|
domains: ["shahrbinapi.shetabdahi.ir"],
|
||||||
|
},};
|
||||||
|
|
||||||
export default nextConfig;
|
export default nextConfig;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,9 @@
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.1.0",
|
"clsx": "^2.1.0",
|
||||||
"cookies-next": "^4.1.1",
|
"cookies-next": "^4.1.1",
|
||||||
|
"dayjs": "^1.11.11",
|
||||||
"framer-motion": "^11.1.7",
|
"framer-motion": "^11.1.7",
|
||||||
|
"jalaliday": "^2.3.0",
|
||||||
"jwt-decode": "^4.0.0",
|
"jwt-decode": "^4.0.0",
|
||||||
"lucide-react": "^0.365.0",
|
"lucide-react": "^0.365.0",
|
||||||
"next": "14.1.4",
|
"next": "14.1.4",
|
||||||
|
|
@ -2006,6 +2008,11 @@
|
||||||
"url": "https://github.com/sponsors/ljharb"
|
"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": {
|
"node_modules/debug": {
|
||||||
"version": "4.3.4",
|
"version": "4.3.4",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||||
|
|
@ -3774,6 +3781,11 @@
|
||||||
"@pkgjs/parseargs": "^0.11.0"
|
"@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": {
|
"node_modules/jiti": {
|
||||||
"version": "1.21.0",
|
"version": "1.21.0",
|
||||||
"resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.0.tgz",
|
"resolved": "https://registry.npmjs.org/jiti/-/jiti-1.21.0.tgz",
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,9 @@
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.1.0",
|
"clsx": "^2.1.0",
|
||||||
"cookies-next": "^4.1.1",
|
"cookies-next": "^4.1.1",
|
||||||
|
"dayjs": "^1.11.11",
|
||||||
"framer-motion": "^11.1.7",
|
"framer-motion": "^11.1.7",
|
||||||
|
"jalaliday": "^2.3.0",
|
||||||
"jwt-decode": "^4.0.0",
|
"jwt-decode": "^4.0.0",
|
||||||
"lucide-react": "^0.365.0",
|
"lucide-react": "^0.365.0",
|
||||||
"next": "14.1.4",
|
"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 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 = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
||||||
// axios.defaults.baseURL = "https://shahrbinapi.shetabdahi.ir/";
|
// 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
|
// Get Location
|
||||||
export async function getLocations() {
|
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;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ResendOtp
|
||||||
export async function resendOtp(payload: { otpToken: string | any}) {
|
export async function resendOtp(payload: { otpToken: string | any}) {
|
||||||
const data = await axios.post(
|
const data = await axios.post(
|
||||||
`/api/Authenticate/ResendOtp`,
|
`/api/Authenticate/ResendOtp`,
|
||||||
|
|
@ -18,3 +25,19 @@ export async function resendOtp(payload: { otpToken: string | any}) {
|
||||||
);
|
);
|
||||||
return data.data;
|
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 axios from "axios";
|
||||||
|
import { getCookie } from "cookies-next";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
|
||||||
const api = axios.create({ baseURL: "https://shahrbinapi.shetabdahi.ir/" });
|
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(
|
api.interceptors.response.use(
|
||||||
function (response) {
|
function (response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,11 @@ const instance = { id: 1 };
|
||||||
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
||||||
let isRefreshing = false;
|
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(
|
axios.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue