diff --git a/components/AdminWebContents.tsx b/components/AdminWebContents.tsx index b70f2dd..ea4af67 100644 --- a/components/AdminWebContents.tsx +++ b/components/AdminWebContents.tsx @@ -9,7 +9,6 @@ import { getContents } from "@/utils/commonApi"; import { toast } from "sonner"; export default function AdminWebContents() { - const [contentValueCall, setContentValueCall] = useState(""); const [contentValueAbout, setContentValueAbout] = useState(""); const [contentValueAfter, setContentValueAfter] = useState(""); @@ -25,7 +24,7 @@ export default function AdminWebContents() { const [contentTitle, setContentTitle] = useState(""); const [contentDesc, setContentDesc] = useState(""); - + var toolbarOptions = [ ["bold", "italic", "underline", "strike"], // toggled buttons ["blockquote", "code-block"], @@ -75,40 +74,38 @@ export default function AdminWebContents() { queryFn: () => getContents(), refetchOnWindowFocus: false, }); - - + useEffect(() => { // if (isInitialRender2 && isSuccess1) { - if (isSuccess1) { + if (isSuccess1) { // { - data1?.map((item: any) => { - if (item.title === "CallUs") { - setContentValueCall(item.content); - setCallId(item.id); - setCallBtn("Edit"); - } + data1?.map((item: any) => { + if (item.title === "CallUs") { + setContentValueCall(item.content); + setCallId(item.id); + setCallBtn("Edit"); + } - if (item.title === "AboutUs") { - setContentValueAbout(item.content); - setAboutId(item.id); - setAboutBtn("Edit"); - } + if (item.title === "AboutUs") { + setContentValueAbout(item.content); + setAboutId(item.id); + setAboutBtn("Edit"); + } - if (item.title === "AfterRegistration") { - setContentValueAfter(item.content); - setAfterId(item.id); - setAfterBtn("Edit"); - } + if (item.title === "AfterRegistration") { + setContentValueAfter(item.content); + setAfterId(item.id); + setAfterBtn("Edit"); + } - if (item.title === "BeforeRegistration") { - setContentValueBefore(item.content); - setBeforeId(item.id); - setBeforeBtn("Edit"); - } - }); + if (item.title === "BeforeRegistration") { + setContentValueBefore(item.content); + setBeforeId(item.id); + setBeforeBtn("Edit"); + } + }); } - }, [isSuccess1 , refetch1]); - + }, [isSuccess1, refetch1]); // Add // ............'Mutation' Change Key Submit @@ -131,7 +128,6 @@ export default function AdminWebContents() { className: "!bg-red-500 !text-white", }); refetch1(); - }, }); @@ -140,7 +136,6 @@ export default function AdminWebContents() { mutationKey: ["EditWebContents"], mutationFn: UpdateWebContents, onSuccess: (res) => { - toast("عملیات ویرایش شما با موفقیت انجام شد . ", { className: "!bg-green-500 !text-white", }); @@ -216,7 +211,7 @@ export default function AdminWebContents() { formData.append("title", "AfterRegistration"); formData.append("description", "AfterRegistration...."); formData.append("Content", contentValueAfter); - EditWebContents.mutate({ id: afterId, payload: formData }); + EditWebContents.mutate({ id: afterId, payload: formData }); } function onEditBeforeText() { @@ -229,7 +224,7 @@ export default function AdminWebContents() { return (
-
+
{/* Cull Us */}
@@ -269,8 +264,8 @@ export default function AdminWebContents() {
+ {/* BeforeRegistration*/} +
+
+ محتوای قبل از ثبت گزارش +
+ + + +
+ {/* AfterRegistration */}
@@ -297,7 +320,7 @@ export default function AdminWebContents() { @@ -315,34 +338,6 @@ export default function AdminWebContents() { ثبت
- - {/* BeforeRegistration*/} -
-
- محتوای قبل از ثبت گزارش -
- - - -
); diff --git a/components/AttachmentsDialog.tsx b/components/AttachmentsDialog.tsx index e4f1dcc..c015500 100644 --- a/components/AttachmentsDialog.tsx +++ b/components/AttachmentsDialog.tsx @@ -7,53 +7,101 @@ import { DialogTitle, DialogTrigger, } from "@/components/ui/dialog"; + +import { + AlertDialog, + AlertDialogAction, + AlertDialogCancel, + AlertDialogContent, + AlertDialogDescription, + AlertDialogFooter, + AlertDialogHeader, + AlertDialogTitle, + AlertDialogTrigger, +} from "@/components/ui/alert-dialog"; + import { X } from "lucide-react"; +import { Button } from "./ui/button"; export default function AttachmentsDialog({ children, attachments, deleteFile, + deleteAllAttachmentsFiles, }: { children: React.ReactNode; attachments: File[] | []; deleteFile: (file: any) => void; + deleteAllAttachmentsFiles: () => void; }) { return ( {children} - - - پیوست‌ها - - {attachments.length == 0 ? ( -
هیج پیوستی وجود ندارد.
- ) : ( -
- {attachments?.map((item, index) => { - return ( -
-
- {index + 1} -
-
-
-

{item.name}

-
+ + + + پیوست‌ها + + {attachments.length != 0 && ( + + {" "} + + )} - deleteFile(item.name)} - className=" cursor-pointer hover:drop-shadow-md" - /> + {attachments.length == 0 ? ( +
هیج پیوستی وجود ندارد.
+ ) : ( +
+ {attachments?.map((item, index) => { + return ( +
+
+ {index + 1} +
+
+
+

+ {item.name} +

+
+ + deleteFile(item.name)} + className=" cursor-pointer hover:drop-shadow-md" + /> +
-
- ); - })} -
- )} - - + ); + })} +
+ )} + + + + + آیا میخواهید همه ی فایل ها را حذف کنید؟ + + + + + + لغو + + deleteAllAttachmentsFiles()} + > + تایید + + + + + +
); diff --git a/components/ComplainsDetails.tsx b/components/ComplainsDetails.tsx index b47c983..2049d90 100644 --- a/components/ComplainsDetails.tsx +++ b/components/ComplainsDetails.tsx @@ -90,7 +90,11 @@ export default function ComplainsDetails({ data = getComplaintMutation.data; } - const openFileInNewTab = (base64Data: any, fileType: any) => { + const openFileInNewTab = ( + base64Data: any, + fileType: any, + fileName?: string + ) => { const blob = b64toBlob(base64Data, fileType); const blobUrl = URL.createObjectURL(blob); const newTab = window.open(); @@ -109,9 +113,7 @@ export default function ComplainsDetails({ `` ); } else { - newTab.document.write( - `Open in New Tab` - ); + downloadFile(base64Data, fileName, fileType); } newTab.document.write(""); @@ -261,7 +263,7 @@ export default function ComplainsDetails({
{/* 1 */}
-
+

انجام عملیات

@@ -276,7 +278,7 @@ export default function ComplainsDetails({
{/* 2 */}
-
+
{data.user == null ? ( <>
@@ -290,7 +292,7 @@ export default function ComplainsDetails({

- دستگاه مربوطه:{" "} + دستگاه مرتبط:{" "} {data?.complaintOrganization ? data?.complaintOrganization.title @@ -298,7 +300,7 @@ export default function ComplainsDetails({

- فرد مربوطه:{" "} + فرد مرتبط:{" "} {data.complaining ? data.complaining : "-"} @@ -338,7 +340,7 @@ export default function ComplainsDetails({

- دستگاه مربوطه:{" "} + دستگاه مرتبط:{" "} {data?.complaintOrganization ? data?.complaintOrganization.title @@ -346,7 +348,7 @@ export default function ComplainsDetails({

- فرد مربوطه:{" "} + فرد مرتبط:{" "} {data.complaining ? data.complaining : "-"} @@ -419,9 +421,9 @@ export default function ComplainsDetails({ )}

-
+

- روند شکایت + روند رسیدگی گزارش{" "}

+ openFileInNewTab( + item.data, + item.mimeType, + item.title + ) + } > - - openFileInNewTab( - item.data, - item.mimeType - ) - } - className="flex items-center gap-2 truncate cursor-pointer " - > + -

+

{item.title}

- downloadFile( @@ -483,7 +484,7 @@ export default function ComplainsDetails({ item.mimeType ) } - /> + /> */}
); })} diff --git a/components/InspectorOperations.tsx b/components/InspectorOperations.tsx index 56d8cf9..54c1dd2 100644 --- a/components/InspectorOperations.tsx +++ b/components/InspectorOperations.tsx @@ -154,6 +154,11 @@ export default function InspectorOperations({ } OperationMutation.mutate(formData); } + const deleteAllAttachmentsFiles = () => { + setFile([]); + // @ts-expect-error + form.setValue("media", []); + }; const deleteFileFromAttachments = (File: any) => { const filtered = file?.filter((item) => item.name !== File); @@ -187,7 +192,7 @@ export default function InspectorOperations({