Bugs fixed + complaint ui changed

Kahdooie
Hossein Rahmani 2024-01-08 22:44:09 +03:30
parent ead91d08ea
commit b8cab40e70
5 changed files with 323 additions and 110 deletions

View File

@ -7,7 +7,7 @@ import { ComplainDetailsItems } from "@/constants";
import { useMutation } from "@tanstack/react-query"; import { useMutation } from "@tanstack/react-query";
import { OperateByInspector, getComplaint } from "@/utils/inspectorApi"; import { OperateByInspector, getComplaint } from "@/utils/inspectorApi";
import useData from "@/store/useData"; import useData from "@/store/useData";
import { Decrypt, convertDate } from "@/lib/utils"; import { Decrypt, convertDate, convertFullTime } from "@/lib/utils";
import { Badge } from "./ui/badge"; import { Badge } from "./ui/badge";
import InspectorOperations from "./InspectorOperations"; import InspectorOperations from "./InspectorOperations";
import { ArrowDownToLine, ArrowRight, File } from "lucide-react"; import { ArrowDownToLine, ArrowRight, File } from "lucide-react";
@ -51,17 +51,20 @@ export default function ComplainsDetails({
const getComplaintMutation = useMutation({ const getComplaintMutation = useMutation({
mutationKey: ["Complaint", id], mutationKey: ["Complaint", id],
mutationFn: getComplaint, mutationFn: getComplaint,
onSuccess: (res) => {}, onSuccess: (res) => {
localStorage.setItem("trackingNumber", res.trackingNumber);
},
onError: (err) => {}, onError: (err) => {},
}); });
useEffect(() => { useEffect(() => {
const tn = localStorage.getItem("trackingNumber") as string; const storedData = localStorage.getItem("CompliantData");
const data = JSON.parse(storedData as string);
const pw = localStorage.getItem("privateKey") as string; const pw = localStorage.getItem("privateKey") as string;
console.log(tn, pw); localStorage.setItem("trackingNumber", data.trackingNumber);
if (tn != null && pw != null) { if (pw != null) {
getComplaintMutation.mutate({ getComplaintMutation.mutate({
trackingNumber: tn as string, trackingNumber: data.trackingNumber,
password: pw, password: pw,
}); });
setOpen(false); setOpen(false);
@ -157,9 +160,9 @@ export default function ComplainsDetails({
console.log(dcKey); console.log(dcKey);
if (dcKey != false && dcKey != null) { if (dcKey != false && dcKey != null) {
if (check) { if (check) {
localStorage.setItem("trackingNumber", item.trackingNumber);
localStorage.setItem("privateKey", dcKey); localStorage.setItem("privateKey", dcKey);
} }
localStorage.setItem("trackingNumber", item.trackingNumber);
setKey(dcKey); setKey(dcKey);
getComplaintMutation.mutate({ getComplaintMutation.mutate({
trackingNumber: item.trackingNumber, trackingNumber: item.trackingNumber,
@ -205,7 +208,7 @@ export default function ComplainsDetails({
htmlFor="terms" htmlFor="terms"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
> >
ذخیره کلید برای دفعات بعد ذخیره کلید برای استفاده در زمان های بعدی
</label> </label>
</div> </div>
<AlertDialogFooter className=" gap-y-2 max-md:w-full max-md:flex max-md:flex-col"> <AlertDialogFooter className=" gap-y-2 max-md:w-full max-md:flex max-md:flex-col">
@ -245,42 +248,10 @@ export default function ComplainsDetails({
</span> </span>
<p>بازگشت</p> <p>بازگشت</p>
</button> </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="w-full flex max-lg:flex-col items-start mt-2 gap-2">
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col"> <div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-24">
<p className="text-[#464646] text-base font-bold"> <div className=" max-lg:hidden bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col">
گزارش شکایت
</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 className="text-[#464646] text-base font-bold mb-1">
انجام عملیات انجام عملیات
</p> </p>
@ -293,74 +264,308 @@ export default function ComplainsDetails({
/> />
</div> </div>
</div> </div>
<div className="w-full lg:w-2/3 self-stretch bg-[#E9E9E9] p-4 px-10 rounded-lg"> <div className="w-full lg:w-2/3 self-stretch rounded-lg flex flex-col gap-2 ">
<p className="text-[#464646] text-base font-bold">روند شکایت</p> <div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col md:flex-row gap-2 items-center justify-center">
<div className=" flex flex-col gap-y-4 mt-4"> {data.user == null ? (
{data.contents?.map((item: any) => { <>
return ( <div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 w-full p-5 relative">
<div <p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
key={item.id} اطلاعات کلی
className=" bg-white p-4 rounded-lg shadow-md" </p>
> <p className="text-[#2e2a2a] text-sm font-medium">
<div className=" flex gap-4 items-center"> موضوع شکایت:{" "}
<p className=""> <span className="text-[#7C838A] text-sm font-medium">
<Badge>{item.sender == 0 ? "شهروند" : "بازرس"}</Badge> {data?.title}
</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> </span>
</div> </p>
{item.media.length !== 0 && ( <p className="text-[#464646] text-sm font-medium">
<Separator className=" mt-2 mb-1" /> دستگاه مربوطه:{" "}
)} <span className="text-[#7C838A] text-sm font-medium">
<div className=" text-[#464646] mt-2"> {data?.complaintOrganization
<div className=" flex flex-wrap max-md:flex-col w-full items-center gap-2 text-xs mt-2"> ? data?.complaintOrganization.title
{item?.media.map((item: any, index: number) => { : "-"}
return ( </span>
<div </p>
key={index} <p className="text-[#464646] text-sm font-medium">
className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center" فرد مربوطه:{" "}
> <span className="text-[#7C838A] text-sm font-medium">
<a {data.complaining ? data.complaining : "-"}
onClick={() => </span>
openFileInNewTab(item.data, item.mimeType) </p>
} <p className="text-[#464646] text-sm font-medium">
className=" cursor-pointer flex gap-2 truncate items-center" زمان ثبت:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{convertFullTime(data.registeredAt)}
</span>
</p>
</div>
</>
) : (
<>
<div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 md:w-1/2 p-5 relative">
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
اطلاعات کلی
</p>
<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">
{convertFullTime(data.registeredAt)}
</span>
</p>
</div>
<div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 md:w-1/2 p-5 relative">
<p className=" absolute -top-3 right-2 bg-[#E9E9E9] px-2 text-sm text-gray-500">
اطلاعات شاکی
</p>
<p className="text-[#2e2a2a] text-sm font-medium">
نام:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.user?.firstName ? data.user?.firstName : "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
نام خانوادگی:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.user?.lastName ? data.user?.lastName : "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
کدملی:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.user?.nationalId ? data.user?.nationalId : "-"}
</span>
</p>
<p className="text-[#464646] text-sm font-medium">
شماره موبایل:{" "}
<span className="text-[#7C838A] text-sm font-medium">
{data.user?.phoneNumber
? data.user?.phoneNumber
: "-"}
</span>
</p>
</div>
</>
)}
</div>
<div className="bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">
<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, index: number) => {
return (
<div
key={index}
className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center"
> >
<File className=" w-6 h-6" /> <a
<p className=" max-w-[5rem] truncate"> onClick={() =>
{item.title} openFileInNewTab(item.data, item.mimeType)
</p> }
</a> className=" cursor-pointer flex gap-2 truncate items-center"
<ArrowDownToLine >
className=" cursor-pointer" <File className=" w-6 h-6" />
onClick={() => <p className=" max-w-[5rem] truncate">
downloadFile( {item.title}
item.data, </p>
item.title, </a>
item.mimeType <ArrowDownToLine
) className=" cursor-pointer"
} onClick={() =>
/> downloadFile(
</div> item.data,
); item.title,
})} item.mimeType
)
}
/>
</div>
);
})}
</div>
</div> </div>
</div> </div>
</div> );
); })}
})} {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, index: number) => {
return (
<div
key={index}
className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center"
>
<a
onClick={() =>
openFileInNewTab(item.data, item.mimeType)
}
className=" 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>
);
})}
{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, index: number) => {
return (
<div
key={index}
className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center"
>
<a
onClick={() =>
openFileInNewTab(item.data, item.mimeType)
}
className=" 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>
</div> </div>
<div className=" lg:hidden order-2 w-full bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col"> <div className=" lg:hidden order-2 w-full bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col mt-2">
<p className="text-[#464646] text-base font-bold mb-1"> <p className="text-[#464646] text-base font-bold mb-1">
انجام عملیات انجام عملیات
</p> </p>

View File

@ -88,7 +88,7 @@ export default function InspectorOperations({
}); });
const tk = localStorage.getItem("trackingNumber"); const tk = localStorage.getItem("trackingNumber");
updateData({ updateData({
trackingNumber: tk, trackingNumber: complaintData.trackingNumber,
password: key2 ? key2 : (localStorage.getItem("privateKey") as string), password: key2 ? key2 : (localStorage.getItem("privateKey") as string),
}); });
}, },

View File

@ -19,6 +19,14 @@ export function convertDate(date: string) {
return convertedDate; return convertedDate;
} }
export function convertFullTime(date: string) {
const convertedDate = dayjs(date)
.calendar("jalali")
.locale("fa")
.format(" HH:mm - YYYY/M/DD");
return convertedDate;
}
export function Decrypt(encryptedData: any, privateKey: any) { export function Decrypt(encryptedData: any, privateKey: any) {
const decryptor = new JSEncrypt(); const decryptor = new JSEncrypt();
decryptor.setPrivateKey(privateKey); decryptor.setPrivateKey(privateKey);

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "sootzani", "name": "sootzani",
"version": "0.2.1", "version": "0.2.2",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "sootzani", "name": "sootzani",
"version": "0.2.1", "version": "0.2.2",
"dependencies": { "dependencies": {
"@hookform/resolvers": "^3.3.2", "@hookform/resolvers": "^3.3.2",
"@radix-ui/react-alert-dialog": "^1.0.5", "@radix-ui/react-alert-dialog": "^1.0.5",

View File

@ -1,6 +1,6 @@
{ {
"name": "sootzani", "name": "sootzani",
"version": "0.2.1", "version": "0.2.2",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",