ComplaintDetails Modified + Bugs Fixed

Kahdooie
yasaman 2024-01-26 16:46:50 +03:30
parent 24350884fd
commit dae4ec5264
7 changed files with 148 additions and 90 deletions

View File

@ -5,7 +5,7 @@ export default function page({ params }: { params: any }) {
const id = params.id; const id = params.id;
return ( return (
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] mt-10 sm:mt-8 pt-9 mx-auto mb-10"> <div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] mt-10 sm:mt-8 pt-9 mx-auto mb-6">
<ComplainsDetails role="Inspector" id={id} /> <ComplainsDetails role="Inspector" id={id} />
</div> </div>
); );

View File

@ -214,10 +214,18 @@ export default function AdminCategories() {
description: data.description, description: data.description,
}); });
} }
const resetFormAdd = () => {
formAdd.reset({
titleCategory: "",
description: "",
});
};
return ( return (
<div className="w-full min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<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 items-center justify-between w-full ">
{/* 1 */} {/* 1 */}
<div className="w-full my-4 text-lg font-bold text-right text-neutral-600"> <div className="w-full my-4 text-lg font-bold text-right text-neutral-600">
لیست دسته بندی ها لیست دسته بندی ها
@ -242,7 +250,7 @@ export default function AdminCategories() {
<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" onClick={() => { resetFormAdd(); }}>
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -307,7 +315,7 @@ export default function AdminCategories() {
> >
افزودن افزودن
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl" onClick={() => { resetFormAdd(); }}>
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>

View File

@ -71,6 +71,7 @@ const FormSchemaAddKey = z.object({
}), }),
}); });
export default function AdminKeysManagement() { export default function AdminKeysManagement() {
const router = useRouter(); const router = useRouter();
const [keyId, setKeyId] = useState(""); const [keyId, setKeyId] = useState("");
@ -253,6 +254,15 @@ export default function AdminKeysManagement() {
saveTextFile(); saveTextFile();
} }
}, [AddKeyMutation.isSuccess]); }, [AddKeyMutation.isSuccess]);
const resetFormAdd = () => {
formAdd.reset({
title: "",
publicKey: "",
});
};
return ( return (
<div className="w-full min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<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 ">
@ -264,7 +274,7 @@ export default function AdminKeysManagement() {
<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" onClick={() => { resetFormAdd(); }}>
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>

View File

@ -325,10 +325,18 @@ export default function AdminNews() {
} }
}, [data1]); }, [data1]);
const resetFormAdd = () => {
formAdd.reset({
titleNews: "",
urlNews: "",
content: "",
description: "",
});
};
return ( return (
<div className="w-full min-h-[85vh] flex justify-center py-4"> <div className="w-full min-h-[85vh] flex justify-center pb-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 items-center justify-between w-full ">
{/* 1 */} {/* 1 */}
<div className="w-full my-4 text-lg font-bold text-right text-neutral-600"> <div className="w-full my-4 text-lg font-bold text-right text-neutral-600">
لیست خبر ها لیست خبر ها
@ -353,7 +361,7 @@ export default function AdminNews() {
<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" onClick={() => { resetFormAdd(); }}>
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -506,7 +514,7 @@ export default function AdminNews() {
> >
افزودن افزودن
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl" onClick={() => { resetFormAdd(); }}>
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>

View File

@ -217,10 +217,17 @@ export default function AdminOrganizations() {
description: data.description, description: data.description,
}); });
} }
const resetFormAdd = () => {
formAdd.reset({
titleOrg: "",
description: "",
});
};
return ( return (
<div className="w-full min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<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 items-center justify-between w-full ">
{/* 1 */} {/* 1 */}
<div className="w-full my-4 text-lg font-bold text-right text-neutral-600"> <div className="w-full my-4 text-lg font-bold text-right text-neutral-600">
لیست سازمان ها لیست سازمان ها
@ -245,7 +252,7 @@ export default function AdminOrganizations() {
<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" onClick={() => { resetFormAdd(); }}>
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -310,7 +317,7 @@ export default function AdminOrganizations() {
> >
افزودن افزودن
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl" onClick={() => { resetFormAdd(); }}>
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>

View File

@ -250,12 +250,21 @@ const AddSliderMutation = useMutation({
setOpenAdd(false); setOpenAdd(false);
refetch1(); refetch1();
resetField("Title");
resetField("Image");
resetField("Url");
resetField("Description");
toast("عملیات شما با موفقیت انجام شد. ", { toast("عملیات شما با موفقیت انجام شد. ", {
className: "!bg-green-500 !text-white", className: "!bg-green-500 !text-white",
}); });
}, },
onError: (err: any | string) => { onError: (err: any | string) => {
resetField("Title");
resetField("Image");
resetField("Url");
resetField("Description");
toast(<>{err.response.data.detail}</>, { toast(<>{err.response.data.detail}</>, {
className: "!bg-red-500 !text-white", className: "!bg-red-500 !text-white",
}); });
@ -297,14 +306,25 @@ function onSubmitAdd(data: AddSliderFormValues) {
} }
AddSliderMutation.mutate(formData); AddSliderMutation.mutate(formData);
resetField("Title");
resetField("Image");
resetField("Url");
resetField("Description");
} }
const resetFormAdd = () => {
formAdd.reset({
titleSlider: "",
uploadImg: null,
urlSlider: "",
description: "",
});
};
return ( return (
<div className="w-full min-h-[85vh] flex justify-center"> <div className="w-full min-h-[85vh] flex justify-center">
<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 items-center justify-between w-full ">
{/* 1 */} {/* 1 */}
<div className="w-full my-4 text-lg font-bold text-right text-neutral-600"> <div className="w-full my-4 text-lg font-bold text-right text-neutral-600">
لیست اسلایدرها لیست اسلایدرها
@ -329,7 +349,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
<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" onClick={() => { resetFormAdd(); }}>
<IoMdClose /> <IoMdClose />
</AlertDialogCancel> </AlertDialogCancel>
</AlertDialogTitle> </AlertDialogTitle>
@ -465,7 +485,7 @@ function onSubmitAdd(data: AddSliderFormValues) {
> >
افزودن افزودن
</Button> </Button>
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl"> <AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl" onClick={() => { resetFormAdd(); }}>
بستن بستن
</AlertDialogCancel> </AlertDialogCancel>
</div> </div>

View File

@ -49,8 +49,6 @@ export default function ComplainsDetails({
const router = useRouter(); const router = useRouter();
let data; let data;
const getComplaintMutation = useMutation({ const getComplaintMutation = useMutation({
mutationKey: ["Complaint", id], mutationKey: ["Complaint", id],
mutationFn: getComplaint, mutationFn: getComplaint,
@ -272,7 +270,7 @@ export default function ComplainsDetails({
<div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col"> <div className="flex items-start w-full gap-2 mt-2 max-lg:flex-col">
{/* 1 */} {/* 1 */}
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28 lg:h-[78vh]"> <div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28 lg:h-[80vh]">
<div className=" max-lg:hidden bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col lg:h-full"> <div className=" max-lg:hidden bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col lg:h-full">
<p className="text-[#464646] text-base font-bold mb-1"> <p className="text-[#464646] text-base font-bold mb-1">
انجام عملیات انجام عملیات
@ -408,76 +406,83 @@ export default function ComplainsDetails({
</> </>
)} )}
</div> </div>
<div className="bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col "> <div className="h-[calc(80vh-12.8em)] max-h-[calc(80vh-12.8em)] overflow-hidden">
<p className="text-[#464646] text-base font-bold">روند شکایت</p> <div className="bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col h-full ">
<div <p className="text-[#464646] text-base font-bold">
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" </p>
> <div
{data.contents?.map((item: any) => { className="flex flex-col mt-4 gap-y-4 overflow-auto
return ( scrollbar-thin scrollbar-thumb-gray-500 scrollbar-track-gray-100 "
<div >
key={item.id} {data.contents?.map((item: any) => {
className="p-4 bg-white rounded-lg shadow-md " return (
> <div
<div className="flex items-center gap-4 "> key={item.id}
<p className=""> className="p-4 bg-white rounded-lg shadow-md "
<Badge> >
{item.sender == 0 ? "شهروند" : "بازرس"} <div className="flex items-center gap-4 ">
</Badge> <p className="">
</p> <Badge>
<p className=""> {item.sender == 0 ? "شهروند" : "بازرس"}
تاریخ : </Badge>
</p>
<p className="">
تاریخ :
<span className="text-[#7C838A]">
{convertDate(item.dateTime)}
</span>
</p>
</div>
<div className=" text-[#464646] mt-2">
<span className="text-[#7C838A]"> <span className="text-[#7C838A]">
{convertDate(item.dateTime)} {item.text ? item.text : "-"}
</span> </span>
</p> </div>
</div> {item.media.length !== 0 && (
<div className=" text-[#464646] mt-2"> <Separator className="mt-2 mb-1 " />
<span className="text-[#7C838A]"> )}
{item.text ? item.text : "-"} <div className=" text-[#464646] mt-2">
</span> <div className="flex flex-wrap items-center w-full gap-2 mt-2 text-xs max-md:flex-col">
</div> {item?.media.map((item: any, index: number) => {
{item.media.length !== 0 && ( return (
<Separator className="mt-2 mb-1 " /> <div
)} key={index}
<div className=" text-[#464646] mt-2"> className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center"
<div className="flex flex-wrap items-center w-full gap-2 mt-2 text-xs max-md:flex-col">
{item?.media.map((item: any, index: number) => {
return (
<div
key={index}
className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center"
>
<a
onClick={() =>
openFileInNewTab(item.data, item.mimeType)
}
className="flex items-center gap-2 truncate cursor-pointer "
> >
<File className="w-6 h-6 " /> <a
<p className=" max-w-[5rem] truncate"> onClick={() =>
{item.title} openFileInNewTab(
</p> item.data,
</a> item.mimeType
<ArrowDownToLine )
className="cursor-pointer " }
onClick={() => className="flex items-center gap-2 truncate cursor-pointer "
downloadFile( >
item.data, <File className="w-6 h-6 " />
item.title, <p className=" max-w-[5rem] truncate">
item.mimeType {item.title}
) </p>
} </a>
/> <ArrowDownToLine
</div> className="cursor-pointer "
); onClick={() =>
})} downloadFile(
item.data,
item.title,
item.mimeType
)
}
/>
</div>
);
})}
</div>
</div> </div>
</div> </div>
</div> );
); })}
})} </div>
</div> </div>
</div> </div>
</div> </div>