Pagination added
parent
19f1031c37
commit
eae43317b8
|
|
@ -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,23 +27,36 @@ 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,
|
refetchOnWindowFocus: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const revokeMutation = useMutation({
|
||||||
|
mutationFn: revoke,
|
||||||
|
onSuccess: (res) => {},
|
||||||
|
onError: (err: any | string) => {},
|
||||||
|
});
|
||||||
|
|
||||||
const menus = {
|
const menus = {
|
||||||
Admin: AdminMenuItems,
|
Admin: AdminMenuItems,
|
||||||
Inspector: ControllerMenuItems,
|
Inspector: ControllerMenuItems,
|
||||||
};
|
};
|
||||||
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 +125,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 +148,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,67 @@
|
||||||
|
"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({
|
||||||
|
itemsPerPage,
|
||||||
|
Page,
|
||||||
|
countPage,
|
||||||
|
length,
|
||||||
|
}: {
|
||||||
|
itemsPerPage?: any;
|
||||||
|
Page?: any;
|
||||||
|
countPage?: any;
|
||||||
|
length?: any;
|
||||||
|
}) {
|
||||||
|
// Here we use item offsets; we could also use page offsets
|
||||||
|
// following the API or data you're working with.
|
||||||
|
const [itemOffset, setItemOffset] = useState(0);
|
||||||
|
|
||||||
|
// Simulate fetching items from another resources.
|
||||||
|
// (This could be items from props; or items loaded in a local state
|
||||||
|
// from an API endpoint with useEffect and useState)
|
||||||
|
const endOffset = itemOffset + itemsPerPage;
|
||||||
|
// console.log(`Loading items from ${itemOffset} to ${endOffset}`);
|
||||||
|
const currentItems = items.slice(itemOffset, endOffset);
|
||||||
|
const pageCount = Math.ceil(items.length / itemsPerPage);
|
||||||
|
|
||||||
|
// Invoke when user click to request another page.
|
||||||
|
const handlePageClick = (event: any) => {
|
||||||
|
const newOffset = (event.selected * itemsPerPage) % items.length;
|
||||||
|
console.log(
|
||||||
|
`User requested page number ${event.selected}, which is offset ${newOffset}`
|
||||||
|
);
|
||||||
|
setItemOffset(newOffset);
|
||||||
|
// console.log(event.selected);
|
||||||
|
console.log(event);
|
||||||
|
Page(event.selected);
|
||||||
|
};
|
||||||
|
console.log(countPage);
|
||||||
|
// console.log(pageCount, "1111");
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{/* <Items currentItems={currentItems} /> */}
|
||||||
|
<ReactPaginate
|
||||||
|
breakLabel="..."
|
||||||
|
onPageActive={(e) => console.log(e)}
|
||||||
|
nextLabel={<MdKeyboardArrowLeft className="w-5 h-5 " />}
|
||||||
|
onPageChange={handlePageClick}
|
||||||
|
pageRangeDisplayed={3}
|
||||||
|
pageCount={Math.ceil(countPage / 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"
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -33,16 +33,14 @@ export default function Search({
|
||||||
// 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"
|
||||||
|
|
@ -62,71 +60,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,7 +59,7 @@ 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("0");
|
||||||
|
|
||||||
|
|
@ -70,27 +77,36 @@ 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
|
|
||||||
// }, [data]);
|
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (data) {
|
||||||
|
const headersData = JSON.parse(data.headers["x-pagination"]);
|
||||||
|
setTotalCount(headersData.TotalCount);
|
||||||
|
}
|
||||||
|
}, [data]);
|
||||||
|
const isZero = totalCount === 0;
|
||||||
|
console.log(totalCount);
|
||||||
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 xl:hidden">
|
||||||
لیست شکایت ها
|
لیست شکایت ها
|
||||||
</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,10 +115,10 @@ 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>
|
||||||
|
|
||||||
|
|
@ -111,16 +127,19 @@ export default function TabController() {
|
||||||
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));
|
||||||
refetch();
|
refetch();
|
||||||
|
setPage(0);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{item.title}
|
<div className="relative w-full ">
|
||||||
|
{item.title} ({item.count})
|
||||||
|
</div>
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
@ -138,7 +157,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,10 @@ export default function TableController({
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
{data.length != 0 &&
|
||||||
|
[...Array(5 - data.length)].map(() => {
|
||||||
|
return <TableRow className="border border-t-0 border-b-0" />;
|
||||||
|
})}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
<Dialog open={open} onOpenChange={setOpen}>
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
|
|
|
||||||
|
|
@ -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}
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -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",
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,19 @@ 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 &&
|
||||||
|
originalRequest.url == "api/Authenticate/Profile"
|
||||||
|
) {
|
||||||
|
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) {
|
||||||
const data = await RefreshToken({
|
const data = await RefreshToken({
|
||||||
token: accessToken,
|
token: accessToken,
|
||||||
refreshToken: refreshToken,
|
refreshToken: refreshToken,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// if (error.response.status === 403 && !originalRequest._retry) {
|
// if (error.response.status === 403 && !originalRequest._retry) {
|
||||||
// originalRequest._retry = true;
|
// originalRequest._retry = true;
|
||||||
|
|
@ -97,6 +102,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