Compare commits
6 Commits
6baeccf126
...
24350884fd
| Author | SHA1 | Date |
|---|---|---|
|
|
24350884fd | |
|
|
82ebc3c611 | |
|
|
7606d2cb34 | |
|
|
fd42d2ad7f | |
|
|
a0ea1e0b95 | |
|
|
eae43317b8 |
|
|
@ -328,7 +328,7 @@ export default function AdminCategories() {
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
<p className="text-[#464646] text-base font-bold">
|
<p className="text-[#464646] text-base font-bold">
|
||||||
تغییر دسته بندی
|
ویرایش دسته بندی
|
||||||
</p>
|
</p>
|
||||||
<AlertDialogCancel className="h-auto p-0 border-0">
|
<AlertDialogCancel className="h-auto p-0 border-0">
|
||||||
<IoMdClose />
|
<IoMdClose />
|
||||||
|
|
@ -384,7 +384,7 @@ export default function AdminCategories() {
|
||||||
type="submit"
|
type="submit"
|
||||||
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
||||||
>
|
>
|
||||||
تغییر دسته بندی
|
ویرایش دسته بندی
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl">
|
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl">
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,7 @@ export default function AdminKeysManagement() {
|
||||||
type="submit"
|
type="submit"
|
||||||
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
||||||
>
|
>
|
||||||
تغییر کلید
|
ویرایش کلید
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
{/* <AlertDialogAction
|
{/* <AlertDialogAction
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ import { FaRegEdit } from "react-icons/fa";
|
||||||
import { IoMdClose } from "react-icons/io";
|
import { IoMdClose } from "react-icons/io";
|
||||||
import { RiDeleteBin6Line } from "react-icons/ri";
|
import { RiDeleteBin6Line } from "react-icons/ri";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { ThreeDots } from "react-loader-spinner";
|
import { ThreeDots, Triangle } from "react-loader-spinner";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
|
||||||
|
|
@ -51,6 +51,7 @@ import * as z from "zod";
|
||||||
import { Textarea } from "./ui/textarea";
|
import { Textarea } from "./ui/textarea";
|
||||||
import { Switch } from "@/components/ui/switch";
|
import { Switch } from "@/components/ui/switch";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
import Pagination from "./Pagination";
|
||||||
|
|
||||||
const MAX_IMAGE_SIZE = 5242880; // 5 MB
|
const MAX_IMAGE_SIZE = 5242880; // 5 MB
|
||||||
const ALLOWED_IMAGE_TYPES = [
|
const ALLOWED_IMAGE_TYPES = [
|
||||||
|
|
@ -123,7 +124,8 @@ export default function AdminNews() {
|
||||||
const [urlNews, setUrlNews] = useState("");
|
const [urlNews, setUrlNews] = useState("");
|
||||||
const [contentNews, setContentNews] = useState("");
|
const [contentNews, setContentNews] = useState("");
|
||||||
const [imageNews, setImageNews] = useState("");
|
const [imageNews, setImageNews] = useState("");
|
||||||
|
const [page, setPage] = useState<any>(1);
|
||||||
|
const [totalCount, setTotalCount] = useState<any>(0);
|
||||||
const [keyIdDel, setKeyIdDel] = useState("");
|
const [keyIdDel, setKeyIdDel] = useState("");
|
||||||
|
|
||||||
const [openAdd, setOpenAdd] = React.useState(false);
|
const [openAdd, setOpenAdd] = React.useState(false);
|
||||||
|
|
@ -138,8 +140,11 @@ export default function AdminNews() {
|
||||||
isLoading: isListLoading,
|
isLoading: isListLoading,
|
||||||
refetch: refetch1,
|
refetch: refetch1,
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["NewsList"],
|
queryKey: ["NewsList", page],
|
||||||
queryFn: () => GetAllNews(),
|
queryFn: () =>
|
||||||
|
GetAllNews({
|
||||||
|
PageNumber: page,
|
||||||
|
}),
|
||||||
// queryFn: () => GetAllOrganizations(),
|
// queryFn: () => GetAllOrganizations(),
|
||||||
// refetchOnWindowFocus: false,
|
// refetchOnWindowFocus: false,
|
||||||
});
|
});
|
||||||
|
|
@ -253,8 +258,6 @@ export default function AdminNews() {
|
||||||
mutationKey: ["AddNews"],
|
mutationKey: ["AddNews"],
|
||||||
mutationFn: SubmitNews,
|
mutationFn: SubmitNews,
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
console.log(res);
|
|
||||||
console.log("Success Change News");
|
|
||||||
setOpenAdd(false);
|
setOpenAdd(false);
|
||||||
|
|
||||||
refetch1();
|
refetch1();
|
||||||
|
|
@ -314,8 +317,16 @@ export default function AdminNews() {
|
||||||
console.log(data);
|
console.log(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data1) {
|
||||||
|
const headersData = JSON.parse(data1.headers["x-pagination"]);
|
||||||
|
setTotalCount(headersData.TotalCount);
|
||||||
|
setPage(headersData.CurrentPage);
|
||||||
|
}
|
||||||
|
}, [data1]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-[85vh] flex justify-center">
|
<div className="w-full min-h-[85vh] flex justify-center py-4">
|
||||||
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
|
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
|
||||||
<div className="flex flex-row justify-between w-full ">
|
<div className="flex flex-row justify-between w-full ">
|
||||||
{/* 1 */}
|
{/* 1 */}
|
||||||
|
|
@ -516,7 +527,7 @@ export default function AdminNews() {
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
<p className="text-[#464646] text-base font-bold">
|
<p className="text-[#464646] text-base font-bold">
|
||||||
تغییر خبر
|
ویرایش خبر
|
||||||
</p>
|
</p>
|
||||||
<AlertDialogCancel className="h-auto p-0 border-0">
|
<AlertDialogCancel className="h-auto p-0 border-0">
|
||||||
<IoMdClose />
|
<IoMdClose />
|
||||||
|
|
@ -667,7 +678,7 @@ export default function AdminNews() {
|
||||||
type="submit"
|
type="submit"
|
||||||
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
||||||
>
|
>
|
||||||
تغییر خبر
|
ویرایش خبر
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl">
|
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl">
|
||||||
|
|
@ -681,20 +692,33 @@ export default function AdminNews() {
|
||||||
<AlertDialogFooter></AlertDialogFooter>
|
<AlertDialogFooter></AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
|
|
||||||
{data1?.map((item: any) => {
|
{data1?.data?.map((item: any) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-56 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
|
className={`w-full lg:w-[48%] bg-[#F5F5F5] border rounded-lg flex flex-row shadow-md transition-all
|
||||||
|
h-[20em] sm:h-[15em] max-sm:flex-col max-sm:gap-[3px]
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
|
<div className="w-1/2 h-full rounded-r-lg max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
|
||||||
|
<Image
|
||||||
|
alt="picture"
|
||||||
|
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${item?.image?.url}`}
|
||||||
|
height={500}
|
||||||
|
width={500}
|
||||||
|
quality={100}
|
||||||
|
className="w-full h-full rounded-r-lg bg-cover object-cover"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="w-1/2 h-full flex flex-col p-3 justify-between max-md:justify-evenly max-md:w-2/3 max-sm:h-1/2 max-sm:w-full">
|
||||||
|
<div>
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
عنوان :
|
عنوان :
|
||||||
<span className=" text-slate-800">{item.title}</span>
|
<span className=" text-slate-800">{item.title}</span>
|
||||||
</p>
|
</p>
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
توضیحات:
|
توضیحات:
|
||||||
<span className="self-end text-slate-800">
|
<span className="self-end text-slate-800 line-clamp-2">
|
||||||
{item.description}
|
{item.description}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -704,15 +728,7 @@ export default function AdminNews() {
|
||||||
{item.content}
|
{item.content}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<Image
|
</div>
|
||||||
alt="img"
|
|
||||||
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${item?.image?.url}`}
|
|
||||||
width={100}
|
|
||||||
height={100}
|
|
||||||
quality={100}
|
|
||||||
className="object-contain object-right w-full h-20 "
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="flex items-end justify-end w-full gap-2">
|
<div className="flex items-end justify-end w-full gap-2">
|
||||||
<Switch
|
<Switch
|
||||||
dir="ltr"
|
dir="ltr"
|
||||||
|
|
@ -743,9 +759,18 @@ export default function AdminNews() {
|
||||||
</AlertDialogTrigger>
|
</AlertDialogTrigger>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
|
{!isListLoading && (
|
||||||
|
<Pagination
|
||||||
|
currentPage={page - 1}
|
||||||
|
PageSize={5}
|
||||||
|
countPage={totalCount}
|
||||||
|
Page={(num: number) => setPage(num + 1)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -456,7 +456,6 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end">
|
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end">
|
||||||
|
|
@ -487,7 +486,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
<p className="text-[#464646] text-base font-bold">
|
<p className="text-[#464646] text-base font-bold">
|
||||||
تغییر اسلایدر
|
ویرایش اسلایدر
|
||||||
</p>
|
</p>
|
||||||
<AlertDialogCancel className="h-auto p-0 border-0">
|
<AlertDialogCancel className="h-auto p-0 border-0">
|
||||||
<IoMdClose />
|
<IoMdClose />
|
||||||
|
|
@ -614,7 +613,6 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end">
|
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end">
|
||||||
|
|
@ -622,7 +620,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
||||||
type="submit"
|
type="submit"
|
||||||
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
||||||
>
|
>
|
||||||
تغییر اسلایدر
|
ویرایش اسلایدر
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl">
|
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl">
|
||||||
|
|
@ -644,8 +642,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
عنوان :
|
عنوان :<span className=" text-slate-800">{item.title}</span>
|
||||||
<span className=" text-slate-800">{item.title}</span>
|
|
||||||
</p>
|
</p>
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
توضیحات:
|
توضیحات:
|
||||||
|
|
@ -675,8 +672,8 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
||||||
checked={!item.isDeleted}
|
checked={!item.isDeleted}
|
||||||
onCheckedChange={() => {
|
onCheckedChange={() => {
|
||||||
DeleteSliderMutation.mutate({
|
DeleteSliderMutation.mutate({
|
||||||
id: item.id
|
id: item.id,
|
||||||
})
|
});
|
||||||
}}
|
}}
|
||||||
id={item.id}
|
id={item.id}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -315,6 +315,12 @@ export default function ComplainsDetails({
|
||||||
{data.complaining ? data.complaining : "-"}
|
{data.complaining ? data.complaining : "-"}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
<p className="text-[#464646] text-sm font-medium">
|
||||||
|
کد پیگیری:{" "}
|
||||||
|
<span className="text-[#7C838A] text-sm font-medium">
|
||||||
|
{data.trackingNumber ? data.trackingNumber : "-"}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
<p className="text-[#464646] text-sm font-medium">
|
<p className="text-[#464646] text-sm font-medium">
|
||||||
زمان ثبت:{" "}
|
زمان ثبت:{" "}
|
||||||
<span className="text-[#7C838A] text-sm font-medium">
|
<span className="text-[#7C838A] text-sm font-medium">
|
||||||
|
|
@ -325,7 +331,7 @@ export default function ComplainsDetails({
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="relative flex flex-col p-5 mt-2 border border-gray-400 rounded-md gap-y-1 md:w-1/2">
|
<div className="relative flex flex-col p-5 mt-2 border border-gray-400 rounded-md gap-y-1 md:w-1/2 w-full h-full">
|
||||||
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
|
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
|
||||||
اطلاعات کلی
|
اطلاعات کلی
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -349,6 +355,12 @@ export default function ComplainsDetails({
|
||||||
{data.complaining ? data.complaining : "-"}
|
{data.complaining ? data.complaining : "-"}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
<p className="text-[#464646] text-sm font-medium">
|
||||||
|
کد پیگیری:{" "}
|
||||||
|
<span className="text-[#7C838A] text-sm font-medium">
|
||||||
|
{data.trackingNumber ? data.trackingNumber : "-"}
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
<p className="text-[#464646] text-sm font-medium">
|
<p className="text-[#464646] text-sm font-medium">
|
||||||
زمان ثبت:{" "}
|
زمان ثبت:{" "}
|
||||||
<span className="text-[#7C838A] text-sm font-medium">
|
<span className="text-[#7C838A] text-sm font-medium">
|
||||||
|
|
@ -356,7 +368,7 @@ export default function ComplainsDetails({
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="relative flex flex-col p-5 mt-2 border border-gray-400 rounded-md gap-y-1 md:w-1/2">
|
<div className="relative flex flex-col items-start p-5 mt-2 border border-gray-400 rounded-md gap-y-1 md:w-1/2 w-full h-full">
|
||||||
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
|
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
|
||||||
اطلاعات شاکی
|
اطلاعات شاکی
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -386,14 +398,22 @@ export default function ComplainsDetails({
|
||||||
: "-"}
|
: "-"}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
|
<p className="text-[#464646] text-sm font-medium">
|
||||||
|
{/* کد پیگیری:{" "}
|
||||||
|
<span className="text-[#7C838A] text-sm font-medium">
|
||||||
|
{data.trackingNumber ? data.trackingNumber : "-"}
|
||||||
|
</span> */}
|
||||||
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col ">
|
<div className="bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col ">
|
||||||
<p className="text-[#464646] text-base font-bold">روند شکایت</p>
|
<p className="text-[#464646] text-base font-bold">روند شکایت</p>
|
||||||
<div className="flex flex-col mt-4 gap-y-4 max-h-[50vh] lg:max-h-[39.5vh] 2xl:max-h-[43.5vh] 3xl:max-h-[41vh] min-[1920px]:max-h-[48.5vh] overflow-auto
|
<div
|
||||||
scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-500 scrollbar-track-gray-100">
|
className="flex flex-col mt-4 gap-y-4 max-h-[50vh] lg:max-h-[39.5vh] 2xl:max-h-[43.5vh] 3xl:max-h-[41vh] min-[1920px]:max-h-[48.5vh] overflow-auto
|
||||||
|
scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-500 scrollbar-track-gray-100"
|
||||||
|
>
|
||||||
{data.contents?.map((item: any) => {
|
{data.contents?.map((item: any) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
|
@ -474,14 +494,12 @@ export default function ComplainsDetails({
|
||||||
key2={key}
|
key2={key}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
{getComplaintMutation.isPending && (
|
{getComplaintMutation.isPending && (
|
||||||
<div className="flex justify-center w-full h-full mt-20">
|
<div className="flex justify-center w-full h-full mt-20">
|
||||||
|
|
||||||
<Triangle
|
<Triangle
|
||||||
visible={true}
|
visible={true}
|
||||||
height="100"
|
height="100"
|
||||||
|
|
|
||||||
|
|
@ -5,16 +5,16 @@ import { AdminMenuItems, ControllerMenuItems } from "@/constants";
|
||||||
import { usePathname, useRouter } from "next/navigation";
|
import { usePathname, useRouter } from "next/navigation";
|
||||||
import { Squash as Hamburger } from "hamburger-react";
|
import { Squash as Hamburger } from "hamburger-react";
|
||||||
import { AnimatePresence, motion } from "framer-motion";
|
import { AnimatePresence, motion } from "framer-motion";
|
||||||
import { getProfile } from "@/utils/authenticateApi";
|
import { getProfile, revoke } from "@/utils/authenticateApi";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||||
import { DoorOpen, LogOut } from "lucide-react";
|
import { DoorOpen, LogOut } from "lucide-react";
|
||||||
import { deleteCookie } from "cookies-next";
|
import { deleteCookie, getCookie } from "cookies-next";
|
||||||
export default function NavbarPanel() {
|
export default function NavbarPanel() {
|
||||||
const [isOpen, setOpen] = useState(false);
|
const [isOpen, setOpen] = useState(false);
|
||||||
const ref = useRef(null);
|
const ref = useRef(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const [activeLink, setActiveLink] = useState('');
|
const [activeLink, setActiveLink] = useState("");
|
||||||
const [role, setRole] = useState<string | null>("");
|
const [role, setRole] = useState<string | null>("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -27,11 +27,15 @@ export default function NavbarPanel() {
|
||||||
setActiveLink(pathname);
|
setActiveLink(pathname);
|
||||||
}, [pathname]);
|
}, [pathname]);
|
||||||
|
|
||||||
|
|
||||||
const { data, isLoading, refetch } = useQuery({
|
const { data, isLoading, refetch } = useQuery({
|
||||||
queryKey: ["Profile"],
|
queryKey: ["Profile"],
|
||||||
queryFn: () => getProfile(),
|
queryFn: () => getProfile(),
|
||||||
refetchOnWindowFocus: false,
|
});
|
||||||
|
|
||||||
|
const revokeMutation = useMutation({
|
||||||
|
mutationFn: revoke,
|
||||||
|
onSuccess: (res) => {},
|
||||||
|
onError: (err: any | string) => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
const menus = {
|
const menus = {
|
||||||
|
|
@ -40,10 +44,18 @@ export default function NavbarPanel() {
|
||||||
};
|
};
|
||||||
const selectedMenu = menus[role as keyof typeof menus];
|
const selectedMenu = menus[role as keyof typeof menus];
|
||||||
|
|
||||||
|
const logout = () => {
|
||||||
|
revokeMutation.mutate({
|
||||||
|
refreshToken: getCookie("Sootzani_Refresh_Token"),
|
||||||
|
});
|
||||||
|
deleteCookie("Sootzani_Token");
|
||||||
|
localStorage.removeItem("privateKey");
|
||||||
|
localStorage.removeItem("privatePassword");
|
||||||
|
router.push("/");
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div className="fixed top-0 z-10 flex flex-row items-center justify-between w-full gap-3 px-8 py-4 shadow-md sm:items-center sm:gap-0 bg-blue max-md:px-4 ">
|
||||||
className="fixed top-0 z-10 flex flex-row items-center justify-between w-full gap-3 px-8 py-4 shadow-md sm:items-center sm:gap-0 bg-blue max-md:px-4 "
|
|
||||||
>
|
|
||||||
<div className="flex items-center gap-8 max-md:gap-4">
|
<div className="flex items-center gap-8 max-md:gap-4">
|
||||||
<div className=" md:hidden">
|
<div className=" md:hidden">
|
||||||
<Hamburger
|
<Hamburger
|
||||||
|
|
@ -112,7 +124,7 @@ export default function NavbarPanel() {
|
||||||
<p
|
<p
|
||||||
className={`text-white font-normal text-sm max-md:text-xs
|
className={`text-white font-normal text-sm max-md:text-xs
|
||||||
hover:bg-white/50 rounded-sm p-1
|
hover:bg-white/50 rounded-sm p-1
|
||||||
animate-out duration-300 ${isActive ? 'bg-white/50 ' : '' }`}
|
animate-out duration-300 ${isActive ? "bg-white/50 " : ""}`}
|
||||||
>
|
>
|
||||||
{item.name}
|
{item.name}
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -135,15 +147,7 @@ export default function NavbarPanel() {
|
||||||
)}
|
)}
|
||||||
</h1>
|
</h1>
|
||||||
<div className="p-1 rounded-md hover:bg-white/50">
|
<div className="p-1 rounded-md hover:bg-white/50">
|
||||||
<LogOut
|
<LogOut onClick={logout} className="text-white cursor-pointer " />
|
||||||
onClick={() => {
|
|
||||||
deleteCookie("Sootzani_Token");
|
|
||||||
localStorage.removeItem("privateKey");
|
|
||||||
localStorage.removeItem("privatePassword");
|
|
||||||
router.push("/");
|
|
||||||
}}
|
|
||||||
className="text-white cursor-pointer "
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
"use client";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import ReactPaginate from "react-paginate";
|
||||||
|
import { MdKeyboardArrowRight, MdKeyboardArrowLeft } from "react-icons/md";
|
||||||
|
import { twMerge } from "tailwind-merge";
|
||||||
|
// Example items, to simulate fetching from another resources.
|
||||||
|
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
|
||||||
|
|
||||||
|
export default function Pagination({
|
||||||
|
currentPage,
|
||||||
|
PageSize,
|
||||||
|
Page,
|
||||||
|
countPage,
|
||||||
|
length,
|
||||||
|
}: {
|
||||||
|
currentPage?: any;
|
||||||
|
PageSize?: number;
|
||||||
|
Page?: any;
|
||||||
|
countPage?: any;
|
||||||
|
length?: any;
|
||||||
|
}) {
|
||||||
|
const handlePageClick = (event: any) => {
|
||||||
|
console.log(event.selected);
|
||||||
|
Page(event.selected);
|
||||||
|
};
|
||||||
|
console.log(countPage);
|
||||||
|
// console.log(pageCount, "1111");
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ReactPaginate
|
||||||
|
breakLabel="..."
|
||||||
|
onPageActive={(e) => console.log(e)}
|
||||||
|
nextLabel={<MdKeyboardArrowLeft className="w-5 h-5 " />}
|
||||||
|
onPageChange={handlePageClick}
|
||||||
|
pageRangeDisplayed={3}
|
||||||
|
forcePage={currentPage}
|
||||||
|
pageCount={Math.ceil(countPage / (PageSize ? PageSize : 5))}
|
||||||
|
previousLabel={<MdKeyboardArrowRight className="w-5 h-5 " />}
|
||||||
|
pageClassName=" w-10 h-10 grid place-content-center rounded-lg !text-blue shadow-md"
|
||||||
|
className={twMerge(
|
||||||
|
" flex flex-wrap gap-3 text-sm md:text-base w-full bottom-0 rounded-md p-1 bg-white/30 backdrop-blur-lg justify-center text-blue mt-5"
|
||||||
|
)}
|
||||||
|
activeClassName=" bg-blue text-blue shadow-md shadow-main"
|
||||||
|
activeLinkClassName=" text-white w-full p-1 h-full"
|
||||||
|
previousLinkClassName=" w-10 h-10 grid place-content-center rounded-lg text-sm shadow-md"
|
||||||
|
nextLinkClassName=" w-10 h-10 grid place-content-center rounded-lg text-sm shadow-md"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -24,32 +24,34 @@ export default function Search({
|
||||||
action,
|
action,
|
||||||
changeValue,
|
changeValue,
|
||||||
}: {
|
}: {
|
||||||
mode: string;
|
mode?: string;
|
||||||
value: any;
|
value?: any;
|
||||||
action: (any: any) => any;
|
action?: (any: any) => any;
|
||||||
changeValue: (any: any) => any;
|
changeValue?: (any: any) => any ;
|
||||||
}) {
|
}) {
|
||||||
// useEffect(() => {
|
// useEffect(() => {
|
||||||
// const isMobile = useMediaQuery({ query: "(max-width: 768px)" });
|
// const isMobile = useMediaQuery({ query: "(max-width: 768px)" });
|
||||||
// }, []);
|
// }, []);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div className="relative flex items-center w-full bg-gray-300 lg:w-1/5 rounded-xl">
|
||||||
{mode === "controller" || mode === "admin" ? (
|
|
||||||
<div className="relative flex items-center bg-gray-300 rounded-xl">
|
|
||||||
<Input
|
<Input
|
||||||
// type="search"
|
// type="search"
|
||||||
id="default-search"
|
id="default-search"
|
||||||
className={`mb-0 h-8 bg-[#D6D8DE66] border-none focus-visible:none rounded-lg
|
className={`mb-0 h-8 bg-[#E9E9E9] border-none focus-visible:none rounded-lg
|
||||||
block w-full min-w-[13rem] lg:min-w-[16rem] text-xs text-black
|
block w-full min-w-[13rem] text-xs md:text-sm text-black
|
||||||
text-opacity-60 dark:text-white
|
text-opacity-60 dark:text-white
|
||||||
${mode === "controller" && "h-14 max-lg:min-w-[95vw]"}
|
${mode === "controller" && "h-14 "}
|
||||||
${
|
${
|
||||||
mode === "admin" &&
|
mode === "admin" &&
|
||||||
"w-full min-w-full bg-white lg:min-w-full h-11"
|
"w-full min-w-full bg-white lg:min-w-full h-11"
|
||||||
}
|
}
|
||||||
`}
|
`}
|
||||||
value={value}
|
value={value}
|
||||||
onChange={(e) => changeValue(e.target.value)}
|
onChange={(e) => {
|
||||||
|
if (changeValue) {
|
||||||
|
changeValue(e.target.value);
|
||||||
|
}
|
||||||
|
}}
|
||||||
placeholder="جستجو..."
|
placeholder="جستجو..."
|
||||||
required
|
required
|
||||||
/>
|
/>
|
||||||
|
|
@ -62,71 +64,5 @@ export default function Search({
|
||||||
<CiSearch />
|
<CiSearch />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
|
||||||
<>
|
|
||||||
<div className="relative flex items-center bg-gray-300 max-md:hidden rounded-xl">
|
|
||||||
<Input
|
|
||||||
// type="search"
|
|
||||||
id="default-search"
|
|
||||||
className={`mb-0 h-8 bg-[#D6D8DE66] border-none focus-visible:none rounded-lg
|
|
||||||
block w-full min-w-[13rem] lg:min-w-[16rem] text-xs text-black
|
|
||||||
text-opacity-60 dark:text-white
|
|
||||||
${mode === "controller" && "h-12 max-lg:min-w-[95vw]"}
|
|
||||||
${
|
|
||||||
mode === "admin" &&
|
|
||||||
"w-full min-w-full bg-white lg:min-w-full h-11"
|
|
||||||
}
|
|
||||||
`}
|
|
||||||
placeholder="جستجو..."
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
<button className="absolute left-3">
|
|
||||||
<CiSearch />
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
<div className="md:hidden">
|
|
||||||
<AlertDialog>
|
|
||||||
<AlertDialogTrigger asChild>
|
|
||||||
<button
|
|
||||||
// variant="outline"
|
|
||||||
// type="submit"
|
|
||||||
className="p-1 font-bold text-white rounded-md bg-gradient2"
|
|
||||||
>
|
|
||||||
<CiSearch />
|
|
||||||
</button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
|
|
||||||
<AlertDialogContent className=" h-1/5 min-w-[80%] max-w-fit">
|
|
||||||
<AlertDialogHeader className="w-full">
|
|
||||||
<AlertDialogTitle className="py-1 ">
|
|
||||||
<p className="text-[#464646] text-base font-bold">
|
|
||||||
فرم جستجو
|
|
||||||
</p>
|
|
||||||
<AlertDialogCancel className="h-auto p-0 border-0">
|
|
||||||
<IoMdClose />
|
|
||||||
</AlertDialogCancel>
|
|
||||||
</AlertDialogTitle>
|
|
||||||
|
|
||||||
<AlertDialogDescription className="justify-center sm:px-14 sm:py-6">
|
|
||||||
<Input
|
|
||||||
// type="search"
|
|
||||||
id="default-search"
|
|
||||||
className="mb-0 h-12 bg-gray border-none focus-visible:none rounded-lg
|
|
||||||
block w-full min-w-[13rem] lg:min-w-[16rem] text-xs text-black text-opacity-60 dark:text-white "
|
|
||||||
placeholder="جستجو..."
|
|
||||||
required
|
|
||||||
/>
|
|
||||||
|
|
||||||
<button className="absolute text-black left-16">
|
|
||||||
<CiSearch />
|
|
||||||
</button>
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,17 @@ import { useRouter } from "next/navigation";
|
||||||
import { Decrypt } from "@/lib/utils";
|
import { Decrypt } from "@/lib/utils";
|
||||||
import useData from "@/store/useData";
|
import useData from "@/store/useData";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import Pagination from "./Pagination";
|
||||||
|
import { Skeleton } from "./ui/skeleton";
|
||||||
|
|
||||||
export default function TabController() {
|
export default function TabController() {
|
||||||
const saveData = useData((state) => state.saveData);
|
const saveData = useData((state) => state.saveData);
|
||||||
const [selectedFile, setSelectedFile] = useState<any>(null);
|
const [selectedFile, setSelectedFile] = useState<any>(null);
|
||||||
const [search, setSearch] = useState<any>(null);
|
const [search, setSearch] = useState<any>(null);
|
||||||
|
const [page, setPage] = useState<any>(1);
|
||||||
|
const [totalCount, setTotalCount] = useState<any>(0);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const handleFileChange = (event: any) => {
|
const handleFileChange = (event: any) => {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
|
|
@ -38,6 +44,7 @@ export default function TabController() {
|
||||||
|
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
};
|
};
|
||||||
|
|
||||||
const checkKey = (item: any) => {
|
const checkKey = (item: any) => {
|
||||||
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
|
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
|
||||||
if (dcKey != false && dcKey != null) {
|
if (dcKey != false && dcKey != null) {
|
||||||
|
|
@ -52,9 +59,9 @@ export default function TabController() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
console.log(search);
|
|
||||||
const [psblState, setPsblState] = useState(0);
|
const [psblState, setPsblState] = useState(0);
|
||||||
const [selectedTab, setSelectedTab] = useState("0");
|
const [selectedTab, setSelectedTab] = useState<string>("0");
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: dataState,
|
data: dataState,
|
||||||
|
|
@ -70,27 +77,44 @@ export default function TabController() {
|
||||||
// setSelectedTab(initialSelectedTab);
|
// setSelectedTab(initialSelectedTab);
|
||||||
|
|
||||||
const { data, isLoading, refetch } = useQuery({
|
const { data, isLoading, refetch } = useQuery({
|
||||||
queryKey: ["ComplaintsList", psblState, dataState],
|
queryKey: ["ComplaintsList", psblState, dataState, page],
|
||||||
queryFn: () =>
|
queryFn: () =>
|
||||||
getComplaintsList({ states: psblState, TrackingNumber: search }),
|
getComplaintsList({
|
||||||
|
states: psblState,
|
||||||
|
TrackingNumber: search,
|
||||||
|
PageNumber: page,
|
||||||
|
}),
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
const handelSearch = (event: any) => {
|
const handelSearch = (event: any) => {
|
||||||
refetch();
|
refetch();
|
||||||
};
|
};
|
||||||
// useEffect(() => {
|
|
||||||
// // Handle the data after it has been updated
|
useEffect(() => {
|
||||||
// }, [data]);
|
if (data) {
|
||||||
|
const headersData = JSON.parse(data.headers["x-pagination"]);
|
||||||
|
setTotalCount(headersData.TotalCount);
|
||||||
|
}
|
||||||
|
}, [data]);
|
||||||
|
useEffect(() => {
|
||||||
|
const activeTab = localStorage.getItem("ActiveTab");
|
||||||
|
if (activeTab) {
|
||||||
|
setSelectedTab(activeTab);
|
||||||
|
setPsblState(Number(activeTab));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const isZero = totalCount === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 pt-9 mx-auto">
|
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 pt-9 mx-auto">
|
||||||
<p className="my-2 text-xs font-bold 3xl:ml-6 sm:text-sm md:hidden">
|
<p className="my-2 text-xs font-bold 3xl:ml-6 sm:text-sm">
|
||||||
لیست شکایت ها
|
لیست شکایت ها
|
||||||
</p>
|
</p>
|
||||||
<Tabs
|
<Tabs
|
||||||
defaultValue="0"
|
// defaultValue="0"
|
||||||
value={selectedTab}
|
value={String(selectedTab)}
|
||||||
// onClick={(value) => {
|
// onClick={(value) => {
|
||||||
// setPsblState(value);
|
// setPsblState(value);
|
||||||
// setSelectedTab(value);
|
// setSelectedTab(value);
|
||||||
|
|
@ -99,28 +123,33 @@ export default function TabController() {
|
||||||
className=""
|
className=""
|
||||||
dir="rtl"
|
dir="rtl"
|
||||||
>
|
>
|
||||||
<div className="flex flex-col-reverse items-center justify-between w-full gap-4 mb-10 lg:flex-row lg:gap-5">
|
<div className="flex flex-col-reverse items-center justify-between w-full gap-4 mb-10 lg:flex-row lg:gap-2">
|
||||||
{/* Tab Title */}
|
{/* Tab Title */}
|
||||||
<TabsList className="flex w-full gap-1 md:gap-4 lg:gap-3">
|
<TabsList className="flex w-full gap-1 h-a max-lg:flex-wrap max lg:w-4/5 md:gap-4 lg:gap-1 p-1">
|
||||||
<p className="text-xs font-bold 3xl:ml-6 sm:text-sm max-md:hidden">
|
{/* <p className="text-xs font-bold 3xl:ml-6 sm:text-sm max-xl:hidden">
|
||||||
لیست شکایت ها |
|
لیست شکایت ها |
|
||||||
</p>
|
</p> */}
|
||||||
|
|
||||||
{dataState?.map((item: any) => {
|
{dataState?.map((item: any) => {
|
||||||
// const isActive = item.value === selectedTab;
|
// const isActive = item.value === selectedTab;
|
||||||
return (
|
return (
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
key={item.value}
|
key={item.value}
|
||||||
className="hover:border-b-2 border-b-blue max-md:flex-1"
|
className="hover:border-b-2 border-b-blue flex-1 h-10"
|
||||||
value={item.value}
|
value={String(item.value)}
|
||||||
// data-state={isActive ? 'active' : 'inactive'}
|
// data-state={isActive ? 'active' : 'inactive'}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setPsblState(item.value);
|
setPsblState(item.value);
|
||||||
setSelectedTab(item.value);
|
setSelectedTab(String(item.value));
|
||||||
|
localStorage.setItem("ActiveTab", String(item.value));
|
||||||
|
|
||||||
refetch();
|
refetch();
|
||||||
|
setPage(0);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.title}
|
<div className="relative w-full ">
|
||||||
|
{item.title} ({item.count})
|
||||||
|
</div>
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
@ -138,7 +167,37 @@ export default function TabController() {
|
||||||
{/* Tab Content */}
|
{/* Tab Content */}
|
||||||
|
|
||||||
<TabsContent value={selectedTab} key={selectedTab}>
|
<TabsContent value={selectedTab} key={selectedTab}>
|
||||||
<TableController checkKey={(item) => checkKey(item)} data={data} />
|
{data ? (
|
||||||
|
<TableController
|
||||||
|
checkKey={(item) => checkKey(item)}
|
||||||
|
data={data?.data}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="flex flex-col gap-3">
|
||||||
|
<Skeleton className="w-full h-12" />
|
||||||
|
<Skeleton className="w-full h-12" />
|
||||||
|
<Skeleton className="w-full h-12" />
|
||||||
|
<Skeleton className="w-full h-12" />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{!isZero ? (
|
||||||
|
<Pagination
|
||||||
|
// length={data3?.data.length}
|
||||||
|
// itemsPerPage={1}
|
||||||
|
countPage={totalCount}
|
||||||
|
Page={(num: number) => setPage(num + 1)}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
{" "}
|
||||||
|
{data?.data.length == 0 && (
|
||||||
|
<p className="flex justify-center mx-auto mt-10 text-blue/50">
|
||||||
|
درخواستی وجود ندارد
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ import { toast } from "sonner";
|
||||||
import { ScrollArea } from "./ui/scroll-area";
|
import { ScrollArea } from "./ui/scroll-area";
|
||||||
import secureLocalStorage from "react-secure-storage";
|
import secureLocalStorage from "react-secure-storage";
|
||||||
import { Checkbox } from "./ui/checkbox";
|
import { Checkbox } from "./ui/checkbox";
|
||||||
|
import { Skeleton } from "./ui/skeleton";
|
||||||
interface Complaint {
|
interface Complaint {
|
||||||
id: string;
|
id: string;
|
||||||
trackingNumber: string;
|
trackingNumber: string;
|
||||||
|
|
@ -110,7 +111,7 @@ export default function TableController({
|
||||||
<TableHead>دستگاه مربوطه</TableHead>
|
<TableHead>دستگاه مربوطه</TableHead>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableHeader>
|
</TableHeader>
|
||||||
<TableBody className="bg-[#F5F5F5]">
|
<TableBody className="bg-[#F5F5F5] min-h-[20rem] ">
|
||||||
{data?.map((item: Complaint, index: number) => {
|
{data?.map((item: Complaint, index: number) => {
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
|
|
@ -120,7 +121,7 @@ export default function TableController({
|
||||||
`/UserPanel/ControllerDashboard/Complaints/${item.id}`
|
`/UserPanel/ControllerDashboard/Complaints/${item.id}`
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
className=" hover:bg-gray-200 cursor-pointer"
|
className="cursor-pointer hover:bg-gray-200"
|
||||||
key={item.id}
|
key={item.id}
|
||||||
>
|
>
|
||||||
{/* <Link
|
{/* <Link
|
||||||
|
|
@ -149,6 +150,15 @@ export default function TableController({
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{data.length != 0 &&
|
||||||
|
[...Array(5 - data.length)].map(() => {
|
||||||
|
return (
|
||||||
|
<TableRow
|
||||||
|
key={Math.random()}
|
||||||
|
className="border border-t-0 border-b-0"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
<Dialog open={open} onOpenChange={setOpen}>
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,6 @@ export default function TopNav() {
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Search mode="landing" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
function Skeleton({
|
||||||
|
className,
|
||||||
|
...props
|
||||||
|
}: React.HTMLAttributes<HTMLDivElement>) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={cn("animate-pulse rounded-md bg-muted", className)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Skeleton }
|
||||||
|
|
@ -14,7 +14,7 @@ const TabsList = React.forwardRef<
|
||||||
<TabsPrimitive.List
|
<TabsPrimitive.List
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn(
|
className={cn(
|
||||||
"inline-flex h-14 items-center justify-start rounded-md bg-[#E9E9E9] p-2 text-muted-foreground",
|
"inline-flex min-h-[3.5rem] items-center justify-start rounded-md bg-[#E9E9E9] p-2 text-muted-foreground",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
{...props}
|
{...props}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.2.3",
|
"version": "0.2.5",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.2.3",
|
"version": "0.2.5",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@hookform/resolvers": "^3.3.2",
|
"@hookform/resolvers": "^3.3.2",
|
||||||
"@radix-ui/react-alert-dialog": "^1.0.5",
|
"@radix-ui/react-alert-dialog": "^1.0.5",
|
||||||
|
|
@ -56,6 +56,7 @@
|
||||||
"react-leaflet": "^4.2.1",
|
"react-leaflet": "^4.2.1",
|
||||||
"react-loader-spinner": "^6.1.6",
|
"react-loader-spinner": "^6.1.6",
|
||||||
"react-otp-input": "^3.1.1",
|
"react-otp-input": "^3.1.1",
|
||||||
|
"react-paginate": "^8.1.3",
|
||||||
"react-quill": "^2.0.0",
|
"react-quill": "^2.0.0",
|
||||||
"react-responsive": "^9.0.2",
|
"react-responsive": "^9.0.2",
|
||||||
"react-secure-storage": "^1.3.2",
|
"react-secure-storage": "^1.3.2",
|
||||||
|
|
@ -7951,6 +7952,17 @@
|
||||||
"react-dom": ">=16.8.6 || ^17.0.0 || ^18.0.0"
|
"react-dom": ">=16.8.6 || ^17.0.0 || ^18.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-paginate": {
|
||||||
|
"version": "8.1.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-paginate/-/react-paginate-8.1.3.tgz",
|
||||||
|
"integrity": "sha512-zBp80DBRcaeBnAeHUfbGKD0XHfbGNUolQ+S60Ymfs8o7rusYaJYZMAt1j93ADDNLlzRmJ0tMF/NeTlcdKf7dlQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"prop-types": "^15.6.1"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react": "^16 || ^17 || ^18"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/react-quill": {
|
"node_modules/react-quill": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/react-quill/-/react-quill-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/react-quill/-/react-quill-2.0.0.tgz",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sootzani",
|
"name": "sootzani",
|
||||||
"version": "0.2.3",
|
"version": "0.2.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
|
|
@ -57,6 +57,7 @@
|
||||||
"react-leaflet": "^4.2.1",
|
"react-leaflet": "^4.2.1",
|
||||||
"react-loader-spinner": "^6.1.6",
|
"react-loader-spinner": "^6.1.6",
|
||||||
"react-otp-input": "^3.1.1",
|
"react-otp-input": "^3.1.1",
|
||||||
|
"react-paginate": "^8.1.3",
|
||||||
"react-quill": "^2.0.0",
|
"react-quill": "^2.0.0",
|
||||||
"react-responsive": "^9.0.2",
|
"react-responsive": "^9.0.2",
|
||||||
"react-secure-storage": "^1.3.2",
|
"react-secure-storage": "^1.3.2",
|
||||||
|
|
|
||||||
|
|
@ -160,9 +160,17 @@ export async function UpdateWebContents({
|
||||||
}
|
}
|
||||||
|
|
||||||
// .....News.................................................
|
// .....News.................................................
|
||||||
export async function GetAllNews() {
|
export async function GetAllNews({
|
||||||
const data = await axios.get("api/News");
|
PageNumber = 1,
|
||||||
return data.data;
|
PageSize = 5,
|
||||||
|
}: {
|
||||||
|
PageNumber?: number;
|
||||||
|
PageSize?: number;
|
||||||
|
}) {
|
||||||
|
const data = await axios.get("api/News", {
|
||||||
|
params: { PageNumber: PageNumber, PageSize: PageSize },
|
||||||
|
});
|
||||||
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function GetSingleNews({ id }: { id: string }) {
|
export async function GetSingleNews({ id }: { id: string }) {
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import {
|
||||||
|
|
||||||
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
||||||
|
|
||||||
|
let isRefreshing = false;
|
||||||
|
|
||||||
axios.interceptors.response.use(
|
axios.interceptors.response.use(
|
||||||
(response) => {
|
(response) => {
|
||||||
return response;
|
return response;
|
||||||
|
|
@ -15,21 +17,37 @@ axios.interceptors.response.use(
|
||||||
async function (error) {
|
async function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
const originalRequest = error.config;
|
const originalRequest = error.config;
|
||||||
|
|
||||||
if (error.response.status === 401) {
|
if (error.response.status === 401) {
|
||||||
|
if (!originalRequest._retry) {
|
||||||
|
originalRequest._retry = true;
|
||||||
const accessToken = getCookie("Sootzani_Token");
|
const accessToken = getCookie("Sootzani_Token");
|
||||||
const refreshToken = getCookie("Sootzani_Refresh_Token");
|
const refreshToken = getCookie("Sootzani_Refresh_Token");
|
||||||
|
|
||||||
|
if (accessToken && refreshToken && !isRefreshing) {
|
||||||
|
isRefreshing = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Perform token refresh
|
||||||
const data = await RefreshToken({
|
const data = await RefreshToken({
|
||||||
token: accessToken,
|
token: accessToken,
|
||||||
refreshToken: refreshToken,
|
refreshToken: refreshToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Retry the original request
|
||||||
|
return axios(originalRequest);
|
||||||
|
} catch (refreshError) {
|
||||||
|
console.error("Token refresh failed", refreshError);
|
||||||
|
// Handle refresh error, e.g., redirect to login page
|
||||||
|
return Promise.reject(refreshError);
|
||||||
|
} finally {
|
||||||
|
isRefreshing = false;
|
||||||
}
|
}
|
||||||
// if (error.response.status === 403 && !originalRequest._retry) {
|
}
|
||||||
// originalRequest._retry = true;
|
}
|
||||||
// const access_token = await refreshAccessToken();
|
}
|
||||||
// axios.defaults.headers.common["Authorization"] = "Bearer " + access_token;
|
|
||||||
// return axiosApiInstance(originalRequest);
|
// For other errors or if refresh token logic is not applicable
|
||||||
// }
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -97,6 +115,16 @@ export async function editProfile(payload: {
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function revoke(payload: {
|
||||||
|
refreshToken: string | CookieValueTypes;
|
||||||
|
}) {
|
||||||
|
const token = getCookie("Sootzani_Token");
|
||||||
|
const data = await axios.post("api/Authenticate/Revoke", payload, {
|
||||||
|
headers: { Authorization: `Bearer ${token}` },
|
||||||
|
});
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
export async function RefreshToken(payload: { token: any; refreshToken: any }) {
|
export async function RefreshToken(payload: { token: any; refreshToken: any }) {
|
||||||
try {
|
try {
|
||||||
const response = await axios.post("api/Authenticate/Refresh", payload);
|
const response = await axios.post("api/Authenticate/Refresh", payload);
|
||||||
|
|
|
||||||
|
|
@ -20,16 +20,20 @@ export async function getPossibleStates() {
|
||||||
export async function getComplaintsList({
|
export async function getComplaintsList({
|
||||||
states = 0,
|
states = 0,
|
||||||
TrackingNumber,
|
TrackingNumber,
|
||||||
|
PageNumber = 1,
|
||||||
|
PageSize = 5,
|
||||||
}: {
|
}: {
|
||||||
states: number;
|
states: number;
|
||||||
TrackingNumber?: string;
|
TrackingNumber?: string;
|
||||||
|
PageNumber?: number;
|
||||||
|
PageSize?: number;
|
||||||
}) {
|
}) {
|
||||||
// export async function getComplaintsList() {
|
// export async function getComplaintsList() {
|
||||||
// const data = await axios.get(`api/Inspector/List`);
|
// const data = await axios.get(`api/Inspector/List`);
|
||||||
const data = await axios.get(`api/Inspector/List?States=${states}`, {
|
const data = await axios.get(`api/Inspector/List?States=${states}`, {
|
||||||
params: { TrackingNumber: TrackingNumber },
|
params: { TrackingNumber: TrackingNumber, PageNumber, PageSize },
|
||||||
});
|
});
|
||||||
return data.data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getComplaint(payload: {
|
export async function getComplaint(payload: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue