Bugs Fixed

Kahdooie
Hossein Rahmani 2024-01-04 23:01:14 +03:30
parent 4eba3d1c16
commit c423d5ef84
21 changed files with 836 additions and 947 deletions

View File

@ -1,16 +1,22 @@
import NavbarPanel from "@/components/NavbarPanel";
import { cookies } from "next/headers";
import { redirect } from "next/navigation";
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<>
<NavbarPanel />
{children}
</>
)
children,
}: {
children: React.ReactNode;
}) {
const cookieStore = cookies();
const token = cookieStore.get("Sootzani_Token");
if (!token?.value) {
return redirect("/");
}
return (
<>
<NavbarPanel />
{children}
</>
);
}

View File

@ -1,8 +1,7 @@
import AdminDashboard from "@/components/AdminDashboard";
import ControllerDashboard from "@/components/ControllerDashboard";
import React from "react";
export default function page() {
return (
<AdminDashboard />
);
return <ControllerDashboard />;
}

View File

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

View File

@ -6,11 +6,12 @@ export default function RootLayout({
}: {
children: React.ReactNode;
}) {
// const cookieStore = cookies();
// const token = cookieStore.get("Sootzani-Token");
// if (!token.value) {
// return redirect("/");
// }
const cookieStore = cookies();
const token = cookieStore.get("Sootzani_Token");
if (!token?.value) {
return redirect("/");
}
return (
<>
<NavbarPanel />

View File

@ -20,9 +20,9 @@ export default function RootLayout({
}) {
return (
<html lang="fa" dir="rtl">
<body className="font-[yekan] ">
<body className="font-[yekan] bg-white">
<Provider>
{children}
{children}
<Toaster />
<SonnerToaster />
</Provider>

View File

@ -12,12 +12,12 @@ export default function AdminDashboard() {
<div className="w-full mb-6 flex flex-col gap-4 ">
<div className="w-full md:h-36 flex flex-row max-md:flex-wrap justify-center md:justify-between gap-3 ">
{/* <BoxDashboard />
<BoxDashboard />
<BoxDashboard />
<BoxDashboard />
<BoxDashboard />
<BoxDashboard />
<BoxDashboard />
<BoxDashboard /> */}
</div>
<div className="w-full flex flex-col md:flex-row gap-12 md:gap-1 ">
@ -26,7 +26,7 @@ export default function AdminDashboard() {
</div>
<hr />
<div className="w-full md:w-2/3 h-full flex justify-center">
<VerticalChart />
{/* <VerticalChart /> */}
</div>
</div>
</div>

View File

@ -36,6 +36,7 @@ import { toast } from "sonner";
import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import * as z from "zod";
import { Textarea } from "./ui/textarea";
const MAX_FILE_SIZE = 5242880; // 5 MB
// Edit Key Form
@ -76,8 +77,8 @@ export default function AdminKeysManagement() {
const [openAdd, setOpenAdd] = React.useState(false);
const [openEdit, setOpenEdit] = React.useState(false);
const inputPubRef = useRef<HTMLInputElement | null>(null);
const inputPrvRef = useRef<HTMLInputElement | null>(null);
const inputPubRef = useRef<HTMLTextAreaElement | null>(null);
const inputPrvRef = useRef<HTMLTextAreaElement | null>(null);
// ..............Read .txt
const [selectedFile, setSelectedFile] = useState<any>(null);
@ -138,17 +139,10 @@ export default function AdminKeysManagement() {
console.log("bcbcbbcbcbccc" + selectedFile);
console.log("bcbcbbcbcbccccc" + data1[0]?.id);
// if (keyId) {
ChangeKeyMutation.mutate({
privateKey: selectedFile,
publicKeyId: keyId,
// publicKeyId: data1?.id,
});
// }
// else{
// console.error("keyId is undefined");
// }
}
// Add Form
@ -210,6 +204,7 @@ export default function AdminKeysManagement() {
error: Error1,
isLoading: isListLoading,
refetch: refetch1,
isSuccess: isSuccess1,
} = useQuery({
queryKey: ["KeysList"],
queryFn: () => GetKeys(),
@ -223,6 +218,7 @@ export default function AdminKeysManagement() {
error: Error2,
isLoading: isNewKeyLoading,
refetch: refetch2,
isSuccess: isSuccess2,
} = useQuery({
queryKey: ["GenerateKey"],
queryFn: () => GenerateKeyPair(),
@ -236,6 +232,11 @@ export default function AdminKeysManagement() {
refetch2();
console.log(data2);
};
useEffect(() => {
if (isSuccess2) {
formAdd.setValue("publicKey", data2?.publicKey);
}
}, [isSuccess2]);
useEffect(() => {
if (inputPubRef.current && inputPrvRef.current) {
@ -244,28 +245,39 @@ export default function AdminKeysManagement() {
}
}, [handleClickGenerate]);
const saveTextFile = () => {
const textToSave = data2?.privateKey ?? "";
const fileName = "privateKey.txt";
const handleClickAddKey = () => {
// refetch2();
console.log(data1);
// Create a Blob containing the file data
const blob = new Blob([textToSave], { type: "text/plain" });
// Create a link element
const link = document.createElement("a");
// Set the download attribute and create a URL for the Blob
link.download = fileName;
link.href = window.URL.createObjectURL(blob);
// Append the link to the document and trigger the click event
document.body.appendChild(link);
link.click();
// Remove the link from the document
document.body.removeChild(link);
};
useEffect(() => {
if (AddKeyMutation.isSuccess) {
saveTextFile();
}
}, [AddKeyMutation.isSuccess]);
return (
<div className="w-full bg-[#F5F5F5] 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 ">
{/* 1 */}
<AlertDialog open={openAdd} onOpenChange={setOpenAdd}>
<AlertDialogTrigger asChild>
<Button
variant="outline"
onClick={handleClickAddKey}
className="bg-orange-500 text-white"
// disabled={isNewKeyLoading}
>
افزودن کلید جدید
</Button>
</AlertDialogTrigger>
<AlertDialogContent className=" w-full max-w-6xl h-full max-h-[90vh] lg:max-h-[70vh]">
<AlertDialogContent className=" ">
<AlertDialogHeader>
<AlertDialogTitle>
<p className="text-[#464646] text-base font-bold">
@ -277,150 +289,79 @@ export default function AdminKeysManagement() {
</AlertDialogTitle>
<AlertDialogDescription>
<div className="w-full ">
<div className="w-full text-right text-neutral-600 text-lg font-bold mb-4">
ایجاد جفت کلید جدید
</div>
{isNewKeyLoading ? (
<div className="felx justify-center items-center self-center">
<ThreeDots
visible={true}
height="50"
width="100"
color="#003778"
radius="9"
ariaLabel="three-dots-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
) : (
<div>
<Button
variant="outline"
onClick={handleClickGenerate}
disabled={isNewKeyLoading}
className="my-2"
>
{" "}
ایجاد جفت کلید
</Button>
{isNewKeyLoading ? (
<div className="felx justify-center items-center self-center h-full">
<ThreeDots
visible={true}
height="20"
width="50"
color="#003778"
radius="9"
ariaLabel="three-dots-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
) : (
<div
className="flex flex-row flex-wrap justify-between"
id="KeyFetch"
>
<div className=" w-full lg:w-[48%]">
<p className="text-[#7C838A] text-sm font-semibold">
کلید عمومی :
</p>
{/* <p className="text-slate-700 text-sm text-left mb-4">
{data2?.publicKey}
</p> */}
<Input
name="pubKey"
ref={inputPubRef}
// value={data2?.publicKey}
readOnly={true}
className="text-slate-700 text-sm text-left mb-4 w-full bg-white"
/>
</div>
<div className=" w-full lg:w-[48%]">
<p className="text-[#7C838A] text-sm font-semibold">
کلید خصوصی :
</p>
{/* <p className="text-slate-700 text-sm text-left mb-4">
{data2?.privateKey}
</p> */}
<Input
ref={inputPrvRef}
name="privKey"
// value={data2?.privateKey}
readOnly={true}
className="text-slate-700 text-sm text-left mb-4 w-full bg-white"
/>
</div>
</div>
)}
</div>
)}
<div className=" w-full flex justify-between">
<div className="w-full text-right text-neutral-600 text-lg font-bold mt-4 mb-2">
افزودن کلید جدید
</div>
<Form {...formAdd}>
<form
onSubmit={formAdd.handleSubmit(onSubmitAdd)}
className="w-full flex flex-col mt-6 "
>
<div className="flex flex-row flex-wrap justify-between">
<FormField
control={formAdd.control}
name="title"
render={({ field }) => (
<FormItem className=" w-full lg:w-[48%]">
<FormLabel className="text-[#7C838A] text-sm font-medium">
عنوان کلید
</FormLabel>
<FormControl>
<Input
placeholder="عنوان کلید را وارد نمایید"
{...field}
className="bg-white"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={formAdd.control}
name="publicKey"
render={({ field }) => (
<FormItem className=" w-full lg:w-[48%]">
<FormLabel className="text-[#7C838A] text-sm font-medium ">
کلید عمومی
</FormLabel>
<FormControl>
<Input
placeholder="کلید عمومی را وارد کنید"
{...field}
className="bg-white"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button
type="submit"
className="bg-blue text-white min-w-max w-1/2 sm:w-1/3 lg:w-1/4 p-2 rounded-xl text-center"
>
افزودن کلید
</Button>
</div>
</form>
</Form>
<Button
variant="outline"
onClick={handleClickGenerate}
disabled={isNewKeyLoading}
className="my-2"
>
{" "}
ایجاد جفت کلید
</Button>
</div>
<Form {...formAdd}>
<form
onSubmit={formAdd.handleSubmit(onSubmitAdd)}
className="w-full flex flex-col mt-6 "
>
<div className="flex flex-col flex-wrap justify-between">
<FormField
control={formAdd.control}
name="title"
render={({ field }) => (
<FormItem className=" w-full ">
<FormLabel className="text-[#7C838A] text-sm font-medium">
عنوان کلید
</FormLabel>
<FormControl>
<Input
placeholder="عنوان کلید را وارد نمایید"
{...field}
className="bg-white"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={formAdd.control}
name="publicKey"
render={({ field }) => (
<FormItem className=" w-full">
<FormLabel className="text-[#7C838A] text-sm font-medium ">
کلید عمومی
</FormLabel>
<FormControl>
<Textarea
placeholder="کلید عمومی را وارد کنید"
{...field}
className="bg-white resize-none"
dir="ltr"
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
</div>
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button
type="submit"
className="bg-blue text-white min-w-max w-1/2 sm:w-1/3 lg:w-1/4 p-2 rounded-xl text-center"
>
افزودن کلید
</Button>
</div>
</form>
</Form>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
@ -428,74 +369,84 @@ export default function AdminKeysManagement() {
{/* <AlertDialogAction>Continue</AlertDialogAction> */}
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
{/* 2 */}
<div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
لیست کلیدها
</div>
<div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
{data1?.map((item: any) => {
return (
<div
key={item.id}
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start
`}
{/* 2 */}
<div className=" w-full flex justify-between items-center mt-1">
<div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
لیست کلیدها
</div>
<AlertDialogTrigger asChild>
<Button
variant="outline"
className="bg-orange-500 hover:bg-orange-500/80 text-white hover:text-white"
// disabled={isNewKeyLoading}
>
<p className=" text-slate-500 text-sm font-normal leading-normal">
عنوان کلید :
<span className=" text-slate-800">{item.title}</span>
</p>
<p className=" text-slate-500 text-sm font-normal leading-normal">
آی دی بازرس :
<span className=" text-slate-800 self-end">
{item.inspectorId}
</span>
</p>
افزودن کلید جدید
</Button>
</AlertDialogTrigger>
</div>
<div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
{data1?.map((item: any) => {
return (
<div
key={item.id}
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start bg-[#F5F5F5]
`}
>
<p className=" text-slate-500 text-sm font-normal leading-normal">
عنوان کلید:{" "}
<span className=" text-slate-800">{item.title}</span>
</p>
<p className=" text-slate-500 text-sm font-normal leading-normal">
آیدی بازرس:{" "}
<span className=" text-slate-800 self-end">
{item.inspectorId}
</span>
</p>
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}>
<AlertDialogTrigger asChild>
{/* <Button variant="outline">Show Dialog</Button> */}
<FaRegEdit
aria-hidden="true"
className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end"
onClick={() => setKeyId(item?.id)}
/>
</AlertDialogTrigger>
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[20em] max-h-[23em]">
<AlertDialogHeader>
<AlertDialogTitle>تغییر کلید</AlertDialogTitle>
<AlertDialogDescription>
<Form {...formEdit}>
<form
onSubmit={formEdit.handleSubmit(onSubmitEdit)}
className="w-full flex flex-col mt-6 "
>
<div className="flex flex-row flex-wrap justify-between">
<FormField
control={formEdit.control}
name="uploadPrivateKey"
render={({ field }) => (
<FormItem className=" w-full">
<FormLabel className="text-[#7C838A] text-sm font-medium mb-2">
پیوست (کلید خصوصی)
</FormLabel>
<FormControl>
<Input
required={true}
type="file"
accept=".txt"
className="bg-slate-300 mt-2"
// {...field}
onChange={handleFileChange}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<AlertDialog open={openEdit} onOpenChange={setOpenEdit}>
<AlertDialogTrigger asChild>
{/* <Button variant="outline">Show Dialog</Button> */}
<FaRegEdit
aria-hidden="true"
className="w-6 h-6 text-slate-600 hover:cursor-pointer self-end"
onClick={() => setKeyId(item?.id)}
/>
</AlertDialogTrigger>
<AlertDialogContent className=" w-full max-w-3xl h-full lg:max-h-[20em] max-h-[23em]">
<AlertDialogHeader>
<AlertDialogTitle>تغییر کلید</AlertDialogTitle>
<AlertDialogDescription>
<Form {...formEdit}>
<form
onSubmit={formEdit.handleSubmit(onSubmitEdit)}
className="w-full flex flex-col mt-6 "
>
<div className="flex flex-row flex-wrap justify-between">
<FormField
control={formEdit.control}
name="uploadPrivateKey"
render={({ field }) => (
<FormItem className=" w-full">
<FormLabel className="text-[#7C838A] text-sm font-medium mb-2">
پیوست (کلید خصوصی)
</FormLabel>
<FormControl>
<Input
required={true}
type="file"
accept=".txt"
className="bg-slate-300 mt-2"
// {...field}
onChange={handleFileChange}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>
{/* <FormField
{/* <FormField
control={formEdit.control}
name="publicKeyId"
render={({ field }) => (
@ -515,41 +466,42 @@ export default function AdminKeysManagement() {
</FormItem>
)}
/> */}
</div>
</div>
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button
// href="/FollowResult"
type="submit"
className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
>
تغییر کلید
</Button>
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
<Button
// href="/FollowResult"
type="submit"
className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
>
تغییر کلید
</Button>
{/* <AlertDialogAction
{/* <AlertDialogAction
type="submit"
className="bg-blue text-white min-w-max p-2 rounded-xl text-center hover:bg-white hover:text-slate-800"
>
تغییر کلید
</AlertDialogAction> */}
<AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن
</AlertDialogCancel>
</div>
</form>
</Form>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
{/* <AlertDialogAction>Continue</AlertDialogAction> */}
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
);
})}
</div>
<AlertDialogCancel className="bg-blue text-white rounded-xl mt-0">
بستن
</AlertDialogCancel>
</div>
</form>
</Form>
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
{/* <AlertDialogAction>Continue</AlertDialogAction> */}
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
);
})}
</div>
</AlertDialog>
</div>
</div>
);

View File

@ -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<boolean>(true);
const [check, setCheck] = useState<any>(false);
const [complaintData, setComplaintData] = useState<any>("");
const [selectedFile, setSelectedFile] = useState<any>(null);
const [key, setKey] = useState<any>(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 ? (
<div className="w-full flex max-lg:flex-col gap-3 items-start">
<div className="flex flex-col w-full lg:w-1/3 lg:order-2 gap-3 lg:sticky top-20">
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">
<p className="text-[#464646] text-base font-bold">گزارش شکایت</p>
<div className="mt-2">
<p className="text-[#2e2a2a] text-sm font-medium">
موضوع شکایت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.title}
</span>
<Dialog open={open} onOpenChange={setOpen}>
<DialogContent dir="rtl" className="">
<DialogHeader dir="rtl">
<DialogTitle dir="rtl">بارگذاری کلید خصوصی</DialogTitle>
<DialogDescription>
برای مشاهده شکایت لطفا کلید خود را آپلود نمایید.
</DialogDescription>
</DialogHeader>
<div className="grid w-full max-w-sm items-center gap-1.5">
<Input
dir="rtl"
id="picture"
onChange={handleFileChange}
type="file"
accept=".txt"
/>
</div>
<div className="flex items-center space-x-2">
<Checkbox
checked={check}
onCheckedChange={setCheck}
id="terms"
className=" ml-2"
/>
<label
htmlFor="terms"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
ذخیره کلید برای دفعات بعد
</label>
</div>
<DialogFooter className=" flex !justify-between">
{/* <DialogClose asChild></DialogClose> */}
<Button
variant="outline"
onClick={() => {
router.push("/UserPanel/Complaints");
}}
type="submit"
>
بازگشت
</Button>
<Button
className=" bg-blue hover:bg-blue/90"
onClick={() => {
checkKey2(complaintData);
}}
type="submit"
>
ذخیره
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
{getComplaintMutation.data && !getComplaintMutation.isPending ? (
<>
<button
onClick={() => router.push("/UserPanel/Complaints")}
className=" my-2 flex gap-1 cursor-pointer text-blue "
>
<span>
<ArrowRight />
</span>
<p>بازگشت</p>
</button>
<div className="w-full flex max-lg:flex-col gap-3 items-start">
<div className="flex flex-col w-full lg:w-1/3 lg:order-2 gap-3 lg:sticky top-20">
<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-sm font-medium">
دستگاه مربوطه:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{/* {data.title} */}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
پرسنل مربوطه:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{/* {data.title} */}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
زمان ثبت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{convertDate(data.registeredAt)}
</span>
</p>
{/* <p className="text-[#464646] text-sm font-medium">
{" "}
موضوع شکایت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
متن تستی
</span>
</p> */}
<div className="mt-2 flex flex-col gap-y-1">
<p className="text-[#2e2a2a] text-sm font-medium">
موضوع شکایت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data?.title}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
دستگاه مربوطه:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data?.complaintOrganization
? data?.complaintOrganization.title
: "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
پرسنل مربوطه:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.complaining ? data.complaining : "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
زمان ثبت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{convertDate(data.registeredAt)}
</span>
</p>
</div>
</div>
<div className=" max-lg:hidden order-2 bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col">
<p className="text-[#464646] text-base font-bold mb-1">
انجام عملیات
</p>
<InspectorOperations
updateData={(data) => getComplaintMutation.mutate(data)}
role={role}
complaintData={data}
id={id}
key2={key}
/>
</div>
{/* <p className="text-[#464646] text-sm font-medium text-justify">
درخواست شما با کد رهگیری {data.trackingNumber} و رمز عبور 12422 در
دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن
0353286545 جهت پشتیبانی تماس حاصل کنید.{" "}
</p> */}
</div>
<div className=" max-lg:hidden order-2 bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col">
<div className="w-full lg:w-2/3 self-stretch bg-[#E9E9E9] p-4 px-10 rounded-lg">
<p className="text-[#464646] text-base font-bold">روند شکایت</p>
<div className=" flex flex-col gap-y-4 mt-4">
{data.contents?.map((item: any) => {
return (
<div
key={item.id}
className=" bg-white p-4 rounded-lg shadow-md"
>
<div className=" flex gap-4 items-center">
<p className="">
<Badge>{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]">
{item.text ? item.text : "-"}
</span>
</div>
{item.media.length !== 0 && (
<Separator className=" mt-2 mb-1" />
)}
<div className=" text-[#464646] mt-2">
<div className=" flex flex-wrap max-md:flex-col w-full items-center gap-2 text-xs mt-2">
{item?.media.map((item: any) => {
return (
<div 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=" cursor-pointer flex gap-2 truncate items-center"
>
<File className=" w-6 h-6" />
<p className=" max-w-[5rem] truncate">
{item.title}
</p>
</a>
<ArrowDownToLine
className=" cursor-pointer"
onClick={() =>
downloadFile(
item.data,
item.title,
item.mimeType
)
}
/>
</div>
);
})}
</div>
</div>
</div>
);
})}
</div>
</div>
<div className=" lg:hidden order-2 w-full bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">
<p className="text-[#464646] text-base font-bold mb-1">
انجام عملیات
</p>
<InspectorOperations
updateData={() => getComplaintMutation.mutate(storeData)}
updateData={(data) => getComplaintMutation.mutate(data)}
role={role}
complaintData={data}
id={id}
key={key}
/>
</div>
</div>
<div className="w-full lg:w-2/3 self-stretch bg-[#E9E9E9] p-4 px-10 rounded-lg">
<p className="text-[#464646] text-base font-bold">روند شکایت</p>
<div className=" flex flex-col gap-y-4 mt-4">
{data.contents?.map((item: any) => {
return (
<div
key={item.id}
className=" bg-white p-4 rounded-lg shadow-md"
>
<div className=" flex gap-4 items-center">
<p className="">
<Badge>{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]">
{item.text ? item.text : "-"}
</span>
</div>
{item.media.length !== 0 && <Separator className=" mt-2" />}
<div className=" text-[#464646] mt-2">
<div className=" flex flex-wrap max-md:flex-col w-full items-center gap-2 text-xs mt-2">
{item?.media.map((item: any) => {
return (
<div className=" bg-gray-100 text-[#7C838A] w-full md:w-40 rounded-md p-2 flex justify-between gap-2 ">
<a
onClick={() =>
openFileInNewTab(item.data, item.mimeType)
}
className=" cursor-pointer flex gap-2 truncate items-center"
>
<File />
<p className=" truncate">{item.title}</p>
</a>
<ArrowDownToLine
className=" cursor-pointer"
onClick={() =>
downloadFile(
item.data,
item.title,
item.mimeType
)
}
/>
</div>
);
})}
</div>
</div>
</div>
);
})}
</div>
</div>
<div className=" lg:hidden order-2 w-full bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">
<p className="text-[#464646] text-base font-bold mb-1">
انجام عملیات
</p>
<InspectorOperations
updateData={() => getComplaintMutation.mutate(storeData)}
role={role}
complaintData={data}
/>
</div>
{/* Left */}
{/* <div className="w-full md:w-1/3 bg-white shadow-lg rounded-md pt-3 px-4 flex flex-row md:flex-col max-md:flex-wrap">
{/* Left */}
{/* <div className="w-full md:w-1/3 bg-white shadow-lg rounded-md pt-3 px-4 flex flex-row md:flex-col max-md:flex-wrap">
<p className="text-[#464646] text-base font-bold mb-3">
وضعیت درخواست
</p>
@ -294,9 +403,24 @@ export default function ComplainsDetails({
);
})}
</div> */}
</div>
</div>
</>
) : (
""
<>
{getComplaintMutation.isPending && (
<div className="w-full h-full flex justify-center mt-20">
<Triangle
visible={true}
height="100"
width="100"
color="#003778"
ariaLabel="triangle-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
)}
</>
)}
</>
);

View File

@ -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<any>();
const [password, setPassword] = useState<any>();
const [complaintData, setComplaintData] = useState<any>();
const [printStyle, setPrintStyle] = useState<boolean>(true);
// Print component Data
const componentRef = useRef<HTMLDivElement>(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 (
<>
<div className="w-[90vw] sm:w-[90vw] lg:w-[85vw] xl:w-[75vw] 3xl:w-[70vw] max-sm:mt-16 pt-4 mx-auto mb-10">
{/* <div className="h-full flex flex-col justify-center"> */}
{/* <p
className="text-sm font-medium leading-6 tracking-wide text-[#7C838A] dark:text-white
3xl:text-base 3xl:font-bold"
>
درخواست شما با کد رهگیری
<span className="text-slate-500 mx-2">{`${trackingNumber}`}</span>و
رمز عبور
<span className="text-slate-500 mx-2">{`${password}`}</span>
در دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن
0353286545 جهت پشتیبانی تماس حاصل کنید.
</p> */}
{complaintPrintMutation?.data ? (
<>
<div className="flex justify-center sm:justify-end gap-2 mb-2">
<AlertDialog>
<AlertDialogTrigger asChild>
<Button
variant="outline"
type="submit"
onClick={() => onSubmit()}
className="w-fit bg-blue text-white p-2 rounded-xl text-center"
>
پرینت درخواست
</Button>
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
<p className="text-[#464646] text-base font-bold">
گزارش شکایات
</p>
<AlertDialogCancel className="p-0 border-0 h-auto">
<IoMdClose />
</AlertDialogCancel>
</AlertDialogTitle>
<AlertDialogDescription className="h-full px-0 py-0 sm:px-0 sm:pt-0 ">
{complaintPrintMutation.isPending ? (
<div className="felx justify-center items-center self-center h-full">
<ThreeDots
visible={true}
height="80"
width="100"
color="#003778"
radius="9"
ariaLabel="three-dots-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
) : (
<div
dir="rtl"
className=" font-[yekan] px-10 py-4 sm:px-28 sm:pt-9 "
id="details"
ref={componentRef}
// style={{ border: printStyle ? 'none' : '5px solid black' , margin: printStyle ? 'auto': '1em' }}
>
<p className="text-[#464646] text-sm font-medium">
{" "}
موضوع شکایت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{`${complaintData?.title}`}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
{" "}
متن شکایت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{`${complaintData?.contents[0]?.text}`}
</span>
</p>
<br />
<p className="text-[#464646] text-sm font-medium">
{" "}
جزئیات شکایت:
</p>
<br />
<p className="text-[#464646] text-sm font-medium">
درخواست شما با کد رهگیری
<span className="text-slate-500 mx-2">{`${trackingNumber}`}</span>
و رمز عبور
<span className="text-slate-500 mx-2">{`${password}`}</span>
در دست بررسی و اقدام می باشد. در صورت تمایل می
توانید با شماره تلفن 0353286545 جهت پشتیبانی تماس
حاصل کنید.
</p>
</div>
)}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<Button
className="bg-blue text-white w-1/2 sm:w-1/6"
onClick={handlePrint}
>
پرینت گزارش
</Button>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
<ComplainsDetails
role="Citizen"
Data={complaintPrintMutation?.data}
/>
</>
) : (
""
)}
{/* <Image
alt="icon"
src={Resultimg}
className="self-center w-3/5 mt-5 sm:w-[23em] sm:h-[20em] 3xl:w-3/5 3xl:h-[30em] object-contain"
/> */}
{/* </div> */}
</div>
</>
);
}

View File

@ -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<FileList>((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<z.infer<typeof FormSchema>>({
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<typeof FormSchema>) {
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({
<SelectContent dir="rtl">
<SelectGroup>
<SelectLabel>عملیات</SelectLabel>
{selectOptions.map((item) => {
{possibleOperations.map((item) => {
return (
<SelectItem value={String(item.value)}>
{item.name}
{item.description}
</SelectItem>
);
})}

View File

@ -70,6 +70,7 @@ export default function Login() {
});
function onSubmit(data: z.infer<typeof FormSchema>) {
refetch();
const payload = {
username: data.username,
password: data.password,
@ -90,7 +91,7 @@ export default function Login() {
: null;
return (
<div className=" w-screen h-screen grid place-content-center ">
<div className=" w-screen h-screen grid place-content-center bg-gray-200 ">
<div
className="w-full sm:[20rem] md:[20rem] xl:w-[30rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
h-fit"

View File

@ -1,36 +1,102 @@
"use client";
import React, { useEffect, useState } from "react";
import React, { useEffect, useRef, useState } from "react";
import Link from "next/link";
import { AdminMenuItems, ControllerMenuItems } from "@/constants";
import { usePathname } from "next/navigation";
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 { DoorOpen, LogOut } from "lucide-react";
import { deleteCookie } from "cookies-next";
export default function NavbarPanel() {
const [isOpen, setOpen] = useState(false);
const ref = useRef(null);
const router = useRouter();
const pathname = usePathname();
const [role, setRole] = useState<string | null>("");
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 (
<div
className="fixed flex flex-col-reverse justify-between items-start gap-3
sm:flex-row sm:items-center sm:gap-0
className="fixed flex justify-between items-center gap-3
flex-row sm:items-center sm:gap-0
w-full px-8 py-4 z-10 top-0 bg-blue max-md:px-4 shadow-md
"
>
<div className=" flex items-center gap-8 max-md:gap-4">
<p className="text-white inline-block bg-clip-text text-sm font-bold max-md:text-xs max-md:font-medium">
پنل کاربری |
<div className=" md:hidden">
<Hamburger
toggled={isOpen}
size={20}
toggle={setOpen}
direction="right"
color="#fff"
/>
</div>
<p className="text-white inline-block bg-clip-text text-sm font-bold max-md:text-sm max-md:font-medium">
پنل کاربری {<span className=" max-md:hidden">|</span>}
</p>
<div className="flex flex-row gap-7 max-md:gap-3">
<AnimatePresence>
{isOpen && (
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
transition={{ duration: 0.2 }}
className="fixed z-[100] left-0 shadow-4xl right-0 top-[3rem] p-5 bg-gradient-to-b from-blue to-white border-b border-b-white/20"
>
<ul className="grid gap-2 ">
{selectedMenu.map((item, idx, array) => {
// const { Icon } = item;
const lastItem = array.length - 1;
return (
<motion.li
initial={{ scale: 0, opacity: 0 }}
animate={{ scale: 1, opacity: 1 }}
transition={{
type: "spring",
stiffness: 260,
damping: 20,
delay: 0.1 + idx / 10,
}}
key={item.name}
className=" w-full p-[0.08rem] rounded-xl bg-gradient-to-tr from-neutral-800 via-white to-neutral-700"
>
<Link
onClick={() => 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}
>
<span className="flex gap-1 text-sm">{item.name}</span>
{/* <Icon className="text-xl" /> */}
</Link>
</motion.li>
);
})}
</ul>
</motion.div>
)}
</AnimatePresence>
<div className="flex flex-row gap-7 max-md:gap-3 max-md:hidden">
{role && (
<>
{selectedMenu.map(
@ -50,28 +116,28 @@ export default function NavbarPanel() {
)}
</>
)}
{/* {AdminMenuItems.map((item) => {
return (
<Link key={item.id} href={item.href}>
<p
className="text-white font-normal text-sm max-md:text-xs
hover:bg-white/50 rounded-sm p-1
animate-out duration-300 "
>
{item.name}
</p>
</Link>
);
})} */}
</div>
</div>
<h1 className="text-white inline-block bg-clip-text before:max-md:hidden text-sm font-bold max-md:text-xs max-md:font-medium">
{role === "Admin"
? "نام و نام خانوادگی (ادمین)"
: "نام و نام خانوادگی (بازرس)"}
</h1>
<div className=" flex gap-4 items-center">
<h1 className="text-white inline-block bg-clip-text before:max-md:hidden text-sm font-bold max-md:text-xs max-md:font-medium">
{data && (
<>
{role === "Admin"
? `${data?.title ? data.title : data.username} (ادمین)`
: `${data?.title ? data.title : data.username} (بازرس)`}
</>
)}
</h1>
<div className="hover:bg-white/50 p-1 rounded-md">
<LogOut
onClick={() => {
deleteCookie("Sootzani_Token");
router.push("/");
}}
className=" text-white "
/>
</div>
</div>
</div>
);
}

View File

@ -68,130 +68,90 @@ export default function TabController() {
const finishedComplaints = data?.filter((item: any) => item.status == 4);
console.log(newComplaints);
return (
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-8 pt-9 mx-auto">
<Dialog>
<DialogTrigger className=" appearance-none" asChild>
<Button
// onClick={handelVerify}
type="submit"
className="bg-brown hover:bg-brown/90 text-white w-36 p-2 rounded-xl mt-6 md:mt-12 mb-2"
>
+ بارگذاری کلید جدید
</Button>
</DialogTrigger>
<Tabs defaultValue="tab1" className="" dir="rtl">
<div className="w-full flex flex-col-reverse lg:flex-row gap-4 lg:gap-5 justify-between items-center mb-10">
{/* Tab Title */}
<TabsList className="w-full flex gap-1 md:gap-4 lg:gap-7">
<p className="3xl:ml-6 text-xs sm:text-sm font-bold">
لیست شکایت ها |
</p>
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 pt-9 mx-auto">
<p className="3xl:ml-6 text-xs sm:text-sm font-bold md:hidden my-2">
لیست شکایت ها
</p>
<Tabs defaultValue="tab1" className="" dir="rtl">
<div className="w-full flex flex-col-reverse lg:flex-row gap-4 lg:gap-5 justify-between items-center mb-10">
{/* Tab Title */}
<TabsList className="w-full flex gap-1 md:gap-4 lg:gap-7">
<p className="3xl:ml-6 text-xs sm:text-sm font-bold max-md:hidden">
لیست شکایت ها |
</p>
<TabsTrigger
value="tab1"
className="hover:border-b-2 border-b-blue"
>
جدید
</TabsTrigger>
<TabsTrigger
value="tab2"
className="hover:border-b-2 border-b-blue"
>
در انتظار پاسخ
</TabsTrigger>
<TabsTrigger
value="tab3"
className="hover:border-b-2 border-b-blue"
>
در حال بررسی
</TabsTrigger>
<TabsTrigger
value="tab4"
className="hover:border-b-2 border-b-blue"
>
پاسخ داده شده
</TabsTrigger>
<TabsTrigger
value="tab5"
className="hover:border-b-2 border-b-blue"
>
پایان یافته
</TabsTrigger>
</TabsList>
<TabsTrigger
value="tab1"
className="hover:border-b-2 border-b-blue max-md:flex-1"
>
جدید
</TabsTrigger>
<TabsTrigger
value="tab2"
className="hover:border-b-2 border-b-blue max-md:flex-1"
>
در انتظار پاسخ
</TabsTrigger>
<TabsTrigger
value="tab3"
className="hover:border-b-2 border-b-blue max-md:flex-1"
>
در حال بررسی
</TabsTrigger>
<TabsTrigger
value="tab4"
className="hover:border-b-2 border-b-blue max-md:flex-1"
>
پاسخ داده شده
</TabsTrigger>
<TabsTrigger
value="tab5"
className="hover:border-b-2 border-b-blue max-md:flex-1"
>
پایان یافته
</TabsTrigger>
</TabsList>
{/* Search Box */}
<Search mode="controller" />
</div>
{/* Search Box */}
<Search mode="controller" />
</div>
{/* Tab Content */}
<TabsContent value="tab1">
<TableController
checkKey={(item: any) => checkKey(item)}
data={newComplaints}
/>
</TabsContent>
{/* Tab Content */}
<TabsContent value="tab1">
<TableController
checkKey={(item: any) => checkKey(item)}
data={newComplaints}
/>
</TabsContent>
<TabsContent value="tab2">
<TableController
checkKey={(item: any) => checkKey(item)}
data={waitingForCitizenResponseComplaints}
/>
</TabsContent>
<TabsContent value="tab2">
<TableController
checkKey={(item: any) => checkKey(item)}
data={waitingForCitizenResponseComplaints}
/>
</TabsContent>
<TabsContent value="tab3">
<TableController
checkKey={(item: any) => checkKey(item)}
data={inProgressComplaints}
/>
</TabsContent>
<TabsContent value="tab3">
<TableController
checkKey={(item: any) => checkKey(item)}
data={inProgressComplaints}
/>
</TabsContent>
<TabsContent value="tab4">
<TableController
checkKey={(item: any) => checkKey(item)}
data={citizenRepliedComplaints}
/>
</TabsContent>
<TabsContent value="tab4">
<TableController
checkKey={(item: any) => checkKey(item)}
data={citizenRepliedComplaints}
/>
</TabsContent>
<TabsContent value="tab5">
<TableController
checkKey={(item: any) => checkKey(item)}
data={finishedComplaints}
/>
</TabsContent>
</Tabs>
<DialogContent dir="rtl" className="sm:max-w-[425px]">
<DialogHeader dir="rtl">
<DialogTitle dir="rtl">بارگذاری کلید خصوصی</DialogTitle>
<DialogDescription>
لطفا کلید خصوصی خود را آپلود نمایید.
</DialogDescription>
</DialogHeader>
<div className="grid w-full max-w-sm items-center gap-1.5">
{/* <Label htmlFor="picture">Picture</Label> */}
<Input
dir="rtl"
id="picture"
onChange={handleFileChange}
type="file"
accept=".txt"
/>
</div>
<DialogFooter>
<DialogClose asChild>
<Button
onClick={() => {
toast("کلید شما با موفقیت ذخیره شد.", {
className: "!bg-green-500 !text-white",
});
}}
type="submit"
>
ذخیره
</Button>
</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
<TabsContent value="tab5">
<TableController
checkKey={(item: any) => checkKey(item)}
data={finishedComplaints}
/>
</TabsContent>
</Tabs>
</div>
);
}

View File

@ -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<any>(null);
const [open, setOpen] = useState<boolean>(false);
const [roData, setRowData] = useState<boolean>(false);
const [rowData, setRowData] = useState<Complaint | null>(null);
const [check, setCheck] = useState<any>(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 (
<div>
<Table className="border-[1px] border-solid border-muted rounded-md w-full min-w-[40rem] overflow-y-auto scrollbar-thumb-gray-600 scrollbar-track-gray-100 scrollbar-thin">
@ -97,13 +104,12 @@ export default function TableController({
{data?.map((item: Complaint, index: number) => {
return (
<TableRow
onClick={
() => 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"
/>
</div>
<div className="flex items-center space-x-2">
<Checkbox
checked={check}
onCheckedChange={setCheck}
id="terms"
className=" ml-2"
/>
<label
htmlFor="terms"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
ذخیره کلید برای دفعات بعد
</label>
</div>
<DialogFooter>
<DialogClose asChild>
<Button
onClick={() => {
if (selectedFile) {
toast("کلید شما با موفقیت بارگذاری شد.");
}
}}
type="submit"
>
ذخیره
</Button>
</DialogClose>
<DialogClose asChild></DialogClose>
<Button onClick={() => checkKey2(rowData)} type="submit">
ذخیره
</Button>
</DialogFooter>
</DialogContent>
</Dialog>

View File

@ -69,7 +69,7 @@ export default function Verify() {
}, []);
return (
<div className=" w-screen h-screen grid place-content-center ">
<div className=" w-screen h-screen grid place-content-center bg-gray-200">
<div
className="w-full sm:[20rem] md:[20rem] xl:w-[30rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
h-fit"
@ -127,60 +127,6 @@ export default function Verify() {
)}
</Button>
</div>
{/* <Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="w-full flex flex-col "
>
<FormField
control={form.control}
name="username"
render={({ field }) => (
<FormItem>
<FormLabel className="text-[#7C838A] text-sm font-medium">
نام کاربری
</FormLabel>
<FormControl>
<Input
className="mb-4"
placeholder="نام کاربری خود را وارد نمایید"
{...field}
/>
</FormControl>
<FormDescription>
This is your public display name.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="password"
render={({ field }) => (
<FormItem>
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
رمز عبور
</FormLabel>
<FormControl>
<Input placeholder="رمز عبور خود را وارد کنید" {...field} />
</FormControl>
<FormMessage />
</FormItem>
)}
/>
<div className="flex justify-end gap-2 w-full mt-14">
<Button
type="submit"
className="bg-blue text-white w-1/2 md:w-1/3 p-2 rounded-xl"
>
ورود
</Button>
</div>
</form>
</Form> */}
</div>
</div>
</div>

View File

@ -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<typeof CheckboxPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root>
>(({ className, ...props }, ref) => (
<CheckboxPrimitive.Root
ref={ref}
className={cn(
"peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",
className
)}
{...props}
>
<CheckboxPrimitive.Indicator
className={cn("flex items-center justify-center text-current")}
>
<Check className="h-4 w-4" />
</CheckboxPrimitive.Indicator>
</CheckboxPrimitive.Root>
))
Checkbox.displayName = CheckboxPrimitive.Root.displayName
export { Checkbox }

View File

@ -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);

51
package-lock.json generated
View File

@ -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",

View File

@ -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",

View File

@ -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;

View File

@ -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;
}