Some of the bugs in the inspector panel were fixed
parent
ebebcbd684
commit
e887a874a8
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
import AdminWebContents from '@/components/AdminWebContents'
|
||||
import React from 'react'
|
||||
|
||||
export default function page() {
|
||||
return (
|
||||
<AdminWebContents />
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
"use client";
|
||||
import React, { useState, useRef, useEffect } from "react";
|
||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
||||
|
||||
export default function AdminWebContents() {
|
||||
return (
|
||||
<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 ">
|
||||
fsfdsffsdf
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ import { ArrowDownToLine, ArrowRight, File } from "lucide-react";
|
|||
import { Separator } from "./ui/separator";
|
||||
import secureLocalStorage from "react-secure-storage";
|
||||
import { Checkbox } from "./ui/checkbox";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
AlertDialog,
|
||||
|
|
@ -48,6 +49,8 @@ export default function ComplainsDetails({
|
|||
const router = useRouter();
|
||||
let data;
|
||||
|
||||
|
||||
|
||||
const getComplaintMutation = useMutation({
|
||||
mutationKey: ["Complaint", id],
|
||||
mutationFn: getComplaint,
|
||||
|
|
@ -60,15 +63,26 @@ export default function ComplainsDetails({
|
|||
useEffect(() => {
|
||||
const storedData = localStorage.getItem("CompliantData");
|
||||
const data = JSON.parse(storedData as string);
|
||||
const pw = localStorage.getItem("privateKey") as string;
|
||||
const prvKey = localStorage.getItem("privateKey") as string;
|
||||
const cipherKeyInspector = data.cipherKeyInspector;
|
||||
const newDcKey = Decrypt(cipherKeyInspector, prvKey);
|
||||
|
||||
// const pw = localStorage.getItem("privatePassword") as string;
|
||||
const pw = newDcKey as string;
|
||||
localStorage.setItem("trackingNumber", data.trackingNumber);
|
||||
if (pw != null) {
|
||||
// if (pw != null) {
|
||||
if (pw) {
|
||||
getComplaintMutation.mutate({
|
||||
trackingNumber: data.trackingNumber,
|
||||
password: pw,
|
||||
});
|
||||
setOpen(false);
|
||||
}
|
||||
// else {
|
||||
// toast("کلید خصوصی وجود ندارد ، بارگداری کنید.", {
|
||||
// className: "!bg-red-500 !text-white",
|
||||
// });
|
||||
// }
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -160,7 +174,9 @@ export default function ComplainsDetails({
|
|||
console.log(dcKey);
|
||||
if (dcKey != false && dcKey != null) {
|
||||
if (check) {
|
||||
localStorage.setItem("privateKey", dcKey);
|
||||
// localStorage.setItem("privateKey", dcKey);
|
||||
localStorage.setItem("privatePassword", dcKey);
|
||||
localStorage.setItem("privateKey", selectedFile);
|
||||
}
|
||||
localStorage.setItem("trackingNumber", item.trackingNumber);
|
||||
setKey(dcKey);
|
||||
|
|
@ -177,6 +193,8 @@ export default function ComplainsDetails({
|
|||
};
|
||||
|
||||
data = getComplaintMutation?.data;
|
||||
// console.log("Complainet data"+getComplaintMutation?.data);
|
||||
|
||||
return (
|
||||
<>
|
||||
<AlertDialog open={open} onOpenChange={setOpen}>
|
||||
|
|
@ -230,7 +248,7 @@ export default function ComplainsDetails({
|
|||
}}
|
||||
type="submit"
|
||||
>
|
||||
ذخیره
|
||||
مشاهده
|
||||
</Button>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
|
|
@ -241,7 +259,7 @@ export default function ComplainsDetails({
|
|||
onClick={() =>
|
||||
router.push("/UserPanel/ControllerDashboard/Complaints")
|
||||
}
|
||||
className=" my-2 flex gap-1 cursor-pointer text-blue "
|
||||
className=" my-2 flex gap-1 cursor-pointer text-blue lg:sticky top-20"
|
||||
>
|
||||
<span>
|
||||
<ArrowRight />
|
||||
|
|
@ -250,7 +268,7 @@ export default function ComplainsDetails({
|
|||
</button>
|
||||
|
||||
<div className="w-full flex max-lg:flex-col items-start mt-2 gap-2">
|
||||
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-24">
|
||||
<div className="flex flex-col w-full lg:w-1/3 gap-3 lg:sticky top-28">
|
||||
<div className=" max-lg:hidden bg-[#E9E9E9] rounded-md p-4 px-10 flex flex-col">
|
||||
<p className="text-[#464646] text-base font-bold mb-1">
|
||||
انجام عملیات
|
||||
|
|
@ -265,7 +283,7 @@ export default function ComplainsDetails({
|
|||
</div>
|
||||
</div>
|
||||
<div className="w-full lg:w-2/3 self-stretch rounded-lg flex flex-col gap-2 ">
|
||||
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col md:flex-row gap-2 items-center justify-center">
|
||||
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col md:flex-row gap-2 items-center justify-center lg:sticky top-28">
|
||||
{data.user == null ? (
|
||||
<>
|
||||
<div className="mt-2 flex flex-col gap-y-1 border rounded-md border-gray-400 w-full p-5 relative">
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ export default function NavbarPanel() {
|
|||
onClick={() => {
|
||||
deleteCookie("Sootzani_Token");
|
||||
localStorage.removeItem("privateKey");
|
||||
localStorage.removeItem("privatePassword");
|
||||
router.push("/");
|
||||
}}
|
||||
className=" text-white cursor-pointer"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
"use client";
|
||||
import React, { useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||
import TableController from "./TableController";
|
||||
import Search from "./Search";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { getComplaintsList } from "@/utils/inspectorApi";
|
||||
import { getComplaintsList, getPossibleStates } from "@/utils/inspectorApi";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Triangle } from "react-loader-spinner";
|
||||
import {
|
||||
Dialog,
|
||||
DialogClose,
|
||||
|
|
@ -51,65 +52,75 @@ export default function TabController() {
|
|||
});
|
||||
}
|
||||
};
|
||||
const { data, isLoading, refetch } = useQuery({
|
||||
queryKey: ["ComplaintsList"],
|
||||
queryFn: () => getComplaintsList(),
|
||||
|
||||
const [psblState, setPsblState] = useState(0);
|
||||
const [selectedTab, setSelectedTab] = useState("0");
|
||||
|
||||
const {
|
||||
data: dataState,
|
||||
isLoading: isLoadingState,
|
||||
refetch: refetchState,
|
||||
} = useQuery({
|
||||
queryKey: ["PossibleStates"],
|
||||
queryFn: () => getPossibleStates(),
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
console.log(data);
|
||||
const newComplaints = data?.filter((item: any) => item.status == 0);
|
||||
const inProgressComplaints = data?.filter((item: any) => item.status == 1);
|
||||
const waitingForCitizenResponseComplaints = data?.filter(
|
||||
(item: any) => item.status == 2
|
||||
);
|
||||
const citizenRepliedComplaints = data?.filter(
|
||||
(item: any) => item.status == 3
|
||||
);
|
||||
const finishedComplaints = data?.filter((item: any) => item.status == 4);
|
||||
console.log(newComplaints);
|
||||
|
||||
// console.log(dataState[0]?.title);
|
||||
|
||||
const { data, isLoading, refetch } = useQuery({
|
||||
queryKey: ["ComplaintsList" ,psblState,dataState],
|
||||
queryFn: () => getComplaintsList(psblState),
|
||||
refetchOnWindowFocus: false,
|
||||
});
|
||||
console.log("dataState", dataState);
|
||||
console.log("psblState", psblState);
|
||||
console.log("data", data);
|
||||
|
||||
// useEffect(() => {
|
||||
// // Handle the data after it has been updated
|
||||
// console.log(data);
|
||||
// }, [data]);
|
||||
|
||||
return (
|
||||
<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">
|
||||
<Tabs
|
||||
defaultValue={selectedTab}
|
||||
value={selectedTab}
|
||||
// onClick={(value) => {
|
||||
// setPsblState(value);
|
||||
// setSelectedTab(value);
|
||||
// refetch();
|
||||
// }}
|
||||
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">
|
||||
<TabsList className="w-full flex gap-1 md:gap-4 lg:gap-3">
|
||||
<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 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>
|
||||
{dataState?.map((item: any) => {
|
||||
return (
|
||||
<TabsTrigger
|
||||
key={item.value}
|
||||
className="hover:border-b-2 border-b-blue max-md:flex-1"
|
||||
value={item.value}
|
||||
onClick={() => {
|
||||
setPsblState(item.value);
|
||||
setSelectedTab(item.value);
|
||||
refetch();
|
||||
}}
|
||||
>
|
||||
{item.title}
|
||||
</TabsTrigger>
|
||||
);
|
||||
})}
|
||||
</TabsList>
|
||||
|
||||
{/* Search Box */}
|
||||
|
|
@ -117,40 +128,11 @@ export default function TabController() {
|
|||
</div>
|
||||
|
||||
{/* Tab Content */}
|
||||
<TabsContent value="tab1">
|
||||
<TableController
|
||||
checkKey={(item: any) => checkKey(item)}
|
||||
data={newComplaints}
|
||||
/>
|
||||
|
||||
<TabsContent value={selectedTab} key={selectedTab}>
|
||||
<TableController checkKey={(item) => checkKey(item)} data={data} />
|
||||
</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="tab4">
|
||||
<TableController
|
||||
checkKey={(item: any) => checkKey(item)}
|
||||
data={citizenRepliedComplaints}
|
||||
/>
|
||||
</TabsContent>
|
||||
|
||||
<TabsContent value="tab5">
|
||||
<TableController
|
||||
checkKey={(item: any) => checkKey(item)}
|
||||
data={finishedComplaints}
|
||||
/>
|
||||
</TabsContent>
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -84,12 +84,16 @@ export default function TableController({
|
|||
password: Decrypt(item.cipherKeyInspector, selectedFile),
|
||||
});
|
||||
secureLocalStorage.setItem("trackingNumber", item.trackingNumber);
|
||||
secureLocalStorage.setItem(
|
||||
"privateKey",
|
||||
Decrypt(item.cipherKeyInspector, selectedFile)
|
||||
);
|
||||
secureLocalStorage.setItem("privateKey", selectedFile);
|
||||
// secureLocalStorage.setItem(
|
||||
// "privateKey",
|
||||
// Decrypt(item.cipherKeyInspector, selectedFile)
|
||||
// );
|
||||
router.push(`/UserPanel/ControllerDashboard/Complaints/${item.id}`);
|
||||
} else {
|
||||
// toast("******کلید شما معتبر نمی باشد.", {
|
||||
// className: "!bg-red-500 !text-white",
|
||||
// });
|
||||
}
|
||||
};
|
||||
console.log(check);
|
||||
|
|
@ -100,8 +104,9 @@ export default function TableController({
|
|||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>ردیف</TableHead>
|
||||
<TableHead>تاریخ</TableHead>
|
||||
<TableHead>کد پیگیری</TableHead>
|
||||
<TableHead> تاریخ ثبت</TableHead>
|
||||
<TableHead>تاریخ</TableHead>
|
||||
<TableHead>موضوع</TableHead>
|
||||
<TableHead>دستگاه مربوطه</TableHead>
|
||||
</TableRow>
|
||||
|
|
@ -126,14 +131,17 @@ export default function TableController({
|
|||
<TableCell className="w-1/12 font-medium ">
|
||||
{index + 1}
|
||||
</TableCell>
|
||||
<TableCell className="w-1/12">{item.trackingNumber}</TableCell>
|
||||
<TableCell className="w-2/12">
|
||||
{convertDate(item.registeredAt)}
|
||||
</TableCell>
|
||||
<TableCell className="w-2/12">{item.trackingNumber}</TableCell>
|
||||
<TableCell className="w-2/12">
|
||||
{convertDate(item.lastChanged)}
|
||||
</TableCell>
|
||||
<TableCell className="w-3/12">
|
||||
{item?.title ? item.title : "-"}
|
||||
</TableCell>
|
||||
<TableCell className="w-5/12">
|
||||
<TableCell className="w-3/12">
|
||||
{item?.complaintOrganization
|
||||
? item?.complaintOrganization.title
|
||||
: "-"}
|
||||
|
|
|
|||
|
|
@ -130,17 +130,17 @@ export const callUsItems = [
|
|||
];
|
||||
|
||||
export const ControllerMenuItems = [
|
||||
{ id: 1, name: "داشبورد", href: "/UserPanel/ControllerDashboard" },
|
||||
{ id: 2, name: "شکایات", href: "/UserPanel/ControllerDashboard/Complaints" },
|
||||
{ id: 1, name: "پیشخوان", href: "/UserPanel/ControllerDashboard" },
|
||||
{ id: 2, name: "گزارش ها", href: "/UserPanel/ControllerDashboard/Complaints" },
|
||||
{
|
||||
id: 3,
|
||||
name: "گزارشات و آمار",
|
||||
name: " آمار و اطلاعات",
|
||||
href: "/UserPanel/ControllerDashboard/Reports",
|
||||
},
|
||||
];
|
||||
|
||||
export const AdminMenuItems = [
|
||||
{ id: 1, name: "داشبورد", href: "/UserPanel/AdminDashboard" },
|
||||
{ id: 1, name: "پیشخوان", href: "/UserPanel/AdminDashboard" },
|
||||
// { id: 2, name: "مدیریت کاربران", href: "/UserPanel/AdminDashboard/UserManagement" },
|
||||
{
|
||||
id: 3,
|
||||
|
|
@ -149,6 +149,7 @@ export const AdminMenuItems = [
|
|||
},
|
||||
{ id: 4, name: "سازمان ها", href: "/UserPanel/AdminDashboard/Organizations" },
|
||||
{ id: 5, name: "دسته بندی ها", href: "/UserPanel/AdminDashboard/Categories" },
|
||||
{ id: 6, name: "مدیریت محتوا", href: "/UserPanel/AdminDashboard/WebContents" },
|
||||
];
|
||||
|
||||
export const ControllerTableItems = [
|
||||
|
|
|
|||
|
|
@ -127,3 +127,31 @@ export async function DeleteOrganization({
|
|||
|
||||
return data.data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// .....WebContents.......
|
||||
export async function GetWebContents() {
|
||||
const data = await axios.get("api/WebContents");
|
||||
return data.data;
|
||||
}
|
||||
|
||||
export async function GetSingleWebContents({ id }: { id: string }) {
|
||||
const data = await axios.get(`api/WebContents/${id}`);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
|
||||
export async function SubmitWebContents( payload: FormData) {
|
||||
const data = await axios.post(`api/WebContents`, payload, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return data.data;
|
||||
}
|
||||
|
||||
export async function UpdateWebContents({ id }: { id: string } , payload: FormData) {
|
||||
const data = await axios.put(`api/WebContents/${id}`, payload, {
|
||||
headers: { "Content-Type": "multipart/form-data" },
|
||||
});
|
||||
return data.data;
|
||||
}
|
||||
|
|
@ -1,22 +1,22 @@
|
|||
import axios from "axios";
|
||||
import { CookieValueTypes } from "cookies-next";
|
||||
|
||||
|
||||
// Get Category
|
||||
export async function getCategory() {
|
||||
const data = await axios.get(
|
||||
"api/Common/Categories",
|
||||
);
|
||||
return data.data;
|
||||
}
|
||||
const data = await axios.get("api/Common/Categories");
|
||||
return data.data;
|
||||
}
|
||||
|
||||
|
||||
// Get Captcha
|
||||
// Get Captcha
|
||||
export async function getCaptcha() {
|
||||
const data = await axios.get(
|
||||
"api/Common/Captcha", {responseType:'blob'}
|
||||
);
|
||||
console.log(data)
|
||||
return data;
|
||||
}
|
||||
const data = await axios.get("api/Common/Captcha", { responseType: "blob" });
|
||||
console.log(data);
|
||||
return data;
|
||||
}
|
||||
|
||||
// Get Captcha
|
||||
export async function getContents() {
|
||||
const data = await axios.get("api/Common/Contents");
|
||||
console.log(data);
|
||||
return data.data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,15 @@ axios.interceptors.request.use(function (config) {
|
|||
return config;
|
||||
});
|
||||
|
||||
export async function getComplaintsList() {
|
||||
const data = await axios.get(`api/Inspector/List`);
|
||||
export async function getPossibleStates() {
|
||||
const data = await axios.get(`api/Inspector/PossibleStates`);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
export async function getComplaintsList(states: number = 0) {
|
||||
// export async function getComplaintsList() {
|
||||
// const data = await axios.get(`api/Inspector/List`);
|
||||
const data = await axios.get(`api/Inspector/List?States=${states}`);
|
||||
return data.data;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue