Bugs fixed
parent
82ebc3c611
commit
24350884fd
|
|
@ -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,71 +692,85 @@ 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]
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
<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
|
||||||
<span className=" text-slate-800">{item.title}</span>
|
alt="picture"
|
||||||
</p>
|
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
|
||||||
توضیحات:
|
|
||||||
<span className="self-end text-slate-800">
|
|
||||||
{item.description}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<p className="text-sm font-normal leading-normal text-slate-500">
|
|
||||||
محتوا:
|
|
||||||
<span className="self-end text-slate-800">
|
|
||||||
{item.content}
|
|
||||||
</span>
|
|
||||||
</p>
|
|
||||||
<Image
|
|
||||||
alt="img"
|
|
||||||
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${item?.image?.url}`}
|
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${item?.image?.url}`}
|
||||||
width={100}
|
height={500}
|
||||||
height={100}
|
width={500}
|
||||||
quality={100}
|
quality={100}
|
||||||
className="object-contain object-right w-full h-20 "
|
className="w-full h-full rounded-r-lg bg-cover object-cover"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
<div className="flex items-end justify-end w-full gap-2">
|
<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">
|
||||||
<Switch
|
<div>
|
||||||
dir="ltr"
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
checked={!item.isDeleted}
|
عنوان :
|
||||||
onCheckedChange={() => {
|
<span className=" text-slate-800">{item.title}</span>
|
||||||
DeleteNewsMutation.mutate({id: item.id});
|
</p>
|
||||||
}}
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
id={item.id}
|
توضیحات:
|
||||||
/>
|
<span className="self-end text-slate-800 line-clamp-2">
|
||||||
|
{item.description}
|
||||||
<AlertDialogTrigger asChild>
|
</span>
|
||||||
{/* <Button variant="outline">Show Dialog</Button> */}
|
</p>
|
||||||
<FaRegEdit
|
<p className="text-sm font-normal leading-normal text-slate-500">
|
||||||
aria-hidden="true"
|
محتوا:
|
||||||
className="self-end w-6 h-6 text-slate-600 hover:cursor-pointer"
|
<span className="self-end text-slate-800">
|
||||||
// onClick={() => setKeyId(item?.id)}
|
{item.content}
|
||||||
onClick={() =>
|
</span>
|
||||||
handleClickEdit(
|
</p>
|
||||||
item?.id,
|
</div>
|
||||||
item?.title,
|
<div className="flex items-end justify-end w-full gap-2">
|
||||||
item?.description,
|
<Switch
|
||||||
item?.content,
|
dir="ltr"
|
||||||
item?.url,
|
checked={!item.isDeleted}
|
||||||
item?.image
|
onCheckedChange={() => {
|
||||||
)
|
DeleteNewsMutation.mutate({ id: item.id });
|
||||||
}
|
}}
|
||||||
|
id={item.id}
|
||||||
/>
|
/>
|
||||||
</AlertDialogTrigger>
|
|
||||||
|
<AlertDialogTrigger asChild>
|
||||||
|
{/* <Button variant="outline">Show Dialog</Button> */}
|
||||||
|
<FaRegEdit
|
||||||
|
aria-hidden="true"
|
||||||
|
className="self-end w-6 h-6 text-slate-600 hover:cursor-pointer"
|
||||||
|
// onClick={() => setKeyId(item?.id)}
|
||||||
|
onClick={() =>
|
||||||
|
handleClickEdit(
|
||||||
|
item?.id,
|
||||||
|
item?.title,
|
||||||
|
item?.description,
|
||||||
|
item?.content,
|
||||||
|
item?.url,
|
||||||
|
item?.image
|
||||||
|
)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</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,23 +642,22 @@ 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">
|
||||||
توضیحات:
|
توضیحات:
|
||||||
<span className="self-end text-slate-800">
|
<span className="self-end text-slate-800">
|
||||||
{item.description}
|
{item.description}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
<Image
|
<Image
|
||||||
alt="img"
|
alt="img"
|
||||||
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${item?.image?.url}`}
|
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${item?.image?.url}`}
|
||||||
width={100}
|
width={100}
|
||||||
height={100}
|
height={100}
|
||||||
quality={100}
|
quality={100}
|
||||||
className="object-contain object-right w-full h-20 "
|
className="object-contain object-right w-full h-20 "
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{/* <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}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,7 @@ export default function ComplainsDetails({
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* 2 */}
|
{/* 2 */}
|
||||||
<div className="flex flex-col self-stretch w-full gap-2 rounded-lg lg:w-2/3 ">
|
<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">
|
<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 ? (
|
{data.user == null ? (
|
||||||
|
|
@ -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
|
||||||
|
|
@ -461,7 +481,7 @@ export default function ComplainsDetails({
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/* 3 */}
|
{/* 3 */}
|
||||||
<div className=" lg:hidden order-2 w-full bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col mt-2">
|
<div className=" lg:hidden order-2 w-full bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col mt-2">
|
||||||
<p className="text-[#464646] text-base font-bold mb-1">
|
<p className="text-[#464646] text-base font-bold mb-1">
|
||||||
انجام عملیات
|
انجام عملیات
|
||||||
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -7,51 +7,34 @@ import { twMerge } from "tailwind-merge";
|
||||||
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
|
const items = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14];
|
||||||
|
|
||||||
export default function Pagination({
|
export default function Pagination({
|
||||||
itemsPerPage,
|
currentPage,
|
||||||
|
PageSize,
|
||||||
Page,
|
Page,
|
||||||
countPage,
|
countPage,
|
||||||
length,
|
length,
|
||||||
}: {
|
}: {
|
||||||
itemsPerPage?: any;
|
currentPage?: any;
|
||||||
|
PageSize?: number;
|
||||||
Page?: any;
|
Page?: any;
|
||||||
countPage?: any;
|
countPage?: any;
|
||||||
length?: 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 handlePageClick = (event: any) => {
|
||||||
const newOffset = (event.selected * itemsPerPage) % items.length;
|
console.log(event.selected);
|
||||||
console.log(
|
|
||||||
`User requested page number ${event.selected}, which is offset ${newOffset}`
|
|
||||||
);
|
|
||||||
setItemOffset(newOffset);
|
|
||||||
// console.log(event.selected);
|
|
||||||
console.log(event);
|
|
||||||
Page(event.selected);
|
Page(event.selected);
|
||||||
};
|
};
|
||||||
console.log(countPage);
|
console.log(countPage);
|
||||||
// console.log(pageCount, "1111");
|
// console.log(pageCount, "1111");
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{/* <Items currentItems={currentItems} /> */}
|
|
||||||
<ReactPaginate
|
<ReactPaginate
|
||||||
breakLabel="..."
|
breakLabel="..."
|
||||||
onPageActive={(e) => console.log(e)}
|
onPageActive={(e) => console.log(e)}
|
||||||
nextLabel={<MdKeyboardArrowLeft className="w-5 h-5 " />}
|
nextLabel={<MdKeyboardArrowLeft className="w-5 h-5 " />}
|
||||||
onPageChange={handlePageClick}
|
onPageChange={handlePageClick}
|
||||||
pageRangeDisplayed={3}
|
pageRangeDisplayed={3}
|
||||||
pageCount={Math.ceil(countPage / 5)}
|
forcePage={currentPage}
|
||||||
|
pageCount={Math.ceil(countPage / (PageSize ? PageSize : 5))}
|
||||||
previousLabel={<MdKeyboardArrowRight className="w-5 h-5 " />}
|
previousLabel={<MdKeyboardArrowRight className="w-5 h-5 " />}
|
||||||
pageClassName=" w-10 h-10 grid place-content-center rounded-lg !text-blue shadow-md"
|
pageClassName=" w-10 h-10 grid place-content-center rounded-lg !text-blue shadow-md"
|
||||||
className={twMerge(
|
className={twMerge(
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ export default function TabController() {
|
||||||
};
|
};
|
||||||
|
|
||||||
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,
|
||||||
|
|
@ -97,11 +97,19 @@ export default function TabController() {
|
||||||
setTotalCount(headersData.TotalCount);
|
setTotalCount(headersData.TotalCount);
|
||||||
}
|
}
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
useEffect(() => {
|
||||||
|
const activeTab = localStorage.getItem("ActiveTab");
|
||||||
|
if (activeTab) {
|
||||||
|
setSelectedTab(activeTab);
|
||||||
|
setPsblState(Number(activeTab));
|
||||||
|
}
|
||||||
|
}, []);
|
||||||
|
|
||||||
const isZero = totalCount === 0;
|
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 xl:hidden">
|
<p className="my-2 text-xs font-bold 3xl:ml-6 sm:text-sm">
|
||||||
لیست شکایت ها
|
لیست شکایت ها
|
||||||
</p>
|
</p>
|
||||||
<Tabs
|
<Tabs
|
||||||
|
|
@ -118,9 +126,9 @@ export default function TabController() {
|
||||||
<div className="flex flex-col-reverse items-center justify-between w-full gap-4 mb-10 lg:flex-row lg:gap-2">
|
<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 h-a max-lg:flex-wrap max lg:w-4/5 md:gap-4 lg:gap-1 p-1">
|
<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 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;
|
||||||
|
|
@ -133,6 +141,8 @@ export default function TabController() {
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setPsblState(item.value);
|
setPsblState(item.value);
|
||||||
setSelectedTab(String(item.value));
|
setSelectedTab(String(item.value));
|
||||||
|
localStorage.setItem("ActiveTab", String(item.value));
|
||||||
|
|
||||||
refetch();
|
refetch();
|
||||||
setPage(0);
|
setPage(0);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -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 }) {
|
||||||
|
|
@ -171,7 +179,7 @@ export async function GetSingleNews({ id }: { id: string }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function SubmitNews(payload: FormData) {
|
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" },
|
headers: { "Content-Type": "multipart/form-data" },
|
||||||
});
|
});
|
||||||
return data.data;
|
return data.data;
|
||||||
|
|
@ -184,7 +192,7 @@ export async function UpdateNews({
|
||||||
id: string;
|
id: string;
|
||||||
payload: FormData;
|
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" },
|
headers: { "Content-Type": "multipart/form-data" },
|
||||||
});
|
});
|
||||||
return data.data;
|
return data.data;
|
||||||
|
|
@ -207,7 +215,7 @@ export async function GetSingleSlider({ id }: { id: string }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function SubmitSlider(payload: FormData) {
|
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" },
|
headers: { "Content-Type": "multipart/form-data" },
|
||||||
});
|
});
|
||||||
return data.data;
|
return data.data;
|
||||||
|
|
@ -220,7 +228,7 @@ export async function UpdateSlider({
|
||||||
id: string;
|
id: string;
|
||||||
payload: FormData;
|
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" },
|
headers: { "Content-Type": "multipart/form-data" },
|
||||||
});
|
});
|
||||||
return data.data;
|
return data.data;
|
||||||
|
|
|
||||||
|
|
@ -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,26 +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) {
|
||||||
originalRequest.url == "api/Authenticate/Profile"
|
if (!originalRequest._retry) {
|
||||||
) {
|
originalRequest._retry = true;
|
||||||
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) {
|
if (accessToken && refreshToken && !isRefreshing) {
|
||||||
const data = await RefreshToken({
|
isRefreshing = true;
|
||||||
token: accessToken,
|
|
||||||
refreshToken: refreshToken,
|
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;
|
// For other errors or if refresh token logic is not applicable
|
||||||
// const access_token = await refreshAccessToken();
|
|
||||||
// axios.defaults.headers.common["Authorization"] = "Bearer " + access_token;
|
|
||||||
// return axiosApiInstance(originalRequest);
|
|
||||||
// }
|
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue