Compare commits
6 Commits
6baeccf126
...
24350884fd
| Author | SHA1 | Date |
|---|---|---|
|
|
24350884fd | |
|
|
82ebc3c611 | |
|
|
7606d2cb34 | |
|
|
fd42d2ad7f | |
|
|
a0ea1e0b95 | |
|
|
eae43317b8 |
|
|
@ -328,7 +328,7 @@ export default function AdminCategories() {
|
|||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
<p className="text-[#464646] text-base font-bold">
|
||||
تغییر دسته بندی
|
||||
ویرایش دسته بندی
|
||||
</p>
|
||||
<AlertDialogCancel className="h-auto p-0 border-0">
|
||||
<IoMdClose />
|
||||
|
|
@ -384,7 +384,7 @@ export default function AdminCategories() {
|
|||
type="submit"
|
||||
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
||||
>
|
||||
تغییر دسته بندی
|
||||
ویرایش دسته بندی
|
||||
</Button>
|
||||
|
||||
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl">
|
||||
|
|
|
|||
|
|
@ -455,7 +455,7 @@ export default function AdminKeysManagement() {
|
|||
type="submit"
|
||||
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
||||
>
|
||||
تغییر کلید
|
||||
ویرایش کلید
|
||||
</Button>
|
||||
|
||||
{/* <AlertDialogAction
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import { FaRegEdit } from "react-icons/fa";
|
|||
import { IoMdClose } from "react-icons/io";
|
||||
import { RiDeleteBin6Line } from "react-icons/ri";
|
||||
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 { toast } from "sonner";
|
||||
|
||||
|
|
@ -51,6 +51,7 @@ import * as z from "zod";
|
|||
import { Textarea } from "./ui/textarea";
|
||||
import { Switch } from "@/components/ui/switch";
|
||||
import Image from "next/image";
|
||||
import Pagination from "./Pagination";
|
||||
|
||||
const MAX_IMAGE_SIZE = 5242880; // 5 MB
|
||||
const ALLOWED_IMAGE_TYPES = [
|
||||
|
|
@ -123,7 +124,8 @@ export default function AdminNews() {
|
|||
const [urlNews, setUrlNews] = useState("");
|
||||
const [contentNews, setContentNews] = useState("");
|
||||
const [imageNews, setImageNews] = useState("");
|
||||
|
||||
const [page, setPage] = useState<any>(1);
|
||||
const [totalCount, setTotalCount] = useState<any>(0);
|
||||
const [keyIdDel, setKeyIdDel] = useState("");
|
||||
|
||||
const [openAdd, setOpenAdd] = React.useState(false);
|
||||
|
|
@ -138,8 +140,11 @@ export default function AdminNews() {
|
|||
isLoading: isListLoading,
|
||||
refetch: refetch1,
|
||||
} = useQuery({
|
||||
queryKey: ["NewsList"],
|
||||
queryFn: () => GetAllNews(),
|
||||
queryKey: ["NewsList", page],
|
||||
queryFn: () =>
|
||||
GetAllNews({
|
||||
PageNumber: page,
|
||||
}),
|
||||
// queryFn: () => GetAllOrganizations(),
|
||||
// refetchOnWindowFocus: false,
|
||||
});
|
||||
|
|
@ -253,8 +258,6 @@ export default function AdminNews() {
|
|||
mutationKey: ["AddNews"],
|
||||
mutationFn: SubmitNews,
|
||||
onSuccess: (res) => {
|
||||
console.log(res);
|
||||
console.log("Success Change News");
|
||||
setOpenAdd(false);
|
||||
|
||||
refetch1();
|
||||
|
|
@ -314,8 +317,16 @@ export default function AdminNews() {
|
|||
console.log(data);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (data1) {
|
||||
const headersData = JSON.parse(data1.headers["x-pagination"]);
|
||||
setTotalCount(headersData.TotalCount);
|
||||
setPage(headersData.CurrentPage);
|
||||
}
|
||||
}, [data1]);
|
||||
|
||||
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="flex flex-row justify-between w-full ">
|
||||
{/* 1 */}
|
||||
|
|
@ -516,7 +527,7 @@ export default function AdminNews() {
|
|||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
<p className="text-[#464646] text-base font-bold">
|
||||
تغییر خبر
|
||||
ویرایش خبر
|
||||
</p>
|
||||
<AlertDialogCancel className="h-auto p-0 border-0">
|
||||
<IoMdClose />
|
||||
|
|
@ -667,7 +678,7 @@ export default function AdminNews() {
|
|||
type="submit"
|
||||
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
||||
>
|
||||
تغییر خبر
|
||||
ویرایش خبر
|
||||
</Button>
|
||||
|
||||
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl">
|
||||
|
|
@ -681,20 +692,33 @@ export default function AdminNews() {
|
|||
<AlertDialogFooter></AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
|
||||
{data1?.map((item: any) => {
|
||||
{data1?.data?.map((item: any) => {
|
||||
return (
|
||||
<div
|
||||
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">
|
||||
عنوان :
|
||||
<span className=" text-slate-800">{item.title}</span>
|
||||
</p>
|
||||
<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}
|
||||
</span>
|
||||
</p>
|
||||
|
|
@ -704,21 +728,13 @@ export default function AdminNews() {
|
|||
{item.content}
|
||||
</span>
|
||||
</p>
|
||||
<Image
|
||||
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>
|
||||
<div className="flex items-end justify-end w-full gap-2">
|
||||
<Switch
|
||||
dir="ltr"
|
||||
checked={!item.isDeleted}
|
||||
onCheckedChange={() => {
|
||||
DeleteNewsMutation.mutate({id: item.id});
|
||||
DeleteNewsMutation.mutate({ id: item.id });
|
||||
}}
|
||||
id={item.id}
|
||||
/>
|
||||
|
|
@ -743,9 +759,18 @@ export default function AdminNews() {
|
|||
</AlertDialogTrigger>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</AlertDialog>
|
||||
{!isListLoading && (
|
||||
<Pagination
|
||||
currentPage={page - 1}
|
||||
PageSize={5}
|
||||
countPage={totalCount}
|
||||
Page={(num: number) => setPage(num + 1)}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -456,7 +456,6 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
|||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end">
|
||||
|
|
@ -487,7 +486,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
|||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>
|
||||
<p className="text-[#464646] text-base font-bold">
|
||||
تغییر اسلایدر
|
||||
ویرایش اسلایدر
|
||||
</p>
|
||||
<AlertDialogCancel className="h-auto p-0 border-0">
|
||||
<IoMdClose />
|
||||
|
|
@ -614,7 +613,6 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
|||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
</div>
|
||||
|
||||
<div className="flex justify-center w-full gap-2 mt-8 sm:justify-end">
|
||||
|
|
@ -622,7 +620,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
|||
type="submit"
|
||||
className="p-2 text-center text-white bg-blue min-w-max rounded-xl hover:bg-white hover:text-slate-800"
|
||||
>
|
||||
تغییر اسلایدر
|
||||
ویرایش اسلایدر
|
||||
</Button>
|
||||
|
||||
<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">
|
||||
عنوان :
|
||||
<span className=" text-slate-800">{item.title}</span>
|
||||
عنوان :<span className=" text-slate-800">{item.title}</span>
|
||||
</p>
|
||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||
توضیحات:
|
||||
|
|
@ -675,8 +672,8 @@ function onSubmitAdd(data: AddSliderFormValues) {
|
|||
checked={!item.isDeleted}
|
||||
onCheckedChange={() => {
|
||||
DeleteSliderMutation.mutate({
|
||||
id: item.id
|
||||
})
|
||||
id: item.id,
|
||||
});
|
||||
}}
|
||||
id={item.id}
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ export default function ComplainsDetails({
|
|||
/>
|
||||
</div>
|
||||
</div>
|
||||
{/* 2 */}
|
||||
{/* 2 */}
|
||||
<div className="flex flex-col self-stretch w-full gap-2 rounded-lg lg:w-2/3 ">
|
||||
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col md:flex-row gap-2 items-center justify-center lg:sticky top-28">
|
||||
{data.user == null ? (
|
||||
|
|
@ -315,6 +315,12 @@ export default function ComplainsDetails({
|
|||
{data.complaining ? data.complaining : "-"}
|
||||
</span>
|
||||
</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">
|
||||
زمان ثبت:{" "}
|
||||
<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>
|
||||
|
|
@ -349,6 +355,12 @@ export default function ComplainsDetails({
|
|||
{data.complaining ? data.complaining : "-"}
|
||||
</span>
|
||||
</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">
|
||||
زمان ثبت:{" "}
|
||||
<span className="text-[#7C838A] text-sm font-medium">
|
||||
|
|
@ -356,7 +368,7 @@ export default function ComplainsDetails({
|
|||
</span>
|
||||
</p>
|
||||
</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>
|
||||
|
|
@ -386,14 +398,22 @@ export default function ComplainsDetails({
|
|||
: "-"}
|
||||
</span>
|
||||
</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 className="bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col ">
|
||||
<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
|
||||
scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-500 scrollbar-track-gray-100">
|
||||
<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
|
||||
scrollbar-thin scrollbar-thumb-rounded-md scrollbar-thumb-gray-500 scrollbar-track-gray-100"
|
||||
>
|
||||
{data.contents?.map((item: any) => {
|
||||
return (
|
||||
<div
|
||||
|
|
@ -474,14 +494,12 @@ export default function ComplainsDetails({
|
|||
key2={key}
|
||||
/>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
{getComplaintMutation.isPending && (
|
||||
<div className="flex justify-center w-full h-full mt-20">
|
||||
|
||||
<Triangle
|
||||
visible={true}
|
||||
height="100"
|
||||
|
|
|
|||
|
|
@ -5,16 +5,16 @@ import { AdminMenuItems, ControllerMenuItems } from "@/constants";
|
|||
import { usePathname, useRouter } from "next/navigation";
|
||||
import { Squash as Hamburger } from "hamburger-react";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import { getProfile } from "@/utils/authenticateApi";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getProfile, revoke } from "@/utils/authenticateApi";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
import { DoorOpen, LogOut } from "lucide-react";
|
||||
import { deleteCookie } from "cookies-next";
|
||||
import { deleteCookie, getCookie } from "cookies-next";
|
||||
export default function NavbarPanel() {
|
||||
const [isOpen, setOpen] = useState(false);
|
||||
const ref = useRef(null);
|
||||
const router = useRouter();
|
||||
const pathname = usePathname();
|
||||
const [activeLink, setActiveLink] = useState('');
|
||||
const [activeLink, setActiveLink] = useState("");
|
||||
const [role, setRole] = useState<string | null>("");
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -27,11 +27,15 @@ export default function NavbarPanel() {
|
|||
setActiveLink(pathname);
|
||||
}, [pathname]);
|
||||
|
||||
|
||||
const { data, isLoading, refetch } = useQuery({
|
||||
queryKey: ["Profile"],
|
||||
queryFn: () => getProfile(),
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
const revokeMutation = useMutation({
|
||||
mutationFn: revoke,
|
||||
onSuccess: (res) => {},
|
||||
onError: (err: any | string) => {},
|
||||
});
|
||||
|
||||
const menus = {
|
||||
|
|
@ -40,10 +44,18 @@ export default function NavbarPanel() {
|
|||
};
|
||||
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 (
|
||||
<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 "
|
||||
>
|
||||
<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 ">
|
||||
<div className="flex items-center gap-8 max-md:gap-4">
|
||||
<div className=" md:hidden">
|
||||
<Hamburger
|
||||
|
|
@ -112,7 +124,7 @@ export default function NavbarPanel() {
|
|||
<p
|
||||
className={`text-white font-normal text-sm max-md:text-xs
|
||||
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}
|
||||
</p>
|
||||
|
|
@ -135,15 +147,7 @@ export default function NavbarPanel() {
|
|||
)}
|
||||
</h1>
|
||||
<div className="p-1 rounded-md hover:bg-white/50">
|
||||
<LogOut
|
||||
onClick={() => {
|
||||
deleteCookie("Sootzani_Token");
|
||||
localStorage.removeItem("privateKey");
|
||||
localStorage.removeItem("privatePassword");
|
||||
router.push("/");
|
||||
}}
|
||||
className="text-white cursor-pointer "
|
||||
/>
|
||||
<LogOut onClick={logout} className="text-white cursor-pointer " />
|
||||
</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,
|
||||
changeValue,
|
||||
}: {
|
||||
mode: string;
|
||||
value: any;
|
||||
action: (any: any) => any;
|
||||
changeValue: (any: any) => any;
|
||||
mode?: string;
|
||||
value?: any;
|
||||
action?: (any: any) => any;
|
||||
changeValue?: (any: any) => any ;
|
||||
}) {
|
||||
// useEffect(() => {
|
||||
// const isMobile = useMediaQuery({ query: "(max-width: 768px)" });
|
||||
// }, []);
|
||||
return (
|
||||
<div>
|
||||
{mode === "controller" || mode === "admin" ? (
|
||||
<div className="relative flex items-center bg-gray-300 rounded-xl">
|
||||
<div className="relative flex items-center w-full bg-gray-300 lg:w-1/5 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
|
||||
className={`mb-0 h-8 bg-[#E9E9E9] border-none focus-visible:none rounded-lg
|
||||
block w-full min-w-[13rem] text-xs md:text-sm text-black
|
||||
text-opacity-60 dark:text-white
|
||||
${mode === "controller" && "h-14 max-lg:min-w-[95vw]"}
|
||||
${mode === "controller" && "h-14 "}
|
||||
${
|
||||
mode === "admin" &&
|
||||
"w-full min-w-full bg-white lg:min-w-full h-11"
|
||||
}
|
||||
`}
|
||||
value={value}
|
||||
onChange={(e) => changeValue(e.target.value)}
|
||||
onChange={(e) => {
|
||||
if (changeValue) {
|
||||
changeValue(e.target.value);
|
||||
}
|
||||
}}
|
||||
placeholder="جستجو..."
|
||||
required
|
||||
/>
|
||||
|
|
@ -62,71 +64,5 @@ export default function Search({
|
|||
<CiSearch />
|
||||
</button>
|
||||
</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 useData from "@/store/useData";
|
||||
import { toast } from "sonner";
|
||||
import Pagination from "./Pagination";
|
||||
import { Skeleton } from "./ui/skeleton";
|
||||
|
||||
export default function TabController() {
|
||||
const saveData = useData((state) => state.saveData);
|
||||
const [selectedFile, setSelectedFile] = 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 handleFileChange = (event: any) => {
|
||||
const file = event.target.files[0];
|
||||
const reader = new FileReader();
|
||||
|
|
@ -38,6 +44,7 @@ export default function TabController() {
|
|||
|
||||
reader.readAsText(file);
|
||||
};
|
||||
|
||||
const checkKey = (item: any) => {
|
||||
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
|
||||
if (dcKey != false && dcKey != null) {
|
||||
|
|
@ -52,9 +59,9 @@ export default function TabController() {
|
|||
});
|
||||
}
|
||||
};
|
||||
console.log(search);
|
||||
|
||||
const [psblState, setPsblState] = useState(0);
|
||||
const [selectedTab, setSelectedTab] = useState("0");
|
||||
const [selectedTab, setSelectedTab] = useState<string>("0");
|
||||
|
||||
const {
|
||||
data: dataState,
|
||||
|
|
@ -70,27 +77,44 @@ export default function TabController() {
|
|||
// setSelectedTab(initialSelectedTab);
|
||||
|
||||
const { data, isLoading, refetch } = useQuery({
|
||||
queryKey: ["ComplaintsList", psblState, dataState],
|
||||
queryKey: ["ComplaintsList", psblState, dataState, page],
|
||||
queryFn: () =>
|
||||
getComplaintsList({ states: psblState, TrackingNumber: search }),
|
||||
getComplaintsList({
|
||||
states: psblState,
|
||||
TrackingNumber: search,
|
||||
PageNumber: page,
|
||||
}),
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
|
||||
const handelSearch = (event: any) => {
|
||||
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]);
|
||||
useEffect(() => {
|
||||
const activeTab = localStorage.getItem("ActiveTab");
|
||||
if (activeTab) {
|
||||
setSelectedTab(activeTab);
|
||||
setPsblState(Number(activeTab));
|
||||
}
|
||||
}, []);
|
||||
|
||||
const isZero = totalCount === 0;
|
||||
|
||||
return (
|
||||
<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>
|
||||
<Tabs
|
||||
defaultValue="0"
|
||||
value={selectedTab}
|
||||
// defaultValue="0"
|
||||
value={String(selectedTab)}
|
||||
// onClick={(value) => {
|
||||
// setPsblState(value);
|
||||
// setSelectedTab(value);
|
||||
|
|
@ -99,28 +123,33 @@ export default function TabController() {
|
|||
className=""
|
||||
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 */}
|
||||
<TabsList className="flex w-full gap-1 md:gap-4 lg:gap-3">
|
||||
<p className="text-xs font-bold 3xl:ml-6 sm:text-sm max-md:hidden">
|
||||
<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-xl:hidden">
|
||||
لیست شکایت ها |
|
||||
</p>
|
||||
</p> */}
|
||||
|
||||
{dataState?.map((item: any) => {
|
||||
// const isActive = item.value === selectedTab;
|
||||
return (
|
||||
<TabsTrigger
|
||||
key={item.value}
|
||||
className="hover:border-b-2 border-b-blue max-md:flex-1"
|
||||
value={item.value}
|
||||
className="hover:border-b-2 border-b-blue flex-1 h-10"
|
||||
value={String(item.value)}
|
||||
// data-state={isActive ? 'active' : 'inactive'}
|
||||
onClick={() => {
|
||||
setPsblState(item.value);
|
||||
setSelectedTab(item.value);
|
||||
setSelectedTab(String(item.value));
|
||||
localStorage.setItem("ActiveTab", String(item.value));
|
||||
|
||||
refetch();
|
||||
setPage(0);
|
||||
}}
|
||||
>
|
||||
{item.title}
|
||||
<div className="relative w-full ">
|
||||
{item.title} ({item.count})
|
||||
</div>
|
||||
</TabsTrigger>
|
||||
);
|
||||
})}
|
||||
|
|
@ -138,7 +167,37 @@ export default function TabController() {
|
|||
{/* Tab Content */}
|
||||
|
||||
<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>
|
||||
</Tabs>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import { toast } from "sonner";
|
|||
import { ScrollArea } from "./ui/scroll-area";
|
||||
import secureLocalStorage from "react-secure-storage";
|
||||
import { Checkbox } from "./ui/checkbox";
|
||||
import { Skeleton } from "./ui/skeleton";
|
||||
interface Complaint {
|
||||
id: string;
|
||||
trackingNumber: string;
|
||||
|
|
@ -110,7 +111,7 @@ export default function TableController({
|
|||
<TableHead>دستگاه مربوطه</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody className="bg-[#F5F5F5]">
|
||||
<TableBody className="bg-[#F5F5F5] min-h-[20rem] ">
|
||||
{data?.map((item: Complaint, index: number) => {
|
||||
return (
|
||||
<TableRow
|
||||
|
|
@ -120,7 +121,7 @@ export default function TableController({
|
|||
`/UserPanel/ControllerDashboard/Complaints/${item.id}`
|
||||
);
|
||||
}}
|
||||
className=" hover:bg-gray-200 cursor-pointer"
|
||||
className="cursor-pointer hover:bg-gray-200"
|
||||
key={item.id}
|
||||
>
|
||||
{/* <Link
|
||||
|
|
@ -149,6 +150,15 @@ export default function TableController({
|
|||
</TableRow>
|
||||
);
|
||||
})}
|
||||
{data.length != 0 &&
|
||||
[...Array(5 - data.length)].map(() => {
|
||||
return (
|
||||
<TableRow
|
||||
key={Math.random()}
|
||||
className="border border-t-0 border-b-0"
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</TableBody>
|
||||
</Table>
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
|
|
@ -174,7 +184,7 @@ export default function TableController({
|
|||
checked={check}
|
||||
onCheckedChange={setCheck}
|
||||
id="terms"
|
||||
className=" ml-2"
|
||||
className="ml-2 "
|
||||
/>
|
||||
<label
|
||||
htmlFor="terms"
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ export default function TopNav() {
|
|||
</svg>
|
||||
</div>
|
||||
|
||||
<Search mode="landing" />
|
||||
</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
|
||||
ref={ref}
|
||||
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
|
||||
)}
|
||||
{...props}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "sootzani",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.5",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "sootzani",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.5",
|
||||
"dependencies": {
|
||||
"@hookform/resolvers": "^3.3.2",
|
||||
"@radix-ui/react-alert-dialog": "^1.0.5",
|
||||
|
|
@ -56,6 +56,7 @@
|
|||
"react-leaflet": "^4.2.1",
|
||||
"react-loader-spinner": "^6.1.6",
|
||||
"react-otp-input": "^3.1.1",
|
||||
"react-paginate": "^8.1.3",
|
||||
"react-quill": "^2.0.0",
|
||||
"react-responsive": "^9.0.2",
|
||||
"react-secure-storage": "^1.3.2",
|
||||
|
|
@ -7951,6 +7952,17 @@
|
|||
"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": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/react-quill/-/react-quill-2.0.0.tgz",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "sootzani",
|
||||
"version": "0.2.3",
|
||||
"version": "0.2.5",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev",
|
||||
|
|
@ -57,6 +57,7 @@
|
|||
"react-leaflet": "^4.2.1",
|
||||
"react-loader-spinner": "^6.1.6",
|
||||
"react-otp-input": "^3.1.1",
|
||||
"react-paginate": "^8.1.3",
|
||||
"react-quill": "^2.0.0",
|
||||
"react-responsive": "^9.0.2",
|
||||
"react-secure-storage": "^1.3.2",
|
||||
|
|
|
|||
|
|
@ -160,9 +160,17 @@ export async function UpdateWebContents({
|
|||
}
|
||||
|
||||
// .....News.................................................
|
||||
export async function GetAllNews() {
|
||||
const data = await axios.get("api/News");
|
||||
return data.data;
|
||||
export async function GetAllNews({
|
||||
PageNumber = 1,
|
||||
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 }) {
|
||||
|
|
@ -171,7 +179,7 @@ export async function GetSingleNews({ id }: { id: string }) {
|
|||
}
|
||||
|
||||
export async function SubmitNews(payload: FormData) {
|
||||
const data = await axios.post("api/News", payload , {
|
||||
const data = await axios.post("api/News", payload, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return data.data;
|
||||
|
|
@ -184,7 +192,7 @@ export async function UpdateNews({
|
|||
id: string;
|
||||
payload: FormData;
|
||||
}) {
|
||||
const data = await axios.put(`api/News/${id}`, payload , {
|
||||
const data = await axios.put(`api/News/${id}`, payload, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return data.data;
|
||||
|
|
@ -207,7 +215,7 @@ export async function GetSingleSlider({ id }: { id: string }) {
|
|||
}
|
||||
|
||||
export async function SubmitSlider(payload: FormData) {
|
||||
const data = await axios.post("api/Sliders", payload , {
|
||||
const data = await axios.post("api/Sliders", payload, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return data.data;
|
||||
|
|
@ -220,7 +228,7 @@ export async function UpdateSlider({
|
|||
id: string;
|
||||
payload: FormData;
|
||||
}) {
|
||||
const data = await axios.put(`api/Sliders/${id}`, payload , {
|
||||
const data = await axios.put(`api/Sliders/${id}`, payload, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return data.data;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ import {
|
|||
|
||||
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
||||
|
||||
let isRefreshing = false;
|
||||
|
||||
axios.interceptors.response.use(
|
||||
(response) => {
|
||||
return response;
|
||||
|
|
@ -15,21 +17,37 @@ axios.interceptors.response.use(
|
|||
async function (error) {
|
||||
console.log(error);
|
||||
const originalRequest = error.config;
|
||||
|
||||
if (error.response.status === 401) {
|
||||
if (!originalRequest._retry) {
|
||||
originalRequest._retry = true;
|
||||
const accessToken = getCookie("Sootzani_Token");
|
||||
const refreshToken = getCookie("Sootzani_Refresh_Token");
|
||||
|
||||
if (accessToken && refreshToken && !isRefreshing) {
|
||||
isRefreshing = true;
|
||||
|
||||
try {
|
||||
// Perform token refresh
|
||||
const data = await RefreshToken({
|
||||
token: accessToken,
|
||||
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);
|
||||
}
|
||||
);
|
||||
|
|
@ -97,6 +115,16 @@ export async function editProfile(payload: {
|
|||
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 }) {
|
||||
try {
|
||||
const response = await axios.post("api/Authenticate/Refresh", payload);
|
||||
|
|
|
|||
|
|
@ -20,16 +20,20 @@ export async function getPossibleStates() {
|
|||
export async function getComplaintsList({
|
||||
states = 0,
|
||||
TrackingNumber,
|
||||
PageNumber = 1,
|
||||
PageSize = 5,
|
||||
}: {
|
||||
states: number;
|
||||
TrackingNumber?: string;
|
||||
PageNumber?: number;
|
||||
PageSize?: number;
|
||||
}) {
|
||||
// export async function getComplaintsList() {
|
||||
// const data = await axios.get(`api/Inspector/List`);
|
||||
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: {
|
||||
|
|
|
|||
Loading…
Reference in New Issue