diff --git a/app/UserPanel/(Admin)/AdminDashboard/WebContents/page.tsx b/app/UserPanel/(Admin)/AdminDashboard/WebContents/page.tsx new file mode 100644 index 0000000..a33de19 --- /dev/null +++ b/app/UserPanel/(Admin)/AdminDashboard/WebContents/page.tsx @@ -0,0 +1,9 @@ + +import AdminWebContents from '@/components/AdminWebContents' +import React from 'react' + +export default function page() { + return ( + + ) +} diff --git a/components/AdminWebContents.tsx b/components/AdminWebContents.tsx new file mode 100644 index 0000000..ed7e7ec --- /dev/null +++ b/components/AdminWebContents.tsx @@ -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 ( +
+
+ fsfdsffsdf +
+
+ ); +} diff --git a/components/ComplainsDetails.tsx b/components/ComplainsDetails.tsx index f4fba85..3b3749e 100644 --- a/components/ComplainsDetails.tsx +++ b/components/ComplainsDetails.tsx @@ -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, @@ -56,19 +59,30 @@ export default function ComplainsDetails({ }, onError: (err) => {}, }); - + 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 ( <> @@ -230,7 +248,7 @@ export default function ComplainsDetails({ }} type="submit" > - ذخیره + مشاهده @@ -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" > @@ -250,7 +268,7 @@ export default function ComplainsDetails({
-
+

انجام عملیات @@ -265,7 +283,7 @@ export default function ComplainsDetails({

-
+
{data.user == null ? ( <>
diff --git a/components/NavbarPanel.tsx b/components/NavbarPanel.tsx index baf63ce..451ea1c 100644 --- a/components/NavbarPanel.tsx +++ b/components/NavbarPanel.tsx @@ -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" diff --git a/components/TabController.tsx b/components/TabController.tsx index 24096c8..f41c59f 100644 --- a/components/TabController.tsx +++ b/components/TabController.tsx @@ -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 (

لیست شکایت ها

- + { + // setPsblState(value); + // setSelectedTab(value); + // refetch(); + // }} + className="" + dir="rtl" + >
{/* Tab Title */} - +

لیست شکایت ها |

- - جدید - - - در انتظار پاسخ - - - در حال بررسی - - - پاسخ داده شده - - - پایان یافته - + {dataState?.map((item: any) => { + return ( + { + setPsblState(item.value); + setSelectedTab(item.value); + refetch(); + }} + > + {item.title} + + ); + })}
{/* Search Box */} @@ -117,40 +128,11 @@ export default function TabController() {
{/* Tab Content */} - - checkKey(item)} - data={newComplaints} - /> - - - - checkKey(item)} - data={waitingForCitizenResponseComplaints} - /> - - - - checkKey(item)} - data={inProgressComplaints} - /> - - - - checkKey(item)} - data={citizenRepliedComplaints} - /> - - - - checkKey(item)} - data={finishedComplaints} - /> + + + checkKey(item)} data={data} /> +
); diff --git a/components/TableController.tsx b/components/TableController.tsx index a041425..2a2f5ab 100644 --- a/components/TableController.tsx +++ b/components/TableController.tsx @@ -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({ ردیف - تاریخ کد پیگیری + تاریخ ثبت + تاریخ موضوع دستگاه مربوطه @@ -126,14 +131,17 @@ export default function TableController({ {index + 1} + {item.trackingNumber} {convertDate(item.registeredAt)} - {item.trackingNumber} + {convertDate(item.lastChanged)} + + {item?.title ? item.title : "-"} - + {item?.complaintOrganization ? item?.complaintOrganization.title : "-"} diff --git a/constants/index.tsx b/constants/index.tsx index d406316..8c1e3bf 100644 --- a/constants/index.tsx +++ b/constants/index.tsx @@ -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 = [ diff --git a/utils/adminApi.ts b/utils/adminApi.ts index d1e304f..792cd1a 100644 --- a/utils/adminApi.ts +++ b/utils/adminApi.ts @@ -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; +} \ No newline at end of file diff --git a/utils/commonApi.ts b/utils/commonApi.ts index 05a0acc..68c0389 100644 --- a/utils/commonApi.ts +++ b/utils/commonApi.ts @@ -1,22 +1,22 @@ import axios from "axios"; import { CookieValueTypes } from "cookies-next"; - -// Get Category +// 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; +} diff --git a/utils/inspectorApi.ts b/utils/inspectorApi.ts index c37cec4..d91c1db 100644 --- a/utils/inspectorApi.ts +++ b/utils/inspectorApi.ts @@ -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; }