+
{/* 1 */}
-
-
- افزودن کلید جدید
-
-
-
+
@@ -277,150 +289,79 @@ export default function AdminKeysManagement() {
-
-
- ایجاد جفت کلید جدید
-
-
- {isNewKeyLoading ? (
-
-
-
- ) : (
-
-
- {" "}
- ایجاد جفت کلید
-
- {isNewKeyLoading ? (
-
-
-
- ) : (
-
-
-
- کلید عمومی :
-
- {/*
- {data2?.publicKey}
-
*/}
-
-
-
-
- کلید خصوصی :
-
- {/*
- {data2?.privateKey}
-
*/}
-
-
-
- )}
-
- )}
-
+
افزودن کلید جدید
-
-
+
+ {" "}
+ ایجاد جفت کلید
+
+
+
@@ -428,74 +369,84 @@ export default function AdminKeysManagement() {
{/* Continue */}
-
- {/* 2 */}
-
- لیست کلیدها
-
-
- {data1?.map((item: any) => {
- return (
-
+
+ لیست کلیدها
+
+
+
-
- عنوان کلید :
- {item.title}
-
-
- آی دی بازرس :
-
- {item.inspectorId}
-
-
+ افزودن کلید جدید
+
+
+
+
+ {data1?.map((item: any) => {
+ return (
+
+
+ عنوان کلید:{" "}
+ {item.title}
+
+
+ آیدی بازرس:{" "}
+
+ {item.inspectorId}
+
+
-
-
- {/* Show Dialog */}
- setKeyId(item?.id)}
- />
-
-
-
- تغییر کلید
-
-
-
-
-
-
- تغییر کلید
-
+
+
+ تغییر کلید
+
- {/*
تغییر کلید
*/}
-
- بستن
-
-
-
-
-
-
-
- {/* Continue */}
-
-
-
-
- );
- })}
-
+
+ بستن
+
+
+
+
+
+
+
+ {/* Continue */}
+
+
+
+
+ );
+ })}
+
+
);
diff --git a/components/ComplainsDetails.tsx b/components/ComplainsDetails.tsx
index 10c7572..05f5bd0 100644
--- a/components/ComplainsDetails.tsx
+++ b/components/ComplainsDetails.tsx
@@ -1,5 +1,5 @@
"use client";
-import React, { useEffect } from "react";
+import React, { useEffect, useState } from "react";
import greenIcon from "../public/img/greenPoint.svg";
import blueIcon from "../public/img/bluepoint.svg";
import Image from "next/image";
@@ -7,13 +7,28 @@ import { ComplainDetailsItems } from "@/constants";
import { useMutation } from "@tanstack/react-query";
import { OperateByInspector, getComplaint } from "@/utils/inspectorApi";
import useData from "@/store/useData";
-import { convertDate } from "@/lib/utils";
+import { Decrypt, convertDate } from "@/lib/utils";
import { Badge } from "./ui/badge";
import InspectorOperations from "./InspectorOperations";
-import { postComplaintTracking } from "@/utils/citizenApi";
-import { ArrowDownToLine, File } from "lucide-react";
+import { ArrowDownToLine, ArrowRight, File } from "lucide-react";
import { Separator } from "./ui/separator";
-
+import secureLocalStorage from "react-secure-storage";
+import { Checkbox } from "./ui/checkbox";
+import { Button } from "@/components/ui/button";
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+ DialogTrigger,
+} from "@/components/ui/dialog";
+import { Input } from "./ui/input";
+import { toast } from "sonner";
+import { useRouter } from "next/navigation";
+import { Triangle } from "react-loader-spinner";
export default function ComplainsDetails({
id,
role,
@@ -24,46 +39,44 @@ export default function ComplainsDetails({
Data?: any;
}) {
const storeData = useData((state) => state.data);
+ const [open, setOpen] = useState
(true);
+ const [check, setCheck] = useState(false);
+ const [complaintData, setComplaintData] = useState("");
+ const [selectedFile, setSelectedFile] = useState(null);
+ const [key, setKey] = useState(null);
+ const router = useRouter();
let data;
- const getComplaintMutation = useMutation<
- any,
- Error,
- { trackingNumber: string; password: string }
- >({
+ const getComplaintMutation = useMutation({
mutationKey: ["Complaint", id],
- mutationFn:
- role == "Inspector"
- ? (getComplaint as any)
- : (postComplaintTracking as any),
+ mutationFn: getComplaint,
onSuccess: (res) => {},
onError: (err) => {},
});
- console.log(storeData);
-
useEffect(() => {
- if (role == "Inspector") {
- useData.persist.rehydrate();
+ const tn = localStorage.getItem("trackingNumber") as string;
+ const pw = localStorage.getItem("privateKey") as string;
+ console.log(tn, pw);
+ if (tn != null && pw != null) {
+ getComplaintMutation.mutate({
+ trackingNumber: tn as string,
+ password: pw,
+ });
+ setOpen(false);
}
}, []);
+
useEffect(() => {
- if (storeData && role == "Inspector") {
- getComplaintMutation.mutate(storeData);
- }
- }, [storeData]);
+ const storedData = localStorage.getItem("CompliantData");
+ const data = JSON.parse(storedData as string);
+ setComplaintData(data);
+ }, []);
+
if (getComplaintMutation.isSuccess) {
data = getComplaintMutation.data;
- } else if (Data) {
- data = Data;
}
- const handleOpenFile = (file) => {
- const fileURL = URL.createObjectURL(
- new Blob([atob(file.data)], { type: file.mimeType })
- );
- window.open(fileURL, "_blank");
- };
const openFileInNewTab = (base64Data: any, fileType: any) => {
const blob = b64toBlob(base64Data, fileType);
const blobUrl = URL.createObjectURL(blob);
@@ -127,136 +140,232 @@ export default function ComplainsDetails({
return new Blob(byteArrays, { type: contentType });
};
- console.log(Data);
+
+ const handleFileChange = (event: any) => {
+ const file = event.target.files[0];
+ const reader = new FileReader();
+ reader.onload = (e) => {
+ const contents = e?.target?.result;
+ setSelectedFile(contents);
+ };
+ reader.readAsText(file);
+ };
+
+ const checkKey2 = (item: any) => {
+ const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
+ console.log(dcKey);
+ if (dcKey != false && dcKey != null) {
+ if (check) {
+ localStorage.setItem("trackingNumber", item.trackingNumber);
+ localStorage.setItem("privateKey", dcKey);
+ }
+ setKey(dcKey);
+ getComplaintMutation.mutate({
+ trackingNumber: item.trackingNumber,
+ password: dcKey as string,
+ });
+ setOpen(false);
+ } else {
+ toast("کلید شما معتبر نمی باشد.", {
+ className: "!bg-red-500 !text-white",
+ });
+ }
+ };
+
+ data = getComplaintMutation?.data;
return (
<>
- {data ? (
-
-
-
-
گزارش شکایت
-
-
- موضوع شکایت:{" "}
-
- {data.title}
-
+
+
+
+ بارگذاری کلید خصوصی
+
+ برای مشاهده شکایت لطفا کلید خود را آپلود نمایید.
+
+
+
+
+
+
+
+
+ ذخیره کلید برای دفعات بعد
+
+
+
+ {/* */}
+ {
+ router.push("/UserPanel/Complaints");
+ }}
+ type="submit"
+ >
+ بازگشت
+
+ {
+ checkKey2(complaintData);
+ }}
+ type="submit"
+ >
+ ذخیره
+
+
+
+
+ {getComplaintMutation.data && !getComplaintMutation.isPending ? (
+ <>
+ router.push("/UserPanel/Complaints")}
+ className=" my-2 flex gap-1 cursor-pointer text-blue "
+ >
+
+
+
+ بازگشت
+
+
+
+
+
+ گزارش شکایت
-
- دستگاه مربوطه:{" "}
-
- {/* {data.title} */}
-
-
-
- پرسنل مربوطه:{" "}
-
- {/* {data.title} */}
-
-
-
- زمان ثبت:{" "}
-
- {convertDate(data.registeredAt)}
-
-
- {/*
- {" "}
- موضوع شکایت:{" "}
-
- متن تستی
-
-
*/}
+
+
+ موضوع شکایت:{" "}
+
+ {data?.title}
+
+
+
+ دستگاه مربوطه:{" "}
+
+ {data?.complaintOrganization
+ ? data?.complaintOrganization.title
+ : "-"}
+
+
+
+ پرسنل مربوطه:{" "}
+
+ {data.complaining ? data.complaining : "-"}
+
+
+
+ زمان ثبت:{" "}
+
+ {convertDate(data.registeredAt)}
+
+
+
+
+
+
+ انجام عملیات
+
+
getComplaintMutation.mutate(data)}
+ role={role}
+ complaintData={data}
+ id={id}
+ key2={key}
+ />
- {/*
- درخواست شما با کد رهگیری {data.trackingNumber} و رمز عبور 12422 در
- دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن
- 0353286545 جهت پشتیبانی تماس حاصل کنید.{" "}
-
*/}
-
+
+
روند شکایت
+
+ {data.contents?.map((item: any) => {
+ return (
+
+
+
+ {item.sender == 0 ? "شهروند" : "بازرس"}
+
+
+ تاریخ :
+
+ {convertDate(item.dateTime)}
+
+
+
+
+
+ {item.text ? item.text : "-"}
+
+
+ {item.media.length !== 0 && (
+
+ )}
+
+
+ {item?.media.map((item: any) => {
+ return (
+
+ );
+ })}
+
+
+
+ );
+ })}
+
+
+
انجام عملیات
getComplaintMutation.mutate(storeData)}
+ updateData={(data) => getComplaintMutation.mutate(data)}
role={role}
complaintData={data}
+ id={id}
+ key={key}
/>
-
-
-
روند شکایت
-
- {data.contents?.map((item: any) => {
- return (
-
-
-
- {item.sender == 0 ? "شهروند" : "بازرس"}
-
-
- تاریخ :
-
- {convertDate(item.dateTime)}
-
-
-
-
-
- {item.text ? item.text : "-"}
-
-
- {item.media.length !== 0 &&
}
-
-
- {item?.media.map((item: any) => {
- return (
-
- );
- })}
-
-
-
- );
- })}
-
-
-
-
- انجام عملیات
-
-
getComplaintMutation.mutate(storeData)}
- role={role}
- complaintData={data}
- />
-
- {/* Left */}
- {/*
+ {/* Left */}
+ {/*
وضعیت درخواست
@@ -294,9 +403,24 @@ export default function ComplainsDetails({
);
})}
*/}
-
+
+ >
) : (
- ""
+ <>
+ {getComplaintMutation.isPending && (
+
+
+
+ )}
+ >
)}
>
);
diff --git a/components/FollowResult.tsx b/components/FollowResult.tsx
deleted file mode 100644
index d730fb4..0000000
--- a/components/FollowResult.tsx
+++ /dev/null
@@ -1,214 +0,0 @@
-"use client";
-import React, { useEffect, useState, useRef } from "react";
-import Image from "next/image";
-import Resultimg from "../public/img/followResult.png";
-import Link from "next/link";
-import { useRouter } from "next/navigation";
-import { ThreeDots } from "react-loader-spinner";
-
-import {
- AlertDialog,
- AlertDialogAction,
- AlertDialogCancel,
- AlertDialogContent,
- AlertDialogDescription,
- AlertDialogFooter,
- AlertDialogHeader,
- AlertDialogTitle,
- AlertDialogTrigger,
-} from "@/components/ui/alert-dialog";
-import { Button } from "@/components/ui/button";
-import { IoMdClose } from "react-icons/io";
-import { postComplaintTracking } from "@/utils/citizenApi";
-import { useMutation } from "@tanstack/react-query";
-import { useReactToPrint } from "react-to-print";
-
-import "../app/print-styles.css";
-import ComplainsDetails from "./ComplainsDetails";
-
-export default function FollowResult() {
- const router = useRouter();
- const [trackingNumber, setTrackingNumber] = useState
();
- const [password, setPassword] = useState();
- const [complaintData, setComplaintData] = useState();
- const [printStyle, setPrintStyle] = useState(true);
-
- // Print component Data
- const componentRef = useRef(null);
- const handlePrint = useReactToPrint({
- content: () => componentRef.current,
- // onBeforePrint() {
- // setPrintStyle(!printStyle);
- // },
- // onAfterPrint() {
- // setPrintStyle(!printStyle)
- // },
- });
-
- useEffect(() => {
- setTrackingNumber(localStorage.getItem("trackingNumber2"));
- setPassword(localStorage.getItem("password2"));
- }, []);
-
- useEffect(() => {
- if (trackingNumber && password) {
- complaintPrintMutation.mutate({
- Data: { trackingNumber: trackingNumber, password: password },
- });
- }
- }, [trackingNumber, password]);
-
- const complaintPrintMutation = useMutation({
- mutationKey: ["complaintPrint"],
- mutationFn: postComplaintTracking,
- onSuccess: (res) => {
- setComplaintData(res);
- },
- onError: (error) => {
- console.log(error);
- console.log(error?.message);
- },
- });
-
- function onSubmit() {
- console.log("SuccessPrinttttttttttt");
-
- // complaintPrintMutation.mutate({
- // Data: { trackingNumber: trackingNumber, password: password },
- // });
- }
- // const possibleOperations = complaintPrintMutation.data?.possibleOperations;
- // const selectOptions = Operations.filter((item, index) =>
- // possibleOperations.includes(index)
- // );
-
- const printableContent = "This is the content to be printed.";
- console.log(complaintPrintMutation?.data);
- return (
- <>
-
- {/*
*/}
- {/*
- درخواست شما با کد رهگیری
- {`${trackingNumber}`} و
- رمز عبور
- {`${password}`}
- در دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن
- 0353286545 جهت پشتیبانی تماس حاصل کنید.
-
*/}
- {complaintPrintMutation?.data ? (
- <>
-
-
-
- onSubmit()}
- className="w-fit bg-blue text-white p-2 rounded-xl text-center"
- >
- پرینت درخواست
-
-
-
-
-
-
-
- گزارش شکایات
-
-
-
-
-
-
-
-
- {complaintPrintMutation.isPending ? (
-
-
-
- ) : (
-
-
- {" "}
- موضوع شکایت:{" "}
-
- {`${complaintData?.title}`}
-
-
-
- {" "}
- متن شکایت:{" "}
-
- {`${complaintData?.contents[0]?.text}`}
-
-
-
-
-
- {" "}
- جزئیات شکایت:
-
-
-
- درخواست شما با کد رهگیری
- {`${trackingNumber}`}
- و رمز عبور
- {`${password}`}
- در دست بررسی و اقدام می باشد. در صورت تمایل می
- توانید با شماره تلفن 0353286545 جهت پشتیبانی تماس
- حاصل کنید.
-
-
- )}
-
-
-
-
- پرینت گزارش
-
-
-
-
-
-
- >
- ) : (
- ""
- )}
-
- {/*
*/}
- {/*
*/}
-
- >
- );
-}
diff --git a/components/InspectorOperations.tsx b/components/InspectorOperations.tsx
index 0b5feee..0e05cd3 100644
--- a/components/InspectorOperations.tsx
+++ b/components/InspectorOperations.tsx
@@ -29,36 +29,34 @@ import {
} from "@/components/ui/select";
import { Operations } from "@/constants";
import useData from "@/store/useData";
-import { useMutation } from "@tanstack/react-query";
+import { useMutation, useQueryClient } from "@tanstack/react-query";
import { OperateByInspector } from "@/utils/inspectorApi";
import { toast } from "sonner";
-import { postComplaintsDetails } from "@/utils/citizenApi";
+import secureLocalStorage from "react-secure-storage";
+import { Decrypt } from "@/lib/utils";
export default function InspectorOperations({
complaintData,
role,
updateData,
+ id,
+ key2,
}: {
complaintData: any;
role: string;
- updateData: () => any;
+ updateData: (data: any) => any;
+ id: any;
+ key2: any;
}) {
const FormSchema = z.object({
- text: z
- .string({ required_error: "لطفا متن خود را وارد نمایید." })
- .min(8, {
- message: "Bio must be at least 8 characters.",
- })
- .max(260, {
- message: "Bio must not be longer than 30 characters.",
- }),
+ text: z.string({ required_error: "لطفا متن خود را وارد نمایید." }),
...(role == "Inspector" && {
type: z.enum(["private", "public"], {
required_error: "لطفا وضعیت عملیات را انتخاب نمایید.",
}),
}),
operation: z.string({
- required_error: "Please select an email to display.",
+ required_error: "لطفا نوع عملیات را انتخاب نمایید.",
}),
media: z
.custom((val) => val instanceof FileList, "Required")
@@ -67,33 +65,39 @@ export default function InspectorOperations({
.nullish(),
});
const password = useData((state) => state.data.password);
- const possibleOperations = complaintData?.possibleOperations;
- const selectOptions = Operations.filter((item, index) =>
- possibleOperations.includes(index)
- );
+ const possibleOperations = complaintData?.possibleOperationsWithDescription;
+ const queryClient = useQueryClient();
+ console.log(possibleOperations);
const form = useForm>({
resolver: zodResolver(FormSchema),
defaultValues: {
operation:
- selectOptions.length == 1 ? String(selectOptions[0].value) : undefined,
+ possibleOperations.length == 1
+ ? String(possibleOperations[0].value)
+ : undefined,
+ text: "",
},
});
const OperationMutation = useMutation({
mutationKey: ["Operation"],
- mutationFn:
- role == "Inspector" ? OperateByInspector : postComplaintsDetails,
+ mutationFn: OperateByInspector,
onSuccess: (res) => {
toast("عملیات شما با موفقیت انجام شد. ", {
className: "!bg-green-500 !text-white",
});
+ const tk = localStorage.getItem("trackingNumber");
+ updateData({ trackingNumber: tk, password: key2 });
},
onError: (err) => {},
});
function onSubmit(data: z.infer) {
- console.log(data);
+ const storedData = JSON.parse(localStorage.getItem("CompliantData"));
+ console.log(storedData);
+ console.log(key2);
+ const dcKey = Decrypt(storedData.cipherKeyInspector, key2);
const formData = new FormData();
formData.append("text", data.text);
formData.append("trackingNumber", complaintData.trackingNumber);
@@ -101,11 +105,7 @@ export default function InspectorOperations({
if (data.type) {
formData.append("IsPublic", data.type == "public" ? "true" : "false");
}
- if (role == "Inspector") {
- formData.append("EncodedKey", password);
- } else {
- formData.append("password", localStorage.getItem("password2") as string);
- }
+ formData.append("EncodedKey", key2);
if (data?.media && data?.media?.length > 0) {
for (let i = 0; i < data.media.length; i++) {
formData.append("Medias", data.media[i]);
@@ -221,10 +221,10 @@ export default function InspectorOperations({
عملیات
- {selectOptions.map((item) => {
+ {possibleOperations.map((item) => {
return (
- {item.name}
+ {item.description}
);
})}
diff --git a/components/Login.tsx b/components/Login.tsx
index 077f051..7fb5327 100644
--- a/components/Login.tsx
+++ b/components/Login.tsx
@@ -70,6 +70,7 @@ export default function Login() {
});
function onSubmit(data: z.infer) {
+ refetch();
const payload = {
username: data.username,
password: data.password,
@@ -90,7 +91,7 @@ export default function Login() {
: null;
return (
-
+
("");
+
useEffect(() => {
const userRole = localStorage.getItem("Sootzani_Role");
setRole(userRole);
}, []);
- console.log(role);
+ const { data, isLoading, refetch } = useQuery({
+ queryKey: ["Profile"],
+ queryFn: () => getProfile(),
+ refetchOnWindowFocus: false,
+ });
+
const menus = {
Admin: AdminMenuItems,
Inspector: ControllerMenuItems,
};
const selectedMenu = menus[role as keyof typeof menus];
+
return (
-
- پنل کاربری |
+
+
+
+
+ پنل کاربری {| }
-
+
+ {isOpen && (
+
+
+ {selectedMenu.map((item, idx, array) => {
+ // const { Icon } = item;
+ const lastItem = array.length - 1;
+ return (
+
+ setOpen((prev) => !prev)}
+ className={`flex items-center justify-between w-full p-3 rounded-xl text-white
+ ${lastItem === idx ? "bg-blue" : "bg-blue"} `}
+ href={item.href}
+ >
+ {item.name}
+ {/* */}
+
+
+ );
+ })}
+
+
+ )}
+
+
{role && (
<>
{selectedMenu.map(
@@ -50,28 +116,28 @@ export default function NavbarPanel() {
)}
>
)}
-
- {/* {AdminMenuItems.map((item) => {
- return (
-
-
- {item.name}
-
-
- );
- })} */}
-
-
- {role === "Admin"
- ? "نام و نام خانوادگی (ادمین)"
- : "نام و نام خانوادگی (بازرس)"}
-
+
+
+ {data && (
+ <>
+ {role === "Admin"
+ ? `${data?.title ? data.title : data.username} (ادمین)`
+ : `${data?.title ? data.title : data.username} (بازرس)`}
+ >
+ )}
+
+
+ {
+ deleteCookie("Sootzani_Token");
+ router.push("/");
+ }}
+ className=" text-white "
+ />
+
+
);
}
diff --git a/components/TabController.tsx b/components/TabController.tsx
index 5abc336..24096c8 100644
--- a/components/TabController.tsx
+++ b/components/TabController.tsx
@@ -68,130 +68,90 @@ export default function TabController() {
const finishedComplaints = data?.filter((item: any) => item.status == 4);
console.log(newComplaints);
return (
-
-
-
-
- + بارگذاری کلید جدید
-
-
-
-
- {/* Tab Title */}
-
-
- لیست شکایت ها |
-
+
+
+ لیست شکایت ها
+
+
+
+ {/* Tab Title */}
+
+
+ لیست شکایت ها |
+
-
- جدید
-
-
- در انتظار پاسخ
-
-
- در حال بررسی
-
-
- پاسخ داده شده
-
-
- پایان یافته
-
-
+
+ جدید
+
+
+ در انتظار پاسخ
+
+
+ در حال بررسی
+
+
+ پاسخ داده شده
+
+
+ پایان یافته
+
+
- {/* Search Box */}
-
-
+ {/* Search Box */}
+
+
- {/* Tab Content */}
-
- checkKey(item)}
- data={newComplaints}
- />
-
+ {/* Tab Content */}
+
+ checkKey(item)}
+ data={newComplaints}
+ />
+
-
- checkKey(item)}
- data={waitingForCitizenResponseComplaints}
- />
-
+
+ checkKey(item)}
+ data={waitingForCitizenResponseComplaints}
+ />
+
-
- checkKey(item)}
- data={inProgressComplaints}
- />
-
+
+ checkKey(item)}
+ data={inProgressComplaints}
+ />
+
-
- checkKey(item)}
- data={citizenRepliedComplaints}
- />
-
+
+ checkKey(item)}
+ data={citizenRepliedComplaints}
+ />
+
-
- checkKey(item)}
- data={finishedComplaints}
- />
-
-
-
-
- بارگذاری کلید خصوصی
-
- لطفا کلید خصوصی خود را آپلود نمایید.
-
-
-
- {/* Picture */}
-
-
-
-
- {
- toast("کلید شما با موفقیت ذخیره شد.", {
- className: "!bg-green-500 !text-white",
- });
- }}
- type="submit"
- >
- ذخیره
-
-
-
-
-
+
+ checkKey(item)}
+ data={finishedComplaints}
+ />
+
+
);
}
diff --git a/components/TableController.tsx b/components/TableController.tsx
index 6872a45..74fbfa5 100644
--- a/components/TableController.tsx
+++ b/components/TableController.tsx
@@ -28,6 +28,8 @@ import { Input } from "./ui/input";
import { useRouter } from "next/navigation";
import { toast } from "sonner";
import { ScrollArea } from "./ui/scroll-area";
+import secureLocalStorage from "react-secure-storage";
+import { Checkbox } from "./ui/checkbox";
interface Complaint {
id: string;
trackingNumber: string;
@@ -53,8 +55,8 @@ export default function TableController({
const saveData = useData((state) => state.saveData);
const [selectedFile, setSelectedFile] = useState(null);
const [open, setOpen] = useState(false);
- const [roData, setRowData] = useState(false);
-
+ const [rowData, setRowData] = useState(null);
+ const [check, setCheck] = useState(false);
const router = useRouter();
const handleFileChange = (event: any) => {
@@ -62,13 +64,13 @@ export default function TableController({
const reader = new FileReader();
reader.onload = (e) => {
const contents = e?.target?.result;
- // Process the contents of the file here
setSelectedFile(contents);
console.log(contents);
};
reader.readAsText(file);
};
+
const checkKey2 = (item: any) => {
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
if (dcKey != false && dcKey != null) {
@@ -76,11 +78,16 @@ export default function TableController({
trackingNumber: item.trackingNumber,
password: Decrypt(item.cipherKeyInspector, selectedFile),
});
+ secureLocalStorage.setItem("trackingNumber", item.trackingNumber);
+ secureLocalStorage.setItem(
+ "privateKey",
+ Decrypt(item.cipherKeyInspector, selectedFile)
+ );
router.push(`/UserPanel/ControllerDashboard/Complaints/${item.id}`);
} else {
}
};
-
+ console.log(check);
return (
@@ -97,13 +104,12 @@ export default function TableController({
{data?.map((item: Complaint, index: number) => {
return (
checkKey(item)
- // saveData({
- // trackingNumber: item.trackingNumber,
- // password: Decrypt(item.cipherKeyInspector),
- // })
- }
+ onClick={() => {
+ localStorage.setItem("CompliantData", JSON.stringify(item));
+ router.push(
+ `/UserPanel/ControllerDashboard/Complaints/${item.id}`
+ );
+ }}
className=" hover:bg-gray-200 cursor-pointer"
key={item.id}
>
@@ -145,19 +151,25 @@ export default function TableController({
accept=".txt"
/>
+
+
+
+ ذخیره کلید برای دفعات بعد
+
+
-
- {
- if (selectedFile) {
- toast("کلید شما با موفقیت بارگذاری شد.");
- }
- }}
- type="submit"
- >
- ذخیره
-
-
+
+ checkKey2(rowData)} type="submit">
+ ذخیره
+
diff --git a/components/Verify.tsx b/components/Verify.tsx
index 6fe2683..866bbf2 100644
--- a/components/Verify.tsx
+++ b/components/Verify.tsx
@@ -69,7 +69,7 @@ export default function Verify() {
}, []);
return (
-
diff --git a/components/ui/checkbox.tsx b/components/ui/checkbox.tsx
new file mode 100644
index 0000000..df61a13
--- /dev/null
+++ b/components/ui/checkbox.tsx
@@ -0,0 +1,30 @@
+"use client"
+
+import * as React from "react"
+import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
+import { Check } from "lucide-react"
+
+import { cn } from "@/lib/utils"
+
+const Checkbox = React.forwardRef<
+ React.ElementRef,
+ React.ComponentPropsWithoutRef
+>(({ className, ...props }, ref) => (
+
+
+
+
+
+))
+Checkbox.displayName = CheckboxPrimitive.Root.displayName
+
+export { Checkbox }
diff --git a/lib/utils.ts b/lib/utils.ts
index 390ec1a..9b28f42 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -19,22 +19,7 @@ export function convertDate(date: string) {
return convertedDate;
}
-export function Decrypt(encryptedData: string , privateKey: string) {
- const Key = `-----BEGIN RSA PRIVATE KEY-----
-MIICXAIBAAKBgQCfmb1aGcWsqJPp+v6e72CPngE6P6FoCZCJESwDTXUXiJiAKshB
-WZ9nlN+IIpQr6h8gmxi8SWbofPWmSKZgTyU2MddxUanneuywPTTUj4HQ6/DUaDwF
-0Vr6Fk0x4yi1GKpBzhRFPyOYBWVXKIw23j0l+EWw6+JIpR9Kwu0TezHHFQIDAQAB
-AoGBAIVxegy3t7vhR6s/HV2uMEJkjgox4banKJ4yKWapgNmocDnZi454bPuiUjP1
-FYaSPmx4wXnMtap1sL7Tx6iHBEi10KB1AghDZP5wJHz6nm9ugcrGSSWhVJM74x6C
-ThVztAV/rydaZ6/DLaqsBg5lHlo1DjMKq4sxnqrw/LUMGtOBAkEAzt8bnM1Ij/rF
-i8oSP3gI0H914vf/0N2xxGGdQvMmJK0oijIm5j8dFDZf02Ft34SFeVJfXyVPapDE
-vQ6TRw+1HQJBAMWAwvbypbtl65Dn4qCj3oJUmmnjjxm5080idF1S6ufo34p2gHMF
-qLtWjmnGqjh2Shs7ahnfbLF+cxzgBg7yEFkCQFYGl1/0Sel9uepwpHf6PYgeiPJS
-ePHtTwBAK3pszH7R9xrI0j5LHpeKKP0o9dzOKgcShxB03nqNKxMHXZ1eXc0CQFhD
-Ot3xgm9FFQklF/qCQSYtePRpZcIxcZ3zD93E+IW7ZGsUmkLM/KL8A5jx15B0DJou
-6zO0zXZk9DyrQQnc08ECQGy5ti89HmQ6I6Wqq5ADglCY6YPISsNwScVyvu/WxQsX
-dEqG/38xFdYTFEekexcHnT/Vt1MW4/j76vBJHYWuAJU=
------END RSA PRIVATE KEY-----`;
+export function Decrypt(encryptedData: any, privateKey: any) {
const decryptor = new JSEncrypt();
decryptor.setPrivateKey(privateKey);
const decrypted = decryptor.decrypt(encryptedData);
diff --git a/package-lock.json b/package-lock.json
index 0546aa3..63985fa 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,6 +10,7 @@
"dependencies": {
"@hookform/resolvers": "^3.3.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
+ "@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
@@ -53,6 +54,7 @@
"react-loader-spinner": "^6.1.6",
"react-otp-input": "^3.1.1",
"react-responsive": "^9.0.2",
+ "react-secure-storage": "^1.3.2",
"react-spinners": "^0.13.8",
"react-to-print": "^2.14.15",
"react-use": "^17.4.2",
@@ -581,6 +583,36 @@
}
}
},
+ "node_modules/@radix-ui/react-checkbox": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.0.4.tgz",
+ "integrity": "sha512-CBuGQa52aAYnADZVt/KBQzXrwx6TqnlwtcIPGtVt5JkkzQwMOLJjPukimhfKEr4GQNd43C+djUh5Ikopj8pSLg==",
+ "dependencies": {
+ "@babel/runtime": "^7.13.10",
+ "@radix-ui/primitive": "1.0.1",
+ "@radix-ui/react-compose-refs": "1.0.1",
+ "@radix-ui/react-context": "1.0.1",
+ "@radix-ui/react-presence": "1.0.1",
+ "@radix-ui/react-primitive": "1.0.3",
+ "@radix-ui/react-use-controllable-state": "1.0.1",
+ "@radix-ui/react-use-previous": "1.0.1",
+ "@radix-ui/react-use-size": "1.0.1"
+ },
+ "peerDependencies": {
+ "@types/react": "*",
+ "@types/react-dom": "*",
+ "react": "^16.8 || ^17.0 || ^18.0",
+ "react-dom": "^16.8 || ^17.0 || ^18.0"
+ },
+ "peerDependenciesMeta": {
+ "@types/react": {
+ "optional": true
+ },
+ "@types/react-dom": {
+ "optional": true
+ }
+ }
+ },
"node_modules/@radix-ui/react-collection": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.0.3.tgz",
@@ -2312,6 +2344,11 @@
"node": ">= 8"
}
},
+ "node_modules/crypto-js": {
+ "version": "4.2.0",
+ "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
+ "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q=="
+ },
"node_modules/css-color-keywords": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz",
@@ -4302,6 +4339,11 @@
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
},
+ "node_modules/murmurhash-js": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/murmurhash-js/-/murmurhash-js-1.0.0.tgz",
+ "integrity": "sha512-TvmkNhkv8yct0SVBSy+o8wYzXjE4Zz3PCesbfs8HiCXXdcTuocApFv11UWlNFWKYsP2okqrhb7JNlSm9InBhIw=="
+ },
"node_modules/mz": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
@@ -7802,6 +7844,15 @@
"react": ">=16.8.0"
}
},
+ "node_modules/react-secure-storage": {
+ "version": "1.3.2",
+ "resolved": "https://registry.npmjs.org/react-secure-storage/-/react-secure-storage-1.3.2.tgz",
+ "integrity": "sha512-pNCyksbLXWIYRS9vCzERXdIMErtx9Ik70TPtLKivcq44+zYybbxA72wpp5ivghK9Xe0gRku2w/7zBy/9n+RtKA==",
+ "dependencies": {
+ "crypto-js": "^4.1.1",
+ "murmurhash-js": "^1.0.0"
+ }
+ },
"node_modules/react-spinners": {
"version": "0.13.8",
"resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.13.8.tgz",
diff --git a/package.json b/package.json
index 588cf87..3960206 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,7 @@
"dependencies": {
"@hookform/resolvers": "^3.3.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
+ "@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-icons": "^1.3.0",
@@ -54,6 +55,7 @@
"react-loader-spinner": "^6.1.6",
"react-otp-input": "^3.1.1",
"react-responsive": "^9.0.2",
+ "react-secure-storage": "^1.3.2",
"react-spinners": "^0.13.8",
"react-to-print": "^2.14.15",
"react-use": "^17.4.2",
diff --git a/utils/authenticateApi.ts b/utils/authenticateApi.ts
index 00c3b2c..411ad34 100644
--- a/utils/authenticateApi.ts
+++ b/utils/authenticateApi.ts
@@ -1,7 +1,7 @@
import axios from "axios";
import { CookieValueTypes } from "cookies-next";
-axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
+axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
export async function loginStaff(payload: {
username: string;
diff --git a/utils/citizenApi.ts b/utils/citizenApi.ts
deleted file mode 100644
index 482f1fd..0000000
--- a/utils/citizenApi.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import axios from "axios";
-import { CookieValueTypes } from "cookies-next";
-
-axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
-
-// Post Complaints
-export async function postComplaintSubmit({ Data }: { Data: FormData }) {
- const data = await axios.post(`api/Citizen`, Data);
- return data.data;
-}
-
-// Post 1 Complaints
-export async function postComplaintTracking({
- Data,
-}: {
- Data: { trackingNumber: string; password: string };
-}) {
- const data = await axios.post(`api/Citizen/Get`, Data);
- return data.data;
-}
-
-// Post Complaints Details "citizen / Oprate"
-export async function postComplaintsDetails(payload: FormData) {
- const data = await axios.post(`api/Citizen/Operate`, payload);
- return data.data;
-}