Compare commits
4 Commits
96dcc0ab3f
...
c423d5ef84
| Author | SHA1 | Date |
|---|---|---|
|
|
c423d5ef84 | |
|
|
4eba3d1c16 | |
|
|
b01ea3201e | |
|
|
0e80cc7264 |
|
|
@ -1,8 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import CallUs from "@/components/CallUs";
|
|
||||||
|
|
||||||
export default function page() {
|
|
||||||
return (
|
|
||||||
<CallUs />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
import CitizenLogin from "@/components/CitizenLogin";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
export default function page() {
|
|
||||||
return <CitizenLogin />;
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import FollowResult from "@/components/FollowResult";
|
|
||||||
|
|
||||||
export default function page() {
|
|
||||||
return (
|
|
||||||
<FollowResult />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import FollowUp from "@/components/FollowUp";
|
|
||||||
|
|
||||||
export default function page() {
|
|
||||||
return (
|
|
||||||
<FollowUp />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import Result from "@/components/RequestResult";
|
|
||||||
|
|
||||||
export default function page() {
|
|
||||||
return (
|
|
||||||
<Result />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import RequestStep1 from "@/components/RequestStep1";
|
|
||||||
|
|
||||||
export default function page() {
|
|
||||||
return (
|
|
||||||
<RequestStep1 />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import RequestStep2 from "@/components/RequestStep2";
|
|
||||||
|
|
||||||
export default function page() {
|
|
||||||
return (
|
|
||||||
<RequestStep2 />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
import AdminCategories from '@/components/AdminCategories'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default function page() {
|
||||||
|
return (
|
||||||
|
<AdminCategories/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default function page() {
|
||||||
|
return (
|
||||||
|
<div>page</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,8 @@
|
||||||
|
import AdminOrganizations from '@/components/AdminOrganizations'
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default function page() {
|
||||||
|
return (
|
||||||
|
<AdminOrganizations />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,22 @@
|
||||||
import NavbarPanel from "@/components/NavbarPanel";
|
import NavbarPanel from "@/components/NavbarPanel";
|
||||||
|
import { cookies } from "next/headers";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default function RootLayout({
|
export default function RootLayout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
return (
|
const cookieStore = cookies();
|
||||||
<>
|
const token = cookieStore.get("Sootzani_Token");
|
||||||
|
if (!token?.value) {
|
||||||
<NavbarPanel />
|
return redirect("/");
|
||||||
{children}
|
}
|
||||||
</>
|
|
||||||
)
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<NavbarPanel />
|
||||||
|
{children}
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import AdminDashboard from "@/components/AdminDashboard";
|
import AdminDashboard from "@/components/AdminDashboard";
|
||||||
|
import ControllerDashboard from "@/components/ControllerDashboard";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default function page() {
|
export default function page() {
|
||||||
return (
|
return <ControllerDashboard />;
|
||||||
<AdminDashboard />
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +0,0 @@
|
||||||
import NavbarPanel from "@/components/NavbarPanel";
|
|
||||||
|
|
||||||
export default function RootLayout({
|
|
||||||
children,
|
|
||||||
}: {
|
|
||||||
children: React.ReactNode;
|
|
||||||
}) {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
|
|
||||||
<NavbarPanel />
|
|
||||||
{children}
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -3,16 +3,10 @@ import React from "react";
|
||||||
|
|
||||||
export default function page({ params }: { params: any }) {
|
export default function page({ params }: { params: any }) {
|
||||||
const id = params.id;
|
const id = params.id;
|
||||||
{
|
|
||||||
console.log(params);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
console.log(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
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">
|
<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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
import NavbarPanel from "@/components/NavbarPanel";
|
import NavbarPanel from "@/components/NavbarPanel";
|
||||||
import { cookies } from "next/headers";
|
import { cookies } from "next/headers";
|
||||||
import { redirect } from "next/navigation";
|
import { redirect } from "next/navigation";
|
||||||
|
|
||||||
export default function RootLayout({
|
export default function RootLayout({
|
||||||
children,
|
children,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
}) {
|
}) {
|
||||||
// const cookieStore = cookies();
|
const cookieStore = cookies();
|
||||||
// const token = cookieStore.get("Sootzani-Token");
|
const token = cookieStore.get("Sootzani_Token");
|
||||||
// if (!token.value) {
|
if (!token?.value) {
|
||||||
// return redirect("/");
|
return redirect("/");
|
||||||
// }
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NavbarPanel />
|
<NavbarPanel />
|
||||||
<div className="mt-10 mx-auto container">{children}</div>
|
<div className="mt-10 mx-auto px-2">{children}</div>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,189 +0,0 @@
|
||||||
"use client";
|
|
||||||
import React from "react";
|
|
||||||
import Navbar from "../../components/Navbar";
|
|
||||||
import Counter from "../../components/Counter";
|
|
||||||
import SubmitRequest from "../../components/SubmitRequest";
|
|
||||||
import { boxItems, newsItems } from "@/constants";
|
|
||||||
import Image from "next/image";
|
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
import Link from "next/link";
|
|
||||||
import bgimg from "../../public/img/bg.png";
|
|
||||||
import Footer from "@/components/Footer";
|
|
||||||
|
|
||||||
// Import Swiper React components
|
|
||||||
import { Swiper, SwiperSlide } from "swiper/react";
|
|
||||||
// Import Swiper styles
|
|
||||||
import "swiper/css";
|
|
||||||
import "swiper/css/pagination";
|
|
||||||
// import required modules
|
|
||||||
import { Autoplay, Pagination, Navigation} from "swiper/modules";
|
|
||||||
import { sliderItems } from "@/constants";
|
|
||||||
|
|
||||||
export default function Landing() {
|
|
||||||
return (
|
|
||||||
<div className="overflow-x-hidden">
|
|
||||||
<div className="w-screen bg-top lg:bg-center bg-no-repeat h-[13rem] sm:h-[20rem] md:h-[24rem] xl:h-[33rem]">
|
|
||||||
<Swiper
|
|
||||||
slidesPerView={1}
|
|
||||||
spaceBetween={0}
|
|
||||||
autoplay={{
|
|
||||||
delay: 2500,
|
|
||||||
disableOnInteraction: false,
|
|
||||||
}}
|
|
||||||
loop={false}
|
|
||||||
pagination={{
|
|
||||||
clickable: true,
|
|
||||||
}}
|
|
||||||
modules={[Autoplay]}
|
|
||||||
|
|
||||||
className="mySwiper w-full h-full"
|
|
||||||
>
|
|
||||||
{sliderItems.map((item) => {
|
|
||||||
return (
|
|
||||||
<SwiperSlide key={item.id}>
|
|
||||||
<Image
|
|
||||||
alt="bg"
|
|
||||||
src={bgimg}
|
|
||||||
// width={20}
|
|
||||||
// height={20}
|
|
||||||
quality={100}
|
|
||||||
className=" w-full h-full object-cover max-sm:object-[70%]"
|
|
||||||
/>
|
|
||||||
</SwiperSlide>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Swiper>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="3xl:w-[60%] w-[75%] mx-auto max-md:mt-5">
|
|
||||||
<div className="flex justify-between gap-6 w-full mx-auto -mt-24 max-md:mt-0 max-sm:flex-wrap max-sm:justify-around ">
|
|
||||||
{boxItems.map((item, index) => {
|
|
||||||
return (
|
|
||||||
<Link
|
|
||||||
className="group bg-white shadow-md rounded-lg p-10 h-64 w-64 flex items-end justify-center z-10 relative
|
|
||||||
hover:bg-blue transition-all duration-700 ease-in-out text-center
|
|
||||||
hover:flex-col-reverse hover:justify-evenly hover:items-center hover:cursor-pointer
|
|
||||||
max-lg:w-52 max-lg:h-52 max-md:w-40 max-md:h-40
|
|
||||||
max-lg:p-8 max-md:p-5 max-sm:p-2 hover:max-lg:p-2
|
|
||||||
max-md:shadow-[0px_0px_8px_0px_#00000040]
|
|
||||||
"
|
|
||||||
key={index}
|
|
||||||
href={item.link}
|
|
||||||
>
|
|
||||||
<p className="text-xs text-center font-medium text-gray hidden group-hover:flex ">
|
|
||||||
{item.description}
|
|
||||||
</p>
|
|
||||||
<p className=" z-10 text-base text-black group-hover:text-white max-md:text-sm">
|
|
||||||
{item.name}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<Image
|
|
||||||
alt="icon"
|
|
||||||
src={item.icon}
|
|
||||||
width={20}
|
|
||||||
height={20}
|
|
||||||
quality={100}
|
|
||||||
key={index}
|
|
||||||
className={cn(
|
|
||||||
" w-[80%] h-[80%] absolute left-2 top-6 group-hover:hidden max-md:h-[60%] max-md:w-[60%] max-md:left-auto",
|
|
||||||
item.id == 1 && "left-8"
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Image
|
|
||||||
alt="icon"
|
|
||||||
src={item.icon2}
|
|
||||||
width={20}
|
|
||||||
height={20}
|
|
||||||
quality={100}
|
|
||||||
key={index}
|
|
||||||
className=" w-[45%] h-[45%] hidden group-hover:flex"
|
|
||||||
/>
|
|
||||||
</Link>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* News */}
|
|
||||||
<div className=" border mt-6 mx-auto py-3 px-4 rounded-lg">
|
|
||||||
آخرین اخبار
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
className=" w-full mt-6 flex flex-row gap-8 mb-14
|
|
||||||
max-lg:flex-col max-lg:gap-4
|
|
||||||
"
|
|
||||||
>
|
|
||||||
{/* Right News */}
|
|
||||||
<div
|
|
||||||
className=" w-1/2 max-lg:w-full border rounded-lg flex flex-row shadow-md hover:shadow-none transition-all
|
|
||||||
max-lg:h-[14em] max-md:h-[12em] max-sm:h-[22em] max-sm:flex-col max-sm:gap-[3px]"
|
|
||||||
>
|
|
||||||
<div className="w-1/2 h-full rounded-r-lg bg-rose-400 max-sm:h-1/2 max-md:w-1/3 max-sm:w-full">
|
|
||||||
<Image
|
|
||||||
alt="picture"
|
|
||||||
src="/img/pic1.png"
|
|
||||||
height={500}
|
|
||||||
width={500}
|
|
||||||
style={{ objectFit: "fill", objectPosition: "center" }}
|
|
||||||
className="w-full h-full rounded-r-lg"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className=" w-1/2 h-full flex flex-col p-8 justify-between max-lg:p-4 max-md:justify-evenly max-md:w-2/3 max-sm:h-1/2 max-sm:w-full">
|
|
||||||
<p className="text-[10px] font-bold text-right text-white bg-blue p-1 rounded ">
|
|
||||||
اخبار
|
|
||||||
</p>
|
|
||||||
<p className="text-xs font-medium text-right text-black">
|
|
||||||
24 آذر ماه 1402
|
|
||||||
</p>
|
|
||||||
<p className="text-base font-medium text-right text-black line-clamp-1">
|
|
||||||
شروع به کار سامانه سوت زنی
|
|
||||||
</p>
|
|
||||||
<p className="text-sm font-normal text-justify text-[#3C3C43D9] line-clamp-5 max-md:line-clamp-2">
|
|
||||||
این سامانه با هدف نظارت بر عملکرد پرستل و نهادهای مرتبط با امور
|
|
||||||
مردمی در شهرداری استان یزد در زمستان 1402 شروع به فعالیت نموده
|
|
||||||
است ...
|
|
||||||
</p>
|
|
||||||
<Link
|
|
||||||
href="#"
|
|
||||||
className="text-[10px] font-normal text-blue text-left"
|
|
||||||
>
|
|
||||||
بیشتر بخوانید{" "}
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/* Left News */}
|
|
||||||
<div className=" w-1/2 max-lg:w-full flex flex-col gap-[2px] max-lg:gap-4">
|
|
||||||
{newsItems.map((item, index) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className=" w-full h-1/3 flex flex-col border rounded-lg justify-between px-8 py-[10px] hover:shadow-[0px_0px_8px_0px_#00000040] transition-all
|
|
||||||
max-lg:px-4 max-lg:gap-3"
|
|
||||||
key={index}
|
|
||||||
>
|
|
||||||
<div className="flex flex-row justify-between items-center max-sm:flex-col-reverse">
|
|
||||||
<p className="text-base font-medium text-right text-black max-sm:self-start">
|
|
||||||
{item.title}
|
|
||||||
</p>
|
|
||||||
<p className="text-xs font-medium text-right text-black max-sm:self-end">
|
|
||||||
{item.date}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<p className="text-sm font-normal text-justify text-[#3C3C43D9] max-md:line-clamp-2">
|
|
||||||
{item.content}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/* Counter */}
|
|
||||||
<Counter />
|
|
||||||
{/*SubmitRequest */}
|
|
||||||
<SubmitRequest />
|
|
||||||
{/* Footer */}
|
|
||||||
<Footer />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { Toaster as SonnerToaster } from "@/components/ui/sonner";
|
||||||
const inter = Inter({ subsets: ["latin"] });
|
const inter = Inter({ subsets: ["latin"] });
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Create Next App",
|
title: "سوت زنی",
|
||||||
description: "Generated by create next app",
|
description: "Generated by create next app",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -20,9 +20,9 @@ export default function RootLayout({
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<html lang="fa" dir="rtl">
|
<html lang="fa" dir="rtl">
|
||||||
<body className="font-[yekan] ">
|
<body className="font-[yekan] bg-white">
|
||||||
<Provider>
|
<Provider>
|
||||||
{children}
|
{children}
|
||||||
<Toaster />
|
<Toaster />
|
||||||
<SonnerToaster />
|
<SonnerToaster />
|
||||||
</Provider>
|
</Provider>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default function AdminCategories() {
|
||||||
|
return (
|
||||||
|
<div>AdminCategories</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -12,12 +12,12 @@ export default function AdminDashboard() {
|
||||||
<div className="w-full mb-6 flex flex-col gap-4 ">
|
<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 ">
|
<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 />
|
<BoxDashboard />
|
||||||
<BoxDashboard />
|
<BoxDashboard /> */}
|
||||||
<BoxDashboard />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full flex flex-col md:flex-row gap-12 md:gap-1 ">
|
<div className="w-full flex flex-col md:flex-row gap-12 md:gap-1 ">
|
||||||
|
|
@ -26,7 +26,7 @@ export default function AdminDashboard() {
|
||||||
</div>
|
</div>
|
||||||
<hr />
|
<hr />
|
||||||
<div className="w-full md:w-2/3 h-full flex justify-center">
|
<div className="w-full md:w-2/3 h-full flex justify-center">
|
||||||
<VerticalChart />
|
{/* <VerticalChart /> */}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import React, { useState } from "react";
|
import React, { useState, useRef, useEffect } from "react";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useMutation, useQuery, RefetchOptions } from "@tanstack/react-query";
|
||||||
import { GenerateKeyPair, GetKeys } from "@/utils/adminApi";
|
import { GenerateKeyPair, GetKeys, AddKey, ChangeKey } from "@/utils/adminApi";
|
||||||
|
import { FaRegEdit } from "react-icons/fa";
|
||||||
|
import { IoMdClose } from "react-icons/io";
|
||||||
|
import { useRouter } from "next/navigation";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AlertDialog,
|
AlertDialog,
|
||||||
|
|
@ -28,24 +31,180 @@ import {
|
||||||
FormMessage,
|
FormMessage,
|
||||||
} from "@/components/ui/form";
|
} from "@/components/ui/form";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
|
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 FormSchema = z.object({
|
const MAX_FILE_SIZE = 5242880; // 5 MB
|
||||||
// title: z.string().min(2, {
|
// Edit Key Form
|
||||||
// message: "trackingNumber must be at least 2 characters.",
|
const FormSchemaEditKey = z.object({
|
||||||
// }),
|
uploadPrivateKey: z.any(),
|
||||||
// password: z.string().min(4, {
|
// .instanceof(File)
|
||||||
// message: "Password must be at least 4 characters.",
|
|
||||||
// }),
|
// .custom<FileList>((val) => val instanceof FileList, "Required")
|
||||||
// });
|
// .refine((files) => files.length <= 1, "Maximum of 1 file is allowed.")
|
||||||
|
// .refine(
|
||||||
|
// (files) =>
|
||||||
|
// Array.from(files).every((file) => file.size <= MAX_IMAGE_SIZE),
|
||||||
|
// "Each file size should be less than 5 MB."
|
||||||
|
// ),
|
||||||
|
|
||||||
|
// .refine((files) => files?.length === 0, "File is required.")
|
||||||
|
// .refine((files) => files?.length >= 1, "Maximum of 1 file is allowed.")
|
||||||
|
// .refine((files) => files?.[0]?.size <= MAX_FILE_SIZE, `Max file size is 5MB.`)
|
||||||
|
|
||||||
|
// publicKeyId: z
|
||||||
|
// .string()
|
||||||
|
// .nullable(),
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add Key Form
|
||||||
|
const FormSchemaAddKey = z.object({
|
||||||
|
title: z.string().min(2, {
|
||||||
|
message: "عنوان کلید را وارد کنید",
|
||||||
|
}),
|
||||||
|
publicKey: z.string().min(4, {
|
||||||
|
message: "کلید عمومی را وارد کنید",
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
export default function AdminKeysManagement() {
|
export default function AdminKeysManagement() {
|
||||||
|
const router = useRouter();
|
||||||
|
const [keyId, setKeyId] = useState("");
|
||||||
|
const [openAdd, setOpenAdd] = React.useState(false);
|
||||||
|
const [openEdit, setOpenEdit] = React.useState(false);
|
||||||
|
|
||||||
|
const inputPubRef = useRef<HTMLTextAreaElement | null>(null);
|
||||||
|
const inputPrvRef = useRef<HTMLTextAreaElement | null>(null);
|
||||||
|
|
||||||
|
// ..............Read .txt
|
||||||
|
const [selectedFile, setSelectedFile] = useState<any>(null);
|
||||||
|
const handleFileChange = (event: any) => {
|
||||||
|
const file = event.target.files[0];
|
||||||
|
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);
|
||||||
|
|
||||||
|
console.log(reader);
|
||||||
|
console.log(selectedFile);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Edit Form
|
||||||
|
const formEdit = useForm<z.infer<typeof FormSchemaEditKey>>({
|
||||||
|
resolver: zodResolver(FormSchemaEditKey),
|
||||||
|
defaultValues: {
|
||||||
|
// publicKeyId: "",
|
||||||
|
// uploadFile: null,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// ............'Mutation' Change Key Submit
|
||||||
|
const ChangeKeyMutation = useMutation({
|
||||||
|
mutationKey: ["ChangeKey"],
|
||||||
|
mutationFn: ChangeKey,
|
||||||
|
onSuccess: (res) => {
|
||||||
|
console.log(res);
|
||||||
|
// alert("Success");
|
||||||
|
console.log("Success ChangeKey");
|
||||||
|
setOpenEdit(false);
|
||||||
|
|
||||||
|
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||||
|
className: "!bg-green-500 !text-white",
|
||||||
|
});
|
||||||
|
|
||||||
|
// router.refresh()
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.log(error);
|
||||||
|
console.log(error?.message);
|
||||||
|
|
||||||
|
setOpenEdit(false);
|
||||||
|
|
||||||
|
toast(error?.message, {
|
||||||
|
className: "!bg-red-500 !text-black",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function onSubmitEdit(data: z.infer<typeof FormSchemaEditKey>) {
|
||||||
|
console.log("bcbcbbcbcbc" + data);
|
||||||
|
console.log("bcbcbbcbcbccc" + selectedFile);
|
||||||
|
console.log("bcbcbbcbcbccccc" + data1[0]?.id);
|
||||||
|
|
||||||
|
ChangeKeyMutation.mutate({
|
||||||
|
privateKey: selectedFile,
|
||||||
|
publicKeyId: keyId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add Form
|
||||||
|
const formAdd = useForm<z.infer<typeof FormSchemaAddKey>>({
|
||||||
|
resolver: zodResolver(FormSchemaAddKey),
|
||||||
|
defaultValues: {
|
||||||
|
title: "",
|
||||||
|
publicKey: "",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// ............'Mutation' Add Key Submit
|
||||||
|
const AddKeyMutation = useMutation({
|
||||||
|
mutationKey: ["AddKey"],
|
||||||
|
mutationFn: AddKey,
|
||||||
|
onSuccess: (res) => {
|
||||||
|
console.log(res);
|
||||||
|
console.log("Success AddKey");
|
||||||
|
|
||||||
|
setOpenAdd(false);
|
||||||
|
|
||||||
|
refetch1();
|
||||||
|
formAdd.reset();
|
||||||
|
|
||||||
|
if (inputPubRef.current && inputPrvRef.current) {
|
||||||
|
inputPrvRef.current.value = "";
|
||||||
|
inputPubRef.current.value = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||||
|
className: "!bg-green-500 !text-white",
|
||||||
|
});
|
||||||
|
|
||||||
|
// inputPubRef.current.clear();
|
||||||
|
// router.refresh()
|
||||||
|
},
|
||||||
|
onError: (error) => {
|
||||||
|
console.log(error);
|
||||||
|
console.log(error?.message);
|
||||||
|
setOpenAdd(false);
|
||||||
|
|
||||||
|
toast(error?.message, {
|
||||||
|
className: "!bg-red-500 !text-black",
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function onSubmitAdd(data: z.infer<typeof FormSchemaAddKey>) {
|
||||||
|
AddKeyMutation.mutate({
|
||||||
|
title: data.title,
|
||||||
|
publicKey: data.publicKey,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const { resetField } = useForm();
|
||||||
|
|
||||||
// List Keys
|
// List Keys
|
||||||
const {
|
const {
|
||||||
data: data1,
|
data: data1,
|
||||||
error: Error1,
|
error: Error1,
|
||||||
isLoading: isListLoading,
|
isLoading: isListLoading,
|
||||||
refetch: refetch1,
|
refetch: refetch1,
|
||||||
|
isSuccess: isSuccess1,
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["KeysList"],
|
queryKey: ["KeysList"],
|
||||||
queryFn: () => GetKeys(),
|
queryFn: () => GetKeys(),
|
||||||
|
|
@ -59,198 +218,290 @@ export default function AdminKeysManagement() {
|
||||||
error: Error2,
|
error: Error2,
|
||||||
isLoading: isNewKeyLoading,
|
isLoading: isNewKeyLoading,
|
||||||
refetch: refetch2,
|
refetch: refetch2,
|
||||||
|
isSuccess: isSuccess2,
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["GenerateKey"],
|
queryKey: ["GenerateKey"],
|
||||||
queryFn: () => GenerateKeyPair(),
|
queryFn: () => GenerateKeyPair(),
|
||||||
enabled: false, // Disable automatic fetching
|
enabled: false, // Disable automatic fetching
|
||||||
});
|
});
|
||||||
const handleClick = () => {
|
|
||||||
|
// Define the type for refetch2
|
||||||
|
// type RefetchFunction = (options?: RefetchOptions) => Promise<void>;
|
||||||
|
|
||||||
|
const handleClickGenerate = () => {
|
||||||
refetch2();
|
refetch2();
|
||||||
console.log(data2);
|
console.log(data2);
|
||||||
// Manually trigger the query when the button is clicked
|
};
|
||||||
|
useEffect(() => {
|
||||||
|
if (isSuccess2) {
|
||||||
|
formAdd.setValue("publicKey", data2?.publicKey);
|
||||||
|
}
|
||||||
|
}, [isSuccess2]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (inputPubRef.current && inputPrvRef.current) {
|
||||||
|
inputPubRef.current.value = data2?.publicKey ?? "";
|
||||||
|
inputPrvRef.current.value = data2?.privateKey ?? "";
|
||||||
|
}
|
||||||
|
}, [handleClickGenerate]);
|
||||||
|
|
||||||
|
const saveTextFile = () => {
|
||||||
|
const textToSave = data2?.privateKey ?? "";
|
||||||
|
const fileName = "privateKey.txt";
|
||||||
|
|
||||||
|
// 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 (
|
return (
|
||||||
<div className="w-full bg-[#F5F5F5] min-h-[82vh] 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 ">
|
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
|
||||||
{/* 1 */}
|
{/* 1 */}
|
||||||
<AlertDialog>
|
<AlertDialog open={openAdd} onOpenChange={setOpenAdd}>
|
||||||
<AlertDialogTrigger asChild>
|
<AlertDialogContent className=" ">
|
||||||
<Button
|
|
||||||
variant="outline"
|
|
||||||
onClick={handleClick}
|
|
||||||
disabled={isNewKeyLoading}
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
ایجاد جفت کلید
|
|
||||||
</Button>
|
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent className=" w-full max-w-6xl h-full max-h-[80vh]">
|
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>اطلاعات کلید جدید</AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
<AlertDialogDescription>
|
<p className="text-[#464646] text-base font-bold">
|
||||||
{isNewKeyLoading ? (
|
افزودن کلید جدید
|
||||||
<div className="felx justify-center items-center self-center h-full">
|
</p>
|
||||||
<ThreeDots
|
<AlertDialogCancel className="p-0 border-0 h-auto">
|
||||||
visible={true}
|
<IoMdClose />
|
||||||
height="80"
|
</AlertDialogCancel>
|
||||||
width="100"
|
</AlertDialogTitle>
|
||||||
color="#003778"
|
|
||||||
radius="9"
|
|
||||||
ariaLabel="three-dots-loading"
|
|
||||||
wrapperStyle={{}}
|
|
||||||
wrapperClass=""
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className=" " id="KeyFetch">
|
|
||||||
<p className="text-black text-sm font-semibold">
|
|
||||||
کلید عمومی :
|
|
||||||
</p>
|
|
||||||
<p className="text-slate-700 text-sm text-left mb-4">
|
|
||||||
{data2?.publicKey}
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<p className="text-black text-sm font-semibold">
|
<AlertDialogDescription>
|
||||||
کلید خصوصی :
|
<div className=" w-full flex justify-between">
|
||||||
</p>
|
<div className="w-full text-right text-neutral-600 text-lg font-bold mt-4 mb-2">
|
||||||
<p className="text-slate-700 text-sm text-left mb-4">
|
افزودن کلید جدید
|
||||||
{data2?.privateKey}
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
|
||||||
|
<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>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>بستن</AlertDialogCancel>
|
{/* <AlertDialogCancel>بستن</AlertDialogCancel> */}
|
||||||
{/* <AlertDialogAction>Continue</AlertDialogAction> */}
|
{/* <AlertDialogAction>Continue</AlertDialogAction> */}
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
|
||||||
|
|
||||||
{/* 1 */}
|
{/* 2 */}
|
||||||
<AlertDialog>
|
<div className=" w-full flex justify-between items-center mt-1">
|
||||||
<AlertDialogTrigger asChild>
|
<div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
|
||||||
<Button
|
لیست کلیدها
|
||||||
variant="outline"
|
</div>
|
||||||
onClick={handleClick}
|
<AlertDialogTrigger asChild>
|
||||||
disabled={isNewKeyLoading}
|
<Button
|
||||||
>
|
variant="outline"
|
||||||
افزودن کلید جدید
|
className="bg-orange-500 hover:bg-orange-500/80 text-white hover:text-white"
|
||||||
</Button>
|
// disabled={isNewKeyLoading}
|
||||||
</AlertDialogTrigger>
|
|
||||||
<AlertDialogContent className=" w-full max-w-6xl h-full max-h-[80vh]">
|
|
||||||
<AlertDialogHeader>
|
|
||||||
<AlertDialogTitle>افزودن کلید جدید</AlertDialogTitle>
|
|
||||||
<AlertDialogDescription>
|
|
||||||
{isNewKeyLoading ? (
|
|
||||||
<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>
|
|
||||||
) : (
|
|
||||||
<></>
|
|
||||||
// <Form {...form}>
|
|
||||||
// <form
|
|
||||||
// onSubmit={form.handleSubmit(onSubmit)}
|
|
||||||
// className="w-full flex flex-col mt-6 "
|
|
||||||
// >
|
|
||||||
// <div className="flex flex-row flex-wrap justify-between">
|
|
||||||
// <FormField
|
|
||||||
// control={form.control}
|
|
||||||
// name="trackingNumber"
|
|
||||||
// render={({ field }) => (
|
|
||||||
// <FormItem className=" w-full lg:w-[48%]">
|
|
||||||
// <FormLabel className="text-[#7C838A] text-sm font-medium">
|
|
||||||
// کد پیگیری
|
|
||||||
// </FormLabel>
|
|
||||||
// <FormControl>
|
|
||||||
// <Input
|
|
||||||
// placeholder="کد پیگیری خود را وارد نمایید"
|
|
||||||
// {...field}
|
|
||||||
// />
|
|
||||||
// </FormControl>
|
|
||||||
// <FormMessage />
|
|
||||||
// </FormItem>
|
|
||||||
// )}
|
|
||||||
// />
|
|
||||||
|
|
||||||
// <FormField
|
|
||||||
// control={form.control}
|
|
||||||
// name="password"
|
|
||||||
// render={({ field }) => (
|
|
||||||
// <FormItem className=" w-full lg:w-[48%]">
|
|
||||||
// <FormLabel className="text-[#7C838A] text-sm font-medium ">
|
|
||||||
// رمز عبور
|
|
||||||
// </FormLabel>
|
|
||||||
// <FormControl>
|
|
||||||
// <Input
|
|
||||||
// placeholder="رمز عبور خود را وارد کنید"
|
|
||||||
// {...field}
|
|
||||||
// />
|
|
||||||
// </FormControl>
|
|
||||||
// <FormMessage />
|
|
||||||
// </FormItem>
|
|
||||||
// )}
|
|
||||||
// />
|
|
||||||
// </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 w-1/2 sm:w-1/3 lg:w-1/4 p-2 rounded-xl text-center"
|
|
||||||
// >
|
|
||||||
// پیگیری درخواست
|
|
||||||
// </Button>
|
|
||||||
// </div>
|
|
||||||
// </form>
|
|
||||||
// </Form>
|
|
||||||
)}
|
|
||||||
</AlertDialogDescription>
|
|
||||||
</AlertDialogHeader>
|
|
||||||
<AlertDialogFooter>
|
|
||||||
<AlertDialogCancel>بستن</AlertDialogCancel>
|
|
||||||
{/* <AlertDialogAction>Continue</AlertDialogAction> */}
|
|
||||||
</AlertDialogFooter>
|
|
||||||
</AlertDialogContent>
|
|
||||||
</AlertDialog>
|
|
||||||
|
|
||||||
<div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
|
|
||||||
لیست کلیدها
|
|
||||||
</div>
|
|
||||||
{/* 2 */}
|
|
||||||
<div className="w-full flex flex-row max-md:flex-wrap justify-between gap-3">
|
|
||||||
{data1?.map((item: any) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={item.id}
|
|
||||||
className={`flex flex-col justify-center gap-2 w-full lg:w-1/2 h-28 px-5 bg-white rounded-md shadow-md items-start
|
|
||||||
`}
|
|
||||||
>
|
>
|
||||||
<p className=" text-slate-500 text-sm font-normal leading-normal">
|
افزودن کلید جدید
|
||||||
عنوان کلید :
|
</Button>
|
||||||
<span className=" text-slate-800">{item.title}</span>
|
</AlertDialogTrigger>
|
||||||
</p>
|
</div>
|
||||||
<p className=" text-slate-500 text-sm font-normal leading-normal">
|
<div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
|
||||||
آی دی بازرس :
|
{data1?.map((item: any) => {
|
||||||
<span className=" text-slate-800 self-end">
|
return (
|
||||||
{item.inspectorId}
|
<div
|
||||||
</span>
|
key={item.id}
|
||||||
</p>
|
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]
|
||||||
</div>
|
`}
|
||||||
);
|
>
|
||||||
})}
|
<p className=" text-slate-500 text-sm font-normal leading-normal">
|
||||||
</div>
|
عنوان کلید:{" "}
|
||||||
|
<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>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* <FormField
|
||||||
|
control={formEdit.control}
|
||||||
|
name="publicKeyId"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className=" w-full lg:w-[48%]">
|
||||||
|
<FormLabel className="text-[#7C838A] text-sm font-medium ">
|
||||||
|
آی دی کلید عمومی
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
className="bg-slate-300 mt-2"
|
||||||
|
value={item?.id}
|
||||||
|
readOnly={true}
|
||||||
|
// {...field}
|
||||||
|
/>
|
||||||
|
</FormControl>
|
||||||
|
<FormMessage />
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/> */}
|
||||||
|
</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>
|
||||||
|
|
||||||
|
{/* <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>
|
||||||
|
</AlertDialog>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default function AdminOrganizations() {
|
||||||
|
return (
|
||||||
|
<div>AdminOrganizations</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -24,7 +24,7 @@ import TableAdmin from "./TableAdmin";
|
||||||
|
|
||||||
export default function AdminUserManagement() {
|
export default function AdminUserManagement() {
|
||||||
return (
|
return (
|
||||||
<div className="w-full bg-[#F5F5F5] min-h-[82vh] flex justify-center">
|
<div className="w-full bg-[#F5F5F5] min-h-[85vh] flex justify-center">
|
||||||
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
|
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
|
||||||
<div className="w-full flex flex-col gap-5 ">
|
<div className="w-full flex flex-col gap-5 ">
|
||||||
{/* 1 */}
|
{/* 1 */}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,25 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
|
||||||
export default function BoxDashboard() {
|
export default function BoxDashboard({
|
||||||
|
value,
|
||||||
|
title,
|
||||||
|
}: {
|
||||||
|
value: string;
|
||||||
|
title: string;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="w-full h-full px-7 py-8 bg-zinc-100 rounded-lg shadow flex flex-col justify-end items-center text-black
|
className=" px-7 py-8 bg-zinc-100 rounded-lg shadow flex flex-col justify-end items-center text-black
|
||||||
transition-all duration-300 hover:transition-all hover:duration-300
|
transition duration-200
|
||||||
hover:text-white hover:bg-blue hover:pb-10
|
hover:text-white hover:bg-blue
|
||||||
max-lg:min-h-[10em] max-lg:max-w-[10em]"
|
group h-44 w-44"
|
||||||
>
|
>
|
||||||
<p className="text-center text-sm font-medium ">
|
<div className="group-hover:-translate-y-2 transition-all duration-300">
|
||||||
تعداد درخواست ها 30 روز گذشته
|
<p className="text-center text-xs font-medium">
|
||||||
</p>
|
{value}
|
||||||
|
</p>
|
||||||
|
<p className="text-center text-xs font-medium">{title}</p>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
"use client";
|
|
||||||
import Image from "next/image";
|
|
||||||
import React from "react";
|
|
||||||
import mapImg from "../public/img/map.png";
|
|
||||||
|
|
||||||
import { callUsItems } from "@/constants";
|
|
||||||
import { cn } from "@/lib/utils";
|
|
||||||
import Map from "./Map";
|
|
||||||
|
|
||||||
export default function CallUs(props: any) {
|
|
||||||
const { position, zoom } = props;
|
|
||||||
return (
|
|
||||||
<div className="bg-white dark:bg-gray-900 w-screen">
|
|
||||||
<div className="w-full">
|
|
||||||
<div className="w-full h-[42vh]">
|
|
||||||
{/* <Image
|
|
||||||
src={mapImg}
|
|
||||||
className="object-cover w-full h-full "
|
|
||||||
alt=" Logo1"
|
|
||||||
quality={100}
|
|
||||||
width={100}
|
|
||||||
height={100}
|
|
||||||
/> */}
|
|
||||||
|
|
||||||
<Map />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="container">
|
|
||||||
<div className="grid gap-8 md:gap-0 grid-cols-1 md:grid-cols-3 md:h-[40vh] h-full w-full lg:px-32 xl:px-52 md:py-8 py-12">
|
|
||||||
{callUsItems.map((item) => {
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={item.id}
|
|
||||||
className={cn(
|
|
||||||
" px-4 md:px-6 gap-4 flex justify-center items-center lg:border-l-[1px] border-black h-full",
|
|
||||||
item.id == 3 && " lg:border-l-0 backdrop:"
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
key={item.id}
|
|
||||||
className="p-4 lg:p-6 dark:bg-gray-800 gap-4 flex flex-col justify-between items-center
|
|
||||||
border-black max-md:rounded-lg h-full w-full lg:bg-transparent bg-[#EBEBEB]
|
|
||||||
rounded-lg hover:bg-[#EBEBEB] hover:shadow-[0px_4px_4px_0px_#00000026]
|
|
||||||
hover:transition-all transition-all delay-300 cursor-default"
|
|
||||||
>
|
|
||||||
<span className="inline-block text-orange-500 w-14 h-14">
|
|
||||||
{item.icon}
|
|
||||||
</span>
|
|
||||||
|
|
||||||
<p className=" text-center text-neutral-700 text-lg font-bold dark:text-white">
|
|
||||||
{item.title}
|
|
||||||
</p>
|
|
||||||
<p className="text-center text-neutral-500 text-base dark:text-gray-400 line-clamp-2">
|
|
||||||
{item.description}
|
|
||||||
</p>
|
|
||||||
<p className="text-center text-orange-500 text-lg font-bold">
|
|
||||||
{item.description2}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,199 +0,0 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
import React from "react";
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import * as z from "zod";
|
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { toast } from "@/components/ui/use-toast";
|
|
||||||
import Image from "next/image";
|
|
||||||
import LoginIcon from "../public/img/login-icon.svg";
|
|
||||||
import { useMutation, useQuery } from "@tanstack/react-query";
|
|
||||||
import { loginStaff, logisterCitizen } from "@/utils/authenticateApi";
|
|
||||||
import { getCaptcha } from "@/utils/commonApi";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { Oval, ThreeDots } from "react-loader-spinner";
|
|
||||||
import useData from "@/store/useData";
|
|
||||||
const FormSchema = z.object({
|
|
||||||
phoneNumber: z.string().min(1, {
|
|
||||||
message: "لطفا شماره موبایل خود را وارد نمایید.",
|
|
||||||
}),
|
|
||||||
captcha: z
|
|
||||||
.string({ required_error: "لطفا کد امنیتی را وارد نمایید." })
|
|
||||||
.length(5, { message: "لطفا کد امنیتی را به طور کامل وارد نمایید." }),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function CitizenLogin() {
|
|
||||||
const router = useRouter();
|
|
||||||
const saveData = useData((state) => state.saveData);
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: CaptchaData,
|
|
||||||
isLoading,
|
|
||||||
refetch,
|
|
||||||
} = useQuery({
|
|
||||||
queryKey: ["Captcha"],
|
|
||||||
queryFn: () => getCaptcha(),
|
|
||||||
refetchOnWindowFocus: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
const loginMutation = useMutation({
|
|
||||||
mutationFn: logisterCitizen,
|
|
||||||
onSuccess: (res) => {},
|
|
||||||
onError: (err: any) => {
|
|
||||||
if (err.response.status == 428) {
|
|
||||||
console.log(useData);
|
|
||||||
router.push("/Verify");
|
|
||||||
localStorage.setItem("VerifyRole", "citizen");
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
|
||||||
resolver: zodResolver(FormSchema),
|
|
||||||
});
|
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
|
||||||
const payload = {
|
|
||||||
phoneNumber: data.phoneNumber,
|
|
||||||
captcha: {
|
|
||||||
key: CaptchaData?.headers["captcha-key"],
|
|
||||||
value: data.captcha,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
loginMutation.mutate(payload);
|
|
||||||
saveData({
|
|
||||||
phoneNumber: data.phoneNumber,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
const srcForImage = CaptchaData
|
|
||||||
? URL.createObjectURL(CaptchaData.data)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
className=" w-[20rem] bg-white rounded-lg dark:border xl:p-0 dark:bg-gray-800 dark:border-gray-700 shadow-[0px_0px_15px_0px_#00000040]
|
|
||||||
h-full max-md:p-8 pt-12"
|
|
||||||
>
|
|
||||||
<div className="space-y-3 md:space-y-4 flex flex-col md:py-10 md:px-12 lg:px-16 h-full justify-center">
|
|
||||||
<Image alt="icon" src={LoginIcon} className="self-center w-1/3 " />
|
|
||||||
|
|
||||||
<p className="text-lg font-bold leading-tight tracking-tight text-blue dark:text-white">
|
|
||||||
احراز هویت
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<Form {...form}>
|
|
||||||
<form
|
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
|
||||||
className="w-full flex flex-col "
|
|
||||||
>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="phoneNumber"
|
|
||||||
rules={{ required: true }}
|
|
||||||
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>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<div className="flex gap-4 mt-4 items-center">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="captcha"
|
|
||||||
rules={{ required: true }}
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" items-center h-10 flex-1">
|
|
||||||
{/* <FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
رمز عبور
|
|
||||||
</FormLabel> */}
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="کد امنیتی" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
{isLoading ? (
|
|
||||||
<div className=" w-36 flex justify-center text-center">
|
|
||||||
<ThreeDots
|
|
||||||
visible={true}
|
|
||||||
height="50"
|
|
||||||
width="50"
|
|
||||||
color="#003778"
|
|
||||||
radius="9"
|
|
||||||
ariaLabel="three-dots-loading"
|
|
||||||
wrapperStyle={{}}
|
|
||||||
wrapperClass=""
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<div className=" flex justify-center text-center">
|
|
||||||
<Image
|
|
||||||
alt="icon"
|
|
||||||
src={srcForImage as string}
|
|
||||||
className=" h-12 rounded-md shadow-md w-36"
|
|
||||||
width={150}
|
|
||||||
height={20}
|
|
||||||
quality={100}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
<div className="flex justify-end gap-2 w-full mt-14">
|
|
||||||
<Button
|
|
||||||
disabled={loginMutation.isPending}
|
|
||||||
type="submit"
|
|
||||||
className="bg-blue hover:bg-blue/90 transition text-white w-1/2 md:w-1/3 p-2 rounded-xl"
|
|
||||||
>
|
|
||||||
{loginMutation.isPending ? (
|
|
||||||
<div className="flex justify-center items-center gap-2">
|
|
||||||
<Oval
|
|
||||||
visible={true}
|
|
||||||
height="20"
|
|
||||||
width="20"
|
|
||||||
color="#fff"
|
|
||||||
ariaLabel="oval-loading"
|
|
||||||
wrapperStyle={{}}
|
|
||||||
wrapperClass=""
|
|
||||||
/>
|
|
||||||
{/* <p>در حال انجام ...</p> */}
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
"تایید"
|
|
||||||
)}
|
|
||||||
{/* ورود */}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"use client";
|
"use client";
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import greenIcon from "../public/img/greenPoint.svg";
|
import greenIcon from "../public/img/greenPoint.svg";
|
||||||
import blueIcon from "../public/img/bluepoint.svg";
|
import blueIcon from "../public/img/bluepoint.svg";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
|
@ -7,11 +7,28 @@ 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 { convertDate } from "@/lib/utils";
|
import { Decrypt, convertDate } from "@/lib/utils";
|
||||||
import { Badge } from "./ui/badge";
|
import { Badge } from "./ui/badge";
|
||||||
import InspectorOperations from "./InspectorOperations";
|
import InspectorOperations from "./InspectorOperations";
|
||||||
import { postComplaintTracking } from "@/utils/citizenApi";
|
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({
|
export default function ComplainsDetails({
|
||||||
id,
|
id,
|
||||||
role,
|
role,
|
||||||
|
|
@ -22,140 +39,333 @@ export default function ComplainsDetails({
|
||||||
Data?: any;
|
Data?: any;
|
||||||
}) {
|
}) {
|
||||||
const storeData = useData((state) => state.data);
|
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;
|
let data;
|
||||||
|
|
||||||
const getComplaintMutation = useMutation<
|
const getComplaintMutation = useMutation({
|
||||||
any,
|
|
||||||
Error,
|
|
||||||
{ trackingNumber: string; password: string }
|
|
||||||
>({
|
|
||||||
mutationKey: ["Complaint", id],
|
mutationKey: ["Complaint", id],
|
||||||
mutationFn:
|
mutationFn: getComplaint,
|
||||||
role == "Inspector"
|
|
||||||
? (getComplaint as any)
|
|
||||||
: (postComplaintTracking as any),
|
|
||||||
onSuccess: (res) => {},
|
onSuccess: (res) => {},
|
||||||
onError: (err) => {},
|
onError: (err) => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(storeData);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (role == "Inspector") {
|
const tn = localStorage.getItem("trackingNumber") as string;
|
||||||
useData.persist.rehydrate();
|
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(() => {
|
useEffect(() => {
|
||||||
if (storeData && role == "Inspector") {
|
const storedData = localStorage.getItem("CompliantData");
|
||||||
getComplaintMutation.mutate(storeData);
|
const data = JSON.parse(storedData as string);
|
||||||
}
|
setComplaintData(data);
|
||||||
}, [storeData]);
|
}, []);
|
||||||
|
|
||||||
if (getComplaintMutation.isSuccess) {
|
if (getComplaintMutation.isSuccess) {
|
||||||
data = getComplaintMutation.data;
|
data = getComplaintMutation.data;
|
||||||
} else if (Data) {
|
|
||||||
data = Data;
|
|
||||||
}
|
}
|
||||||
console.log(Data);
|
|
||||||
|
const openFileInNewTab = (base64Data: any, fileType: any) => {
|
||||||
|
const blob = b64toBlob(base64Data, fileType);
|
||||||
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
|
const newTab = window.open();
|
||||||
|
if (newTab) {
|
||||||
|
newTab.document.write(
|
||||||
|
'<html style="height: 100%;"><head><title>File Preview</title></head><body style="margin: 0; padding: 0; height: 100%; overflow: hidden;">'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check the file type and handle accordingly
|
||||||
|
if (fileType.includes("image")) {
|
||||||
|
newTab.document.write(
|
||||||
|
`<img src="data:${fileType};base64,${base64Data}" alt="File Preview"/>`
|
||||||
|
);
|
||||||
|
} else if (fileType === "application/pdf") {
|
||||||
|
newTab.document.write(
|
||||||
|
`<iframe width="100%" height="100%" src="${blobUrl}"></iframe>`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
newTab.document.write(
|
||||||
|
`<a href="${blobUrl}" target="_blank">Open in New Tab</a>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
newTab.document.write("</body></html>");
|
||||||
|
newTab.document.close();
|
||||||
|
|
||||||
|
URL.revokeObjectURL(blobUrl);
|
||||||
|
} else {
|
||||||
|
console.error("Unable to open a new tab.");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const downloadFile = (base64Data, fileName, fileType) => {
|
||||||
|
const blob = b64toBlob(base64Data, fileType);
|
||||||
|
const blobUrl = URL.createObjectURL(blob);
|
||||||
|
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.href = blobUrl;
|
||||||
|
link.download = fileName;
|
||||||
|
link.click();
|
||||||
|
|
||||||
|
URL.revokeObjectURL(blobUrl);
|
||||||
|
};
|
||||||
|
|
||||||
|
const b64toBlob = (b64Data, contentType = "", sliceSize = 512) => {
|
||||||
|
const byteCharacters = atob(b64Data);
|
||||||
|
const byteArrays = [];
|
||||||
|
|
||||||
|
for (let offset = 0; offset < byteCharacters.length; offset += sliceSize) {
|
||||||
|
const slice = byteCharacters.slice(offset, offset + sliceSize);
|
||||||
|
|
||||||
|
const byteNumbers = new Array(slice.length);
|
||||||
|
for (let i = 0; i < slice.length; i++) {
|
||||||
|
byteNumbers[i] = slice.charCodeAt(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
const byteArray = new Uint8Array(byteNumbers);
|
||||||
|
byteArrays.push(byteArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Blob(byteArrays, { type: contentType });
|
||||||
|
};
|
||||||
|
|
||||||
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{data ? (
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
<div className="w-full flex max-lg:flex-col gap-3 items-start">
|
<DialogContent dir="rtl" className="">
|
||||||
<div className="flex flex-col w-full lg:w-1/3 lg:order-2 gap-3 lg:sticky top-40">
|
<DialogHeader dir="rtl">
|
||||||
<div className=" bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">
|
<DialogTitle dir="rtl">بارگذاری کلید خصوصی</DialogTitle>
|
||||||
<p className="text-[#464646] text-base font-bold">گزارش شکایت</p>
|
<DialogDescription>
|
||||||
<div className="mt-2">
|
برای مشاهده شکایت لطفا کلید خود را آپلود نمایید.
|
||||||
<p className="text-[#2e2a2a] text-sm font-medium">
|
</DialogDescription>
|
||||||
موضوع شکایت:{" "}
|
</DialogHeader>
|
||||||
<span className="text-[#7C838A] text-sm font-medium">
|
<div className="grid w-full max-w-sm items-center gap-1.5">
|
||||||
{data.title}
|
<Input
|
||||||
</span>
|
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>
|
||||||
<p className="text-[#464646] text-sm font-medium">
|
<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 className="text-[#7C838A] text-sm font-medium">
|
||||||
</span>
|
{data?.title}
|
||||||
</p>
|
</span>
|
||||||
<p className="text-[#464646] text-sm font-medium">
|
</p>
|
||||||
پرسنل مربوطه:{" "}
|
<p className="text-[#464646] text-sm font-medium">
|
||||||
<span className="text-[#7C838A] text-sm font-medium">
|
دستگاه مربوطه:{" "}
|
||||||
{/* {data.title} */}
|
<span className="text-[#7C838A] text-sm font-medium">
|
||||||
</span>
|
{data?.complaintOrganization
|
||||||
</p>
|
? data?.complaintOrganization.title
|
||||||
<p className="text-[#464646] text-sm font-medium">
|
: "-"}
|
||||||
زمان ثبت:{" "}
|
</span>
|
||||||
<span className="text-[#7C838A] text-sm font-medium">
|
</p>
|
||||||
{convertDate(data.registeredAt)}
|
<p className="text-[#464646] text-sm font-medium">
|
||||||
</span>
|
پرسنل مربوطه:{" "}
|
||||||
</p>
|
<span className="text-[#7C838A] text-sm font-medium">
|
||||||
{/* <p className="text-[#464646] text-sm font-medium">
|
{data.complaining ? data.complaining : "-"}
|
||||||
{" "}
|
</span>
|
||||||
موضوع شکایت:{" "}
|
</p>
|
||||||
<span className="text-[#7C838A] text-sm font-medium">
|
<p className="text-[#464646] text-sm font-medium">
|
||||||
متن تستی
|
زمان ثبت:{" "}
|
||||||
</span>
|
<span className="text-[#7C838A] text-sm font-medium">
|
||||||
</p> */}
|
{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>
|
</div>
|
||||||
{/* <p className="text-[#464646] text-sm font-medium text-justify">
|
|
||||||
درخواست شما با کد رهگیری {data.trackingNumber} و رمز عبور 12422 در
|
|
||||||
دست بررسی و اقدام می باشد. در صورت تمایل می توانید با شماره تلفن
|
|
||||||
0353286545 جهت پشتیبانی تماس حاصل کنید.{" "}
|
|
||||||
</p> */}
|
|
||||||
</div>
|
</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 className="text-[#464646] text-base font-bold mb-1">
|
||||||
انجام عملیات
|
انجام عملیات
|
||||||
</p>
|
</p>
|
||||||
<InspectorOperations
|
<InspectorOperations
|
||||||
updateData={() => getComplaintMutation.mutate(storeData)}
|
updateData={(data) => getComplaintMutation.mutate(data)}
|
||||||
role={role}
|
role={role}
|
||||||
complaintData={data}
|
complaintData={data}
|
||||||
|
id={id}
|
||||||
|
key={key}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{/* Left */}
|
||||||
<div className="w-full lg:w-2/3 self-stretch bg-[#E9E9E9] p-4 px-10 rounded-lg">
|
{/* <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">روند شکایت</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>
|
|
||||||
</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">
|
|
||||||
<p className="text-[#464646] text-base font-bold mb-3">
|
<p className="text-[#464646] text-base font-bold mb-3">
|
||||||
وضعیت درخواست
|
وضعیت درخواست
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -193,9 +403,24 @@ export default function ComplainsDetails({
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div> */}
|
</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>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -6,50 +6,49 @@ import { HorizontalChart } from "./HorizontalChart";
|
||||||
import { getComplaintsList } from "@/utils/inspectorApi";
|
import { getComplaintsList } from "@/utils/inspectorApi";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import useDecrypt from "@/hooks/useDecrypt";
|
import useDecrypt from "@/hooks/useDecrypt";
|
||||||
|
import { getInfo } from "@/utils/infoApi";
|
||||||
|
|
||||||
export default function ControllerDashboard() {
|
export default function ControllerDashboard() {
|
||||||
const { data, isLoading, refetch } = useQuery({
|
const { data, isLoading, refetch } = useQuery({
|
||||||
queryKey: ["ComplaintsList"],
|
queryKey: ["Infos"],
|
||||||
queryFn: () => getComplaintsList(),
|
queryFn: () => getInfo(),
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
});
|
});
|
||||||
console.log(data);
|
console.log(data);
|
||||||
const [decryptedMessage, errorMessage] = useDecrypt(
|
const [decryptedMessage, errorMessage] = useDecrypt(
|
||||||
"gJoT9AqK7wk1MZFSD04yXXfF36fzsOL+RYtJfySrEnQeJ7VoaL7pmOU6nB3+0+PQcaxIi3hf1AHjzIB0Cn5oHgKROeoI4XslhAezZk23QhtIU4HUF1wpeOJfA+4hWyRfbh4fI9774sa/KL47VaBbrNM/rvBxk6hjlKx5mTb3hqM="
|
"gJoT9AqK7wk1MZFSD04yXXfF36fzsOL+RYtJfySrEnQeJ7VoaL7pmOU6nB3+0+PQcaxIi3hf1AHjzIB0Cn5oHgKROeoI4XslhAezZk23QhtIU4HUF1wpeOJfA+4hWyRfbh4fI9774sa/KL47VaBbrNM/rvBxk6hjlKx5mTb3hqM="
|
||||||
);
|
);
|
||||||
console.log(decryptedMessage);
|
|
||||||
if (data) {
|
|
||||||
}
|
|
||||||
console.log(errorMessage);
|
|
||||||
if (data) {
|
|
||||||
}
|
|
||||||
return (
|
return (
|
||||||
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-8 pt-9 mx-auto">
|
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-12 pt-9 mx-auto px-2">
|
||||||
{/* Lg Show */}
|
{/* Lg Show */}
|
||||||
<div className="w-full h-[45vh] mb-6 flex-row gap-0 hidden lg:flex">
|
<div className="w-full mb-6 flex-col gap-0 flex">
|
||||||
<div className="w-1/5 flex flex-col gap-8 pl-6">
|
<div className="w-full flex flex-row flex-wrap mx-auto justify-center gap-8 mb-10">
|
||||||
<BoxDashboard />
|
{data?.singletons.map((item: any) => {
|
||||||
<BoxDashboard />
|
return <BoxDashboard value={item.value} title={item.title} />;
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-4/5 bg-[#EFEFEF80] rounded-lg flex justify-center">
|
<div className=" bg-[#EFEFEF80] rounded-lg flex justify-center shadow-md">
|
||||||
<LineChart />
|
{data?.charts.map((item: any) => {
|
||||||
|
return (
|
||||||
|
<LineChart chartTitle={item.chartTitle} chartData={item.series} />
|
||||||
|
);
|
||||||
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full flex-row gap-6 h-[20vh] hidden lg:flex">
|
{/* <div className="w-full flex-row gap-6 h-[20vh] hidden lg:flex">
|
||||||
<div className="w-3/5 flex flex-row gap-7">
|
<div className="w-3/5 flex flex-row gap-7">
|
||||||
<BoxDashboard />
|
<BoxDashboard />
|
||||||
<BoxDashboard />
|
<BoxDashboard />
|
||||||
<BoxDashboard />
|
<BoxDashboard />
|
||||||
</div>
|
</div>
|
||||||
<div className="w-2/5 flex justify-end">
|
|
||||||
<HorizontalChart />
|
</div> */}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{/* max Lg show */}
|
{/* max Lg show */}
|
||||||
<div className="w-full mb-6 flex-col gap-12 flex lg:hidden">
|
{/* <div className="w-full mb-6 flex-col gap-12 flex lg:hidden">
|
||||||
<div className="w-full flex flex-row flex-wrap justify-center gap-4 ">
|
<div className="w-full flex flex-row flex-wrap justify-center gap-4 ">
|
||||||
<BoxDashboard />
|
<BoxDashboard />
|
||||||
<BoxDashboard />
|
<BoxDashboard />
|
||||||
|
|
@ -67,7 +66,7 @@ export default function ControllerDashboard() {
|
||||||
<HorizontalChart />
|
<HorizontalChart />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div> */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,84 +0,0 @@
|
||||||
import React from 'react'
|
|
||||||
import { counterItems } from '@/constants'
|
|
||||||
// import patern from "../public/img/paternSvg.png"
|
|
||||||
|
|
||||||
// Import Swiper React components
|
|
||||||
import { Swiper, SwiperSlide } from 'swiper/react';
|
|
||||||
// Import Swiper styles
|
|
||||||
import 'swiper/css';
|
|
||||||
import 'swiper/css/pagination';
|
|
||||||
// import required modules
|
|
||||||
import { Pagination } from 'swiper/modules';
|
|
||||||
|
|
||||||
export default function Counter() {
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<div className="flex justify-center items-center w-full bg-blue bg-[url('../public/img/patern.svg')]"
|
|
||||||
>
|
|
||||||
<div className='3xl:w-[70%] w-[80%] flex flex-row py-24 gap-9 justify-between items-center
|
|
||||||
max-md:gap-4 max-lg:flex-wrap max-lg:justify-center'>
|
|
||||||
{counterItems.map((item) => {
|
|
||||||
return (
|
|
||||||
<div className='h-48 flex flex-col justify-end items-center gap-1 px-7 py-6 rounded-lg bg-blue50
|
|
||||||
hover:bg-[#002A5B] transition-all duration-500 text-center
|
|
||||||
max-md:px-1 max-md:py-1 max-lg:h-36 max-md:h-32'
|
|
||||||
key={item.id}>
|
|
||||||
<p className='text-yellow font-bold text-base'>{item.count}</p>
|
|
||||||
<p className='text-white font-normal text-sm'>{item.name}</p>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
{/*
|
|
||||||
<Swiper
|
|
||||||
slidesPerView={1}
|
|
||||||
// spaceBetween={30}
|
|
||||||
// spaceBetween={10}
|
|
||||||
// slidesPerView="auto"
|
|
||||||
breakpoints={{
|
|
||||||
1920: {
|
|
||||||
width: 1920,
|
|
||||||
slidesPerView: 5,
|
|
||||||
},
|
|
||||||
1024: {
|
|
||||||
width: 1024,
|
|
||||||
slidesPerView: 3,
|
|
||||||
},
|
|
||||||
768: {
|
|
||||||
width: 768,
|
|
||||||
slidesPerView: 2,
|
|
||||||
},
|
|
||||||
425: {
|
|
||||||
width: 425,
|
|
||||||
slidesPerView: 2,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
pagination={{
|
|
||||||
clickable: true,
|
|
||||||
}}
|
|
||||||
modules={[Pagination]}
|
|
||||||
className="mySwiper"
|
|
||||||
>
|
|
||||||
{counterItems.map((item) => {
|
|
||||||
return (
|
|
||||||
<SwiperSlide className='h-48 flex flex-col justify-end items-center gap-1 px-7 py-6 rounded-lg
|
|
||||||
hover:bg-[#002A5B] transition-all duration-500 text-center
|
|
||||||
max-md:px-1 max-md:py-1'
|
|
||||||
key={item.id}>
|
|
||||||
<p className='text-yellow font-bold text-base'>{item.count}</p>
|
|
||||||
<p className='text-white font-normal text-sm'>{item.name}</p>
|
|
||||||
</SwiperSlide>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
{/* <SwiperSlide>Slide 1</SwiperSlide> */}
|
|
||||||
|
|
||||||
{/* </Swiper> */}
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -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>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,172 +0,0 @@
|
||||||
"use client";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import * as z from "zod";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { useMutation } from "@tanstack/react-query";
|
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { toast } from "@/components/ui/use-toast";
|
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
|
||||||
|
|
||||||
import Image from "next/image";
|
|
||||||
import Link from "next/link";
|
|
||||||
import FollowResult from "./FollowResult";
|
|
||||||
import { postComplaintTracking } from "@/utils/citizenApi";
|
|
||||||
|
|
||||||
const FormSchema = z.object({
|
|
||||||
trackingNumber: z.string().min(2, {
|
|
||||||
message: "trackingNumber must be at least 2 characters.",
|
|
||||||
}),
|
|
||||||
password: z.string().min(4, {
|
|
||||||
message: "Password must be at least 4 characters.",
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function FollowUp() {
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const complaintTrackingMutation = useMutation({
|
|
||||||
mutationKey: ["complaintTracking"],
|
|
||||||
mutationFn: postComplaintTracking,
|
|
||||||
|
|
||||||
onSuccess: (res) => {
|
|
||||||
const result = res;
|
|
||||||
console.log(res);
|
|
||||||
console.log(result);
|
|
||||||
|
|
||||||
// alert("Success");
|
|
||||||
console.log("Success FollowUp");
|
|
||||||
|
|
||||||
// router.push("/FollowResult");
|
|
||||||
router.push("/FollowResult", {data: JSON.stringify( result ) });
|
|
||||||
|
|
||||||
// router.push(
|
|
||||||
// "/FollowResult",
|
|
||||||
// {
|
|
||||||
// data: JSON.stringify(result),
|
|
||||||
// },
|
|
||||||
// );
|
|
||||||
|
|
||||||
// router.push({
|
|
||||||
// pathname : '/FollowResult',
|
|
||||||
// query : {
|
|
||||||
// data: JSON.stringify( result ) ;
|
|
||||||
// },
|
|
||||||
// });
|
|
||||||
|
|
||||||
// return (res)
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
console.log(error);
|
|
||||||
console.log(error?.message);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
|
||||||
resolver: zodResolver(FormSchema),
|
|
||||||
defaultValues: {
|
|
||||||
trackingNumber: "",
|
|
||||||
password: "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
|
||||||
// toast({
|
|
||||||
// title: "You submitted the following values:",
|
|
||||||
// description: (
|
|
||||||
// <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4 pt-12">
|
|
||||||
// <code className="text-white">{JSON.stringify(data, null, 2)}</code>
|
|
||||||
// </pre>
|
|
||||||
// ),
|
|
||||||
// });
|
|
||||||
|
|
||||||
console.log(data);
|
|
||||||
|
|
||||||
localStorage.setItem("trackingNumber2", data.trackingNumber);
|
|
||||||
localStorage.setItem("password2", data.password);
|
|
||||||
|
|
||||||
complaintTrackingMutation.mutate({
|
|
||||||
Data: { trackingNumber: data.trackingNumber, password: data.password },
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
|
||||||
<div className="space-y-3 md:space-y-4 h-full flex flex-col justify-start ">
|
|
||||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
|
||||||
لطفا جهت پیگیری درخواست و مشاهده وضعیت آن کد رهگیری و رمز عبور خود را
|
|
||||||
وارد نمایید.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<Form {...form}>
|
|
||||||
<form
|
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
|
||||||
className="w-full flex flex-col mt-6 "
|
|
||||||
>
|
|
||||||
<div className="flex flex-row flex-wrap justify-between">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="trackingNumber"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full lg:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium">
|
|
||||||
کد پیگیری
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="کد پیگیری خود را وارد نمایید"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="password"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full lg:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium ">
|
|
||||||
رمز عبور
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="رمز عبور خود را وارد کنید"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</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 w-1/2 sm:w-1/3 lg:w-1/4 p-2 rounded-xl text-center"
|
|
||||||
>
|
|
||||||
پیگیری درخواست
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -29,36 +29,34 @@ import {
|
||||||
} from "@/components/ui/select";
|
} from "@/components/ui/select";
|
||||||
import { Operations } from "@/constants";
|
import { Operations } from "@/constants";
|
||||||
import useData from "@/store/useData";
|
import useData from "@/store/useData";
|
||||||
import { useMutation } from "@tanstack/react-query";
|
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||||
import { OperateByInspector } from "@/utils/inspectorApi";
|
import { OperateByInspector } from "@/utils/inspectorApi";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
import { postComplaintsDetails } from "@/utils/citizenApi";
|
import secureLocalStorage from "react-secure-storage";
|
||||||
|
import { Decrypt } from "@/lib/utils";
|
||||||
|
|
||||||
export default function InspectorOperations({
|
export default function InspectorOperations({
|
||||||
complaintData,
|
complaintData,
|
||||||
role,
|
role,
|
||||||
updateData,
|
updateData,
|
||||||
|
id,
|
||||||
|
key2,
|
||||||
}: {
|
}: {
|
||||||
complaintData: any;
|
complaintData: any;
|
||||||
role: string;
|
role: string;
|
||||||
updateData: () => any;
|
updateData: (data: any) => any;
|
||||||
|
id: any;
|
||||||
|
key2: any;
|
||||||
}) {
|
}) {
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
text: z
|
text: z.string({ required_error: "لطفا متن خود را وارد نمایید." }),
|
||||||
.string({ required_error: "لطفا متن خود را وارد نمایید." })
|
|
||||||
.min(8, {
|
|
||||||
message: "Bio must be at least 8 characters.",
|
|
||||||
})
|
|
||||||
.max(260, {
|
|
||||||
message: "Bio must not be longer than 30 characters.",
|
|
||||||
}),
|
|
||||||
...(role == "Inspector" && {
|
...(role == "Inspector" && {
|
||||||
type: z.enum(["private", "public"], {
|
type: z.enum(["private", "public"], {
|
||||||
required_error: "لطفا وضعیت عملیات را انتخاب نمایید.",
|
required_error: "لطفا وضعیت عملیات را انتخاب نمایید.",
|
||||||
}),
|
}),
|
||||||
}),
|
}),
|
||||||
operation: z.string({
|
operation: z.string({
|
||||||
required_error: "Please select an email to display.",
|
required_error: "لطفا نوع عملیات را انتخاب نمایید.",
|
||||||
}),
|
}),
|
||||||
media: z
|
media: z
|
||||||
.custom<FileList>((val) => val instanceof FileList, "Required")
|
.custom<FileList>((val) => val instanceof FileList, "Required")
|
||||||
|
|
@ -67,33 +65,39 @@ export default function InspectorOperations({
|
||||||
.nullish(),
|
.nullish(),
|
||||||
});
|
});
|
||||||
const password = useData((state) => state.data.password);
|
const password = useData((state) => state.data.password);
|
||||||
const possibleOperations = complaintData?.possibleOperations;
|
const possibleOperations = complaintData?.possibleOperationsWithDescription;
|
||||||
const selectOptions = Operations.filter((item, index) =>
|
const queryClient = useQueryClient();
|
||||||
possibleOperations.includes(index)
|
|
||||||
);
|
|
||||||
|
|
||||||
|
console.log(possibleOperations);
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
const form = useForm<z.infer<typeof FormSchema>>({
|
||||||
resolver: zodResolver(FormSchema),
|
resolver: zodResolver(FormSchema),
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
operation:
|
operation:
|
||||||
selectOptions.length == 1 ? String(selectOptions[0].value) : undefined,
|
possibleOperations.length == 1
|
||||||
|
? String(possibleOperations[0].value)
|
||||||
|
: undefined,
|
||||||
|
text: "",
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const OperationMutation = useMutation({
|
const OperationMutation = useMutation({
|
||||||
mutationKey: ["Operation"],
|
mutationKey: ["Operation"],
|
||||||
mutationFn:
|
mutationFn: OperateByInspector,
|
||||||
role == "Inspector" ? OperateByInspector : postComplaintsDetails,
|
|
||||||
onSuccess: (res) => {
|
onSuccess: (res) => {
|
||||||
toast("عملیات شما با موفقیت انجام شد. ", {
|
toast("عملیات شما با موفقیت انجام شد. ", {
|
||||||
className: "!bg-green-500 !text-white",
|
className: "!bg-green-500 !text-white",
|
||||||
});
|
});
|
||||||
|
const tk = localStorage.getItem("trackingNumber");
|
||||||
|
updateData({ trackingNumber: tk, password: key2 });
|
||||||
},
|
},
|
||||||
onError: (err) => {},
|
onError: (err) => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
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();
|
const formData = new FormData();
|
||||||
formData.append("text", data.text);
|
formData.append("text", data.text);
|
||||||
formData.append("trackingNumber", complaintData.trackingNumber);
|
formData.append("trackingNumber", complaintData.trackingNumber);
|
||||||
|
|
@ -101,11 +105,7 @@ export default function InspectorOperations({
|
||||||
if (data.type) {
|
if (data.type) {
|
||||||
formData.append("IsPublic", data.type == "public" ? "true" : "false");
|
formData.append("IsPublic", data.type == "public" ? "true" : "false");
|
||||||
}
|
}
|
||||||
if (role == "Inspector") {
|
formData.append("EncodedKey", key2);
|
||||||
formData.append("EncodedKey", password);
|
|
||||||
} else {
|
|
||||||
formData.append("password", localStorage.getItem("password2") as string);
|
|
||||||
}
|
|
||||||
if (data?.media && data?.media?.length > 0) {
|
if (data?.media && data?.media?.length > 0) {
|
||||||
for (let i = 0; i < data.media.length; i++) {
|
for (let i = 0; i < data.media.length; i++) {
|
||||||
formData.append("Medias", data.media[i]);
|
formData.append("Medias", data.media[i]);
|
||||||
|
|
@ -221,10 +221,10 @@ export default function InspectorOperations({
|
||||||
<SelectContent dir="rtl">
|
<SelectContent dir="rtl">
|
||||||
<SelectGroup>
|
<SelectGroup>
|
||||||
<SelectLabel>عملیات</SelectLabel>
|
<SelectLabel>عملیات</SelectLabel>
|
||||||
{selectOptions.map((item) => {
|
{possibleOperations.map((item) => {
|
||||||
return (
|
return (
|
||||||
<SelectItem value={String(item.value)}>
|
<SelectItem value={String(item.value)}>
|
||||||
{item.name}
|
{item.description}
|
||||||
</SelectItem>
|
</SelectItem>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,18 @@ import {
|
||||||
Title,
|
Title,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Legend,
|
Legend,
|
||||||
|
ChartOptions,
|
||||||
} from "chart.js";
|
} from "chart.js";
|
||||||
import { Line } from "react-chartjs-2";
|
import { Line } from "react-chartjs-2";
|
||||||
import { faker } from "@faker-js/faker";
|
import { faker } from "@faker-js/faker";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import utc from "dayjs/plugin/utc";
|
||||||
|
import jalaliday from "jalaliday";
|
||||||
|
import { backgroundColor, borderColor } from "@/constants/colors";
|
||||||
|
import ChartDataLabels from "chartjs-plugin-datalabels";
|
||||||
|
dayjs.extend(jalaliday);
|
||||||
|
dayjs.extend(utc);
|
||||||
|
ChartJS.defaults.font.family = "Yekan";
|
||||||
ChartJS.register(
|
ChartJS.register(
|
||||||
CategoryScale,
|
CategoryScale,
|
||||||
LinearScale,
|
LinearScale,
|
||||||
|
|
@ -21,21 +29,22 @@ ChartJS.register(
|
||||||
LineElement,
|
LineElement,
|
||||||
Title,
|
Title,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Legend
|
Legend,
|
||||||
|
ChartDataLabels
|
||||||
);
|
);
|
||||||
|
|
||||||
export const options = {
|
// export const options = {
|
||||||
responsive: true,
|
// responsive: true,
|
||||||
plugins: {
|
// plugins: {
|
||||||
legend: {
|
// legend: {
|
||||||
position: "top" as const,
|
// position: "top" as const,
|
||||||
},
|
// },
|
||||||
title: {
|
// title: {
|
||||||
display: true,
|
// display: true,
|
||||||
text: "Chart.js Line Chart",
|
// text: "Chart.js Line Chart",
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
};
|
// };
|
||||||
|
|
||||||
const labels = ["January", "February", "March", "April", "May", "June", "July"];
|
const labels = ["January", "February", "March", "April", "May", "June", "July"];
|
||||||
|
|
||||||
|
|
@ -57,8 +66,61 @@ export const data = {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function LineChart() {
|
interface Values {
|
||||||
return (
|
title: string;
|
||||||
<Line options={options} data={data} className=' '/>
|
value: string;
|
||||||
);
|
displayValue: string;
|
||||||
|
parameters: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function LineChart({
|
||||||
|
chartData,
|
||||||
|
chartTitle,
|
||||||
|
}: {
|
||||||
|
chartData: { title: string; icon: string; values: Values[] }[];
|
||||||
|
chartTitle: string;
|
||||||
|
}) {
|
||||||
|
const options: ChartOptions<"line"> = {
|
||||||
|
responsive: true,
|
||||||
|
maintainAspectRatio: false,
|
||||||
|
scales: { x: { ticks: { autoSkip: false } } },
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
position: "top" as const,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: chartTitle,
|
||||||
|
position: "bottom",
|
||||||
|
},
|
||||||
|
datalabels: {
|
||||||
|
display: true,
|
||||||
|
color: "black",
|
||||||
|
align: "end",
|
||||||
|
anchor: "end",
|
||||||
|
font: { size: 12 },
|
||||||
|
formatter: function (value, context) {
|
||||||
|
console.log(context.dataset);
|
||||||
|
return value == 0 ? "" : value;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
labels: chartData[0].values.map((item) => {
|
||||||
|
return item.title;
|
||||||
|
}),
|
||||||
|
datasets: chartData.map((item: any, index: number) => {
|
||||||
|
return {
|
||||||
|
label: item.title,
|
||||||
|
data: item.values.map((item) => item.value),
|
||||||
|
backgroundColor: backgroundColor[index],
|
||||||
|
borderColor: borderColor[index],
|
||||||
|
borderWidth: 1,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
return <Line options={options} data={data} className="h-[20rem] " />;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ export default function Login() {
|
||||||
});
|
});
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
function onSubmit(data: z.infer<typeof FormSchema>) {
|
||||||
|
refetch();
|
||||||
const payload = {
|
const payload = {
|
||||||
username: data.username,
|
username: data.username,
|
||||||
password: data.password,
|
password: data.password,
|
||||||
|
|
@ -90,7 +91,7 @@ export default function Login() {
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
return (
|
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
|
<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]
|
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"
|
h-fit"
|
||||||
|
|
|
||||||
|
|
@ -1,48 +0,0 @@
|
||||||
"use client";
|
|
||||||
import React, { useEffect, useRef } from "react";
|
|
||||||
import { MapContainer, TileLayer, Marker, Popup } from "react-leaflet";
|
|
||||||
import L from "leaflet";
|
|
||||||
// import MarkerIcon from "../../node_modules/leaflet/dist/images/marker-icon.png";
|
|
||||||
// import MarkerShadow from "../../node_modules/leaflet/dist/images/marker-shadow.png";
|
|
||||||
import "leaflet/dist/leaflet.css";
|
|
||||||
import { any } from "zod";
|
|
||||||
|
|
||||||
const Map = () => {
|
|
||||||
const markerRef = useRef<any>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (markerRef.current) {
|
|
||||||
markerRef.current.openPopup()
|
|
||||||
}
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<MapContainer
|
|
||||||
center={[31.8974, 54.3569]}
|
|
||||||
zoom={13}
|
|
||||||
style={{ height: "300px" }}
|
|
||||||
className=" rounded-lg max-w-full"
|
|
||||||
>
|
|
||||||
<TileLayer url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png" />
|
|
||||||
<Marker
|
|
||||||
position={[31.8974, 54.3569]}
|
|
||||||
// icon={
|
|
||||||
// new L.Icon({
|
|
||||||
// iconUrl: MarkerIcon.src,
|
|
||||||
// iconRetinaUrl: MarkerIcon.src,
|
|
||||||
// iconSize: [25, 41],
|
|
||||||
// iconAnchor: [12.5, 41],
|
|
||||||
// popupAnchor: [0, -41],
|
|
||||||
// shadowUrl: MarkerShadow.src,
|
|
||||||
// shadowSize: [41, 41],
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
ref={markerRef}
|
|
||||||
>
|
|
||||||
<Popup className=" font-[Yekan] font-bold">داروخانه چمران</Popup>
|
|
||||||
</Marker>
|
|
||||||
</MapContainer>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Map;
|
|
||||||
|
|
@ -1,36 +1,102 @@
|
||||||
"use client";
|
"use client";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useRef, useState } from "react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { AdminMenuItems, ControllerMenuItems } from "@/constants";
|
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() {
|
export default function NavbarPanel() {
|
||||||
|
const [isOpen, setOpen] = useState(false);
|
||||||
|
const ref = useRef(null);
|
||||||
|
const router = useRouter();
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const [role, setRole] = useState<string | null>("");
|
const [role, setRole] = useState<string | null>("");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const userRole = localStorage.getItem("Sootzani_Role");
|
const userRole = localStorage.getItem("Sootzani_Role");
|
||||||
setRole(userRole);
|
setRole(userRole);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
console.log(role);
|
const { data, isLoading, refetch } = useQuery({
|
||||||
|
queryKey: ["Profile"],
|
||||||
|
queryFn: () => getProfile(),
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
});
|
||||||
|
|
||||||
const menus = {
|
const menus = {
|
||||||
Admin: AdminMenuItems,
|
Admin: AdminMenuItems,
|
||||||
Inspector: ControllerMenuItems,
|
Inspector: ControllerMenuItems,
|
||||||
};
|
};
|
||||||
const selectedMenu = menus[role as keyof typeof menus];
|
const selectedMenu = menus[role as keyof typeof menus];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className="fixed flex flex-col-reverse justify-between items-start gap-3
|
className="fixed flex justify-between items-center gap-3
|
||||||
sm:flex-row sm:items-center sm:gap-0
|
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
|
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">
|
<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>
|
</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 && (
|
{role && (
|
||||||
<>
|
<>
|
||||||
{selectedMenu.map(
|
{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>
|
||||||
</div>
|
</div>
|
||||||
|
<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">
|
<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"
|
{data && (
|
||||||
? "نام و نام خانوادگی (ادمین)"
|
<>
|
||||||
: "نام و نام خانوادگی (بازرس)"}
|
{role === "Admin"
|
||||||
</h1>
|
? `${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>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
"use client";
|
||||||
|
import React, { useEffect, useState } from "react";
|
||||||
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
|
import LineChart from "./LineChart";
|
||||||
|
|
||||||
|
import { BsBarChartLineFill } from "react-icons/bs";
|
||||||
|
import { BsBarChartLine } from "react-icons/bs";
|
||||||
|
import VerticalChart from "./VerticalChart";
|
||||||
|
import { HorizontalChart } from "./HorizontalChart";
|
||||||
|
import { getInfo, getInfoList } from "@/utils/infoApi";
|
||||||
|
import { useQueries, useQuery } from "@tanstack/react-query";
|
||||||
|
import useChart from "@/hooks/useChart";
|
||||||
|
|
||||||
|
export default function Reports({ data }) {
|
||||||
|
console.log(data);
|
||||||
|
const [first, setfirst] = useState<any>(false);
|
||||||
|
const Queries: any = useQueries({
|
||||||
|
queries: data?.map((item: any) => ({
|
||||||
|
queryKey: ["user", item.code],
|
||||||
|
queryFn: () => getInfo(item.code),
|
||||||
|
})),
|
||||||
|
});
|
||||||
|
const codes = data.map((item: any) => item.code);
|
||||||
|
console.log(codes);
|
||||||
|
console.log(Queries[0]);
|
||||||
|
const charts = Queries.map((item: any) => item.data);
|
||||||
|
const successfulRequests = Queries.filter((item) => item.isSuccess == true);
|
||||||
|
return (
|
||||||
|
<div className="">
|
||||||
|
{successfulRequests.length == data.length && (
|
||||||
|
<Tabs
|
||||||
|
defaultValue={data[0].code}
|
||||||
|
className="w-full flex flex-col md:flex-row gap-12 items-center"
|
||||||
|
dir="rtl"
|
||||||
|
>
|
||||||
|
<div className="w-full md:w-2/5 flex flex-col justify-between items-center ">
|
||||||
|
{/* Tab Title */}
|
||||||
|
<TabsList className="w-full h-full flex flex-row md:flex-col max-md:flex-wrap max-md:justify-between bg-transparent gap-4">
|
||||||
|
{data?.map((item: any) => {
|
||||||
|
return (
|
||||||
|
<TabsTrigger
|
||||||
|
key={item.code}
|
||||||
|
className="w-[45%] md:w-full h-12 bg-muted text-[#555353] shadow-md hover:shadow-none text-xs lg:text-sm font-bold py-3 gap-2 justify-center whitespace-pre-line"
|
||||||
|
value={item.code}
|
||||||
|
>
|
||||||
|
{item.title}
|
||||||
|
{/* <BsBarChartLineFill /> نمودار شماره یک */}
|
||||||
|
</TabsTrigger>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</TabsList>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="w-full md:w-3/5 flex justify-between items-center ">
|
||||||
|
{charts?.map((item: any, index) => {
|
||||||
|
return (
|
||||||
|
<TabsContent value={codes[index]} className="w-full">
|
||||||
|
<VerticalChart
|
||||||
|
chartTitle={item.charts[0].chartTitle}
|
||||||
|
chartData={item.charts[0].series}
|
||||||
|
chart={2}
|
||||||
|
/>
|
||||||
|
</TabsContent>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{/* Tab Content */}
|
||||||
|
{/* <TabsContent value="tab1" className="w-full h-full ">
|
||||||
|
<VerticalChart />
|
||||||
|
</TabsContent>
|
||||||
|
|
||||||
|
<TabsContent value="tab2" className="w-full h-full ">
|
||||||
|
<HorizontalChart />
|
||||||
|
</TabsContent>
|
||||||
|
|
||||||
|
<TabsContent value="tab3" className="w-full h-full ">
|
||||||
|
<LineChart />
|
||||||
|
</TabsContent>
|
||||||
|
|
||||||
|
<TabsContent value="tab4" className="w-full h-full ">
|
||||||
|
<HorizontalChart />
|
||||||
|
</TabsContent> */}
|
||||||
|
</div>
|
||||||
|
</Tabs>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
"use client"
|
"use client";
|
||||||
import React from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
|
||||||
import LineChart from "./LineChart";
|
import LineChart from "./LineChart";
|
||||||
|
|
||||||
|
|
@ -7,100 +7,23 @@ import { BsBarChartLineFill } from "react-icons/bs";
|
||||||
import { BsBarChartLine } from "react-icons/bs";
|
import { BsBarChartLine } from "react-icons/bs";
|
||||||
import { VerticalChart } from "./VerticalChart";
|
import { VerticalChart } from "./VerticalChart";
|
||||||
import { HorizontalChart } from "./HorizontalChart";
|
import { HorizontalChart } from "./HorizontalChart";
|
||||||
|
import { getInfo, getInfoList } from "@/utils/infoApi";
|
||||||
|
import { useQueries, useQuery } from "@tanstack/react-query";
|
||||||
|
import useChart from "@/hooks/useChart";
|
||||||
|
import Reports from "./Reports";
|
||||||
|
|
||||||
export default function ReportsController() {
|
export default function ReportsController() {
|
||||||
|
const { data, isLoading, refetch, isSuccess } = useQuery({
|
||||||
|
queryKey: ["InfoList"],
|
||||||
|
queryFn: () => getInfoList(),
|
||||||
|
refetchOnWindowFocus: false,
|
||||||
|
});
|
||||||
|
const [first, setfirst] = useState<any>(false);
|
||||||
|
|
||||||
|
console.log(data);
|
||||||
return (
|
return (
|
||||||
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9">
|
<div className="w-[95vw] lg:w-[82vw] xl:w-[75vw] 3xl:w-[65vw] max-sm:mt-16 mt-8 pt-9 mx-auto">
|
||||||
<Tabs
|
{data && <Reports data={data} />}
|
||||||
defaultValue="tab1"
|
|
||||||
className="w-full flex flex-col md:flex-row gap-16"
|
|
||||||
dir="rtl"
|
|
||||||
>
|
|
||||||
<div className="w-full md:w-1/4 flex flex-col justify-between items-center ">
|
|
||||||
{/* Tab Title */}
|
|
||||||
<TabsList className="w-full h-full flex flex-row md:flex-col max-md:flex-wrap max-md:justify-between bg-transparent gap-4">
|
|
||||||
<TabsTrigger
|
|
||||||
className="w-[45%] md:w-full h-12 bg-muted text-[#555353] shadow-md hover:shadow-none text-sm md:text-lg font-bold py-3 gap-2 justify-start"
|
|
||||||
value="tab1"
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
<BsBarChartLineFill /> نمودار شماره یک
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger
|
|
||||||
className="w-[45%] md:w-full h-12 bg-muted text-[#555353] shadow-md hover:shadow-none text-sm md:text-lg font-bold py-3 gap-2 justify-start"
|
|
||||||
value="tab2"
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
<BsBarChartLineFill /> نمودار شماره 2
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger
|
|
||||||
className="w-[45%] md:w-full h-12 bg-muted text-[#555353] shadow-md hover:shadow-none text-sm md:text-lg font-bold py-3 gap-2 justify-start"
|
|
||||||
value="tab3"
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
<BsBarChartLineFill /> نمودار شماره 3
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger
|
|
||||||
className="w-[45%] md:w-full h-12 bg-muted text-[#555353] shadow-md hover:shadow-none text-sm md:text-lg font-bold py-3 gap-2 justify-start"
|
|
||||||
value="tab4"
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
<BsBarChartLineFill /> نمودار شماره 4
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger
|
|
||||||
className="w-[45%] md:w-full h-12 bg-muted text-[#555353] shadow-md hover:shadow-none text-sm md:text-lg font-bold py-3 gap-2 justify-start"
|
|
||||||
value="tab5"
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
<BsBarChartLineFill /> نمودار شماره 5
|
|
||||||
</TabsTrigger>
|
|
||||||
<TabsTrigger
|
|
||||||
className="w-[45%] md:w-full h-12 bg-muted text-[#555353] shadow-md hover:shadow-none text-sm md:text-lg font-bold py-3 gap-2 justify-start"
|
|
||||||
value="tab6"
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
<BsBarChartLineFill /> نمودار شماره 6
|
|
||||||
</TabsTrigger>
|
|
||||||
|
|
||||||
<TabsTrigger
|
|
||||||
className="w-[45%] md:w-full h-12 bg-muted text-[#555353] shadow-md hover:shadow-none text-sm md:text-lg font-bold py-3 gap-2 justify-start"
|
|
||||||
value="tab7"
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
<BsBarChartLineFill /> نمودار شماره 7
|
|
||||||
</TabsTrigger>
|
|
||||||
|
|
||||||
<TabsTrigger
|
|
||||||
className="w-[45%] md:w-full h-12 bg-muted text-[#555353] shadow-md hover:shadow-none text-sm md:text-lg font-bold py-3 gap-2 justify-start"
|
|
||||||
value="tab8"
|
|
||||||
>
|
|
||||||
{" "}
|
|
||||||
<BsBarChartLineFill /> نمودار شماره 8
|
|
||||||
</TabsTrigger>
|
|
||||||
|
|
||||||
|
|
||||||
</TabsList>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="w-full md:w-3/4 flex justify-between items-center ">
|
|
||||||
{/* Tab Content */}
|
|
||||||
<TabsContent value="tab1" className="w-full h-full ">
|
|
||||||
<VerticalChart />
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value="tab2" className="w-full h-full ">
|
|
||||||
<HorizontalChart />
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value="tab3" className="w-full h-full ">
|
|
||||||
<LineChart />
|
|
||||||
</TabsContent>
|
|
||||||
|
|
||||||
<TabsContent value="tab4" className="w-full h-full ">
|
|
||||||
<HorizontalChart />
|
|
||||||
</TabsContent>
|
|
||||||
</div>
|
|
||||||
</Tabs>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,52 +0,0 @@
|
||||||
"use client";
|
|
||||||
|
|
||||||
import React, { useEffect } from "react";
|
|
||||||
import Image from "next/image";
|
|
||||||
import Resultimg from "../public/img/result.png";
|
|
||||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
|
|
||||||
export default function Result() {
|
|
||||||
const trackingNumber = localStorage.getItem("trackingNumber");
|
|
||||||
const password = localStorage.getItem("password");
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
localStorage.removeItem("trackingNumber")
|
|
||||||
localStorage.removeItem("password")
|
|
||||||
}, [router]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="w-full h-full sm:w-2/3 md:w-3/4 lg:w-1/2 max-sm:p-8 pt-12 ">
|
|
||||||
<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 ">
|
|
||||||
با تشکر از شما
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
در سامانه سوت زنی ثبت شده و شما می توانید نتیجه درخواست خود را از صفحه
|
|
||||||
پیگیری درخواست، با استفاده از کد رهگیری و رمز عبور مشاهده کنید.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<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>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,166 +0,0 @@
|
||||||
"use client";
|
|
||||||
import React from "react";
|
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import * as z from "zod";
|
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { toast } from "@/components/ui/use-toast";
|
|
||||||
import Link from "next/link";
|
|
||||||
import RequestStep2 from "./RequestStep2";
|
|
||||||
|
|
||||||
const FormSchema = z.object({
|
|
||||||
firstName: z.string().min(2, {
|
|
||||||
message: "firstName must be at least 2 characters.",
|
|
||||||
}),
|
|
||||||
lastName: z.string().min(2, {
|
|
||||||
message: "lastName must be at least 2 characters.",
|
|
||||||
}),
|
|
||||||
nationalCode: z.number().min(10, {
|
|
||||||
message: "nationalCode must be at least 10 characters.",
|
|
||||||
}),
|
|
||||||
phoneNumber: z.number().min(11, {
|
|
||||||
message: "phoneNumber must be at least 11 characters.",
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function RequestStep1() {
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
|
||||||
resolver: zodResolver(FormSchema),
|
|
||||||
defaultValues: {
|
|
||||||
firstName: "",
|
|
||||||
lastName: "",
|
|
||||||
// nationalCode: ,
|
|
||||||
// phoneNumber: ,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
|
||||||
toast({
|
|
||||||
title: "You submitted the following values:",
|
|
||||||
description: (
|
|
||||||
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
|
|
||||||
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
|
|
||||||
</pre>
|
|
||||||
),
|
|
||||||
});
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
|
||||||
<div className="space-y-4 md:space-y-4 h-full flex flex-col justify-center">
|
|
||||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
|
||||||
لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید.
|
|
||||||
</p>
|
|
||||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-red-500 dark:text-white">
|
|
||||||
در صورت عدم تمایل به ثبت مشخصات شخصی می توانید به صفحه ی بعد مراجعه کنید.
|
|
||||||
</p>
|
|
||||||
<Form {...form}>
|
|
||||||
<form
|
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
|
||||||
className="w-full flex flex-col mt-6 "
|
|
||||||
>
|
|
||||||
<div className="flex flex-row flex-wrap justify-between">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="firstName"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium">
|
|
||||||
نام
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input placeholder="نام خود را وارد نمایید" {...field} />
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="lastName"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full sm:w-[48%] ">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium">
|
|
||||||
نام خانوادگی
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="نام خانوادگی خود را وارد نمایید"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="nationalCode"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
کد ملی
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
type="number"
|
|
||||||
placeholder="کد ملی خود را وارد نمایید "
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="phoneNumber"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full sm:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
شماره تماس
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
type="number"
|
|
||||||
placeholder="شماره تماس خود را وارد نمایید "
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
|
||||||
{/* <Button> */}
|
|
||||||
<Link
|
|
||||||
href="/RequestStep2"
|
|
||||||
type="submit"
|
|
||||||
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center"
|
|
||||||
>
|
|
||||||
صفحه ی بعد
|
|
||||||
</Link>
|
|
||||||
{/* </Button> */}
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,421 +0,0 @@
|
||||||
"use client";
|
|
||||||
import React, { useState } from "react";
|
|
||||||
|
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
|
||||||
import { useForm } from "react-hook-form";
|
|
||||||
import * as z from "zod";
|
|
||||||
|
|
||||||
import { Button } from "@/components/ui/button";
|
|
||||||
import {
|
|
||||||
Form,
|
|
||||||
FormControl,
|
|
||||||
FormDescription,
|
|
||||||
FormField,
|
|
||||||
FormItem,
|
|
||||||
FormLabel,
|
|
||||||
FormMessage,
|
|
||||||
} from "@/components/ui/form";
|
|
||||||
|
|
||||||
import {
|
|
||||||
Select,
|
|
||||||
SelectContent,
|
|
||||||
SelectGroup,
|
|
||||||
SelectItem,
|
|
||||||
SelectLabel,
|
|
||||||
SelectTrigger,
|
|
||||||
SelectValue,
|
|
||||||
} from "@/components/ui/select";
|
|
||||||
|
|
||||||
import { Input } from "@/components/ui/input";
|
|
||||||
import { toast } from "@/components/ui/use-toast";
|
|
||||||
import { Textarea } from "@/components/ui/textarea";
|
|
||||||
import { Label } from "@/components/ui/label";
|
|
||||||
import Link from "next/link";
|
|
||||||
import RequestResult from "./RequestResult";
|
|
||||||
import Image from "next/image";
|
|
||||||
import Img1 from "../public/img/logo.png";
|
|
||||||
|
|
||||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
||||||
import { postComplaintSubmit } from "@/utils/citizenApi";
|
|
||||||
import { useRouter } from "next/navigation";
|
|
||||||
import { getCaptcha, getCategory } from "@/utils/commonApi";
|
|
||||||
|
|
||||||
const MAX_IMAGE_SIZE = 5242880; // 5 MB
|
|
||||||
const ALLOWED_IMAGE_TYPES = [
|
|
||||||
"image/jpeg",
|
|
||||||
"image/png",
|
|
||||||
"image/webp",
|
|
||||||
"image/jpg",
|
|
||||||
];
|
|
||||||
|
|
||||||
const FormSchema = z.object({
|
|
||||||
subject: z.string().min(2, {
|
|
||||||
message: "subject must be at least 2 characters.",
|
|
||||||
}),
|
|
||||||
organisation: z.string().min(2, {
|
|
||||||
message: "organisation must be at least 2 characters.",
|
|
||||||
}),
|
|
||||||
person: z.string().min(2, {
|
|
||||||
message: "personName must be at least 2 characters.",
|
|
||||||
}),
|
|
||||||
description: z
|
|
||||||
.string()
|
|
||||||
.min(5, {
|
|
||||||
message: "description must be at least 5 characters.",
|
|
||||||
})
|
|
||||||
.max(200, {
|
|
||||||
message: "description must not be longer than 200 characters.",
|
|
||||||
}),
|
|
||||||
uploadFile: z
|
|
||||||
.custom<FileList>((val) => val instanceof FileList, "Required")
|
|
||||||
// .refine((files) => files.length > 0, `Required`)
|
|
||||||
.refine((files) => files.length <= 5, `Maximum of 5 File are allowed.`)
|
|
||||||
.refine(
|
|
||||||
(files) => Array.from(files).every((file) => file.size <= MAX_IMAGE_SIZE),
|
|
||||||
`Each file size should be less than 5 MB.`
|
|
||||||
),
|
|
||||||
// .refine(
|
|
||||||
// (files) =>
|
|
||||||
// Array.from(files).every((file) =>
|
|
||||||
// ALLOWED_IMAGE_TYPES.includes(file.type)
|
|
||||||
// ),
|
|
||||||
// "Only these types are allowed .jpg, .jpeg, .png and .webp"
|
|
||||||
// ),
|
|
||||||
categoryId: z.string({
|
|
||||||
required_error: "Please select an category to display.",
|
|
||||||
}),
|
|
||||||
captchaValue: z.string().min(4, {
|
|
||||||
message: "captcha must be at least 4 characters.",
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Form Hook
|
|
||||||
export default function RequestStep2() {
|
|
||||||
// const [trackingComplaint, setTrackingComplaint] = useState({});
|
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
const complaintSubmitMutation = useMutation({
|
|
||||||
mutationKey: ["complaintSubmit"],
|
|
||||||
mutationFn: postComplaintSubmit,
|
|
||||||
|
|
||||||
onSuccess: (res) => {
|
|
||||||
console.log(res);
|
|
||||||
localStorage.setItem("trackingNumber", res.trackingNumber);
|
|
||||||
localStorage.setItem("password", res.password);
|
|
||||||
|
|
||||||
// alert("Success");
|
|
||||||
console.log("Success Step2");
|
|
||||||
router.push("/RequestResult");
|
|
||||||
// router.push("/RequestResult", { data: trackingComplaint });
|
|
||||||
// return (res)
|
|
||||||
},
|
|
||||||
onError: (error) => {
|
|
||||||
console.log(error);
|
|
||||||
console.log(error?.message);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// All Category
|
|
||||||
const { data: categoryData } = useQuery({
|
|
||||||
queryKey: ["Category"],
|
|
||||||
queryFn: () => getCategory(),
|
|
||||||
});
|
|
||||||
|
|
||||||
// Captcha
|
|
||||||
const { data: CaptchaData, isLoading } = useQuery({
|
|
||||||
queryKey: ["Captcha"],
|
|
||||||
queryFn: () => getCaptcha(),
|
|
||||||
});
|
|
||||||
// console.log(captchaData);
|
|
||||||
|
|
||||||
const srcForImage = CaptchaData
|
|
||||||
? URL.createObjectURL(CaptchaData.data)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
const form = useForm<z.infer<typeof FormSchema>>({
|
|
||||||
resolver: zodResolver(FormSchema),
|
|
||||||
defaultValues: {
|
|
||||||
subject: "",
|
|
||||||
organisation: "",
|
|
||||||
person: "",
|
|
||||||
description: "",
|
|
||||||
captchaValue: "",
|
|
||||||
// uploadFile: null,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
|
||||||
// toast({
|
|
||||||
// title: "You submitted the following values:",
|
|
||||||
// description: (
|
|
||||||
// <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
|
|
||||||
// <code className="text-white">{JSON.stringify(data, null, 2)}</code>
|
|
||||||
// </pre>
|
|
||||||
// ),
|
|
||||||
// });
|
|
||||||
|
|
||||||
const formData = new FormData();
|
|
||||||
formData.append("Title", data.subject);
|
|
||||||
formData.append("Text", data.description);
|
|
||||||
formData.append("CategoryId", data.categoryId);
|
|
||||||
formData.append("Medias", data.uploadFile[0]);
|
|
||||||
formData.append("Captcha.Value", data.captchaValue);
|
|
||||||
formData.append("Captcha.Key", CaptchaData?.headers["captcha-key"]);
|
|
||||||
|
|
||||||
complaintSubmitMutation.mutate({
|
|
||||||
Data: formData,
|
|
||||||
});
|
|
||||||
resetField("Title");
|
|
||||||
resetField("Text");
|
|
||||||
resetField("Medias");
|
|
||||||
resetField("CategoryId");
|
|
||||||
resetField("Captcha.Value");
|
|
||||||
|
|
||||||
console.log("submited");
|
|
||||||
console.log(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
const { resetField } = useForm();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="w-full h-full sm:w-2/3 md:w-2/4 max-sm:p-8 pt-12">
|
|
||||||
<div className="space-y-3 md:space-y-4 h-full flex flex-col justify-center">
|
|
||||||
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-blue dark:text-white">
|
|
||||||
لطفا جهت ارسال درخواست فرم زیر را تکمیل نمایید.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<Form {...form}>
|
|
||||||
<form
|
|
||||||
onSubmit={form.handleSubmit(onSubmit)}
|
|
||||||
className="w-full flex flex-col mt-6"
|
|
||||||
>
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="subject"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
*موضوع شکایت
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="موضوع شکایت خود را بنویسید"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<div className="flex flex-row flex-wrap justify-between">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="organisation"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
*دستگاه مربوطه
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="دستگاه مربوطه را انتخاب کنید"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="person"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className=" w-full sm:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
فرد مربوطه
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="نام فرد مورد نظر خود را بنویسید"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="description"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem>
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
توضیحات
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Textarea
|
|
||||||
placeholder="متن توضیحات خود را بنویسید"
|
|
||||||
className="resize-none mb-3"
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="flex flex-row flex-wrap justify-between">
|
|
||||||
{/* Select Option */}
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="categoryId"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full sm:w-[48%] flex-row-reverse">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
انتخاب دسته بندی
|
|
||||||
</FormLabel>
|
|
||||||
<Select
|
|
||||||
onValueChange={field.onChange}
|
|
||||||
defaultValue={field.value}
|
|
||||||
>
|
|
||||||
<FormControl>
|
|
||||||
<SelectTrigger className="bg-slate-200">
|
|
||||||
<SelectValue placeholder=" دسته بندی ها" />
|
|
||||||
</SelectTrigger>
|
|
||||||
</FormControl>
|
|
||||||
<SelectContent>
|
|
||||||
{categoryData?.map((catItems: any, index: any) => (
|
|
||||||
<SelectItem key={index} value={catItems.id}>
|
|
||||||
{catItems.title}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</SelectContent>
|
|
||||||
</Select>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* uploadFile */}
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="uploadFile"
|
|
||||||
render={({ field: { onChange }, ...field }) => {
|
|
||||||
// Get current uploadFile value (always watched updated)
|
|
||||||
const uploadFile = form.watch("uploadFile");
|
|
||||||
{
|
|
||||||
console.log(uploadFile);
|
|
||||||
}
|
|
||||||
var filenames: string[] | undefined = undefined;
|
|
||||||
if (uploadFile) {
|
|
||||||
// 1. covert to File[] using Array.from
|
|
||||||
const files: File[] = Array.from(uploadFile);
|
|
||||||
// 2. now you can use array methods on files;
|
|
||||||
filenames = files.map((file) => file?.name);
|
|
||||||
{
|
|
||||||
console.log(filenames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
آپلود تصویر
|
|
||||||
</FormLabel>
|
|
||||||
{/* File Upload */}
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
type="file"
|
|
||||||
className="mb-3"
|
|
||||||
accept="image/* , .pdf"
|
|
||||||
multiple={true}
|
|
||||||
disabled={form.formState.isSubmitting}
|
|
||||||
{...field}
|
|
||||||
onChange={(event) => {
|
|
||||||
// Triggered when user uploaded a new file
|
|
||||||
// FileList is immutable, so we need to create a new one
|
|
||||||
const dataTransfer = new DataTransfer();
|
|
||||||
|
|
||||||
// Add old images
|
|
||||||
// if (images) {
|
|
||||||
// Array.from(images).forEach((image) =>
|
|
||||||
// dataTransfer.items.add(image)
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Add newly uploaded images
|
|
||||||
Array.from(event.target.files!).forEach((image) =>
|
|
||||||
dataTransfer.items.add(image)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Validate and update uploaded file
|
|
||||||
const newFiles = dataTransfer.files;
|
|
||||||
onChange(newFiles);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
{/* Show File Name */}
|
|
||||||
{/* <FormDescription>{`${filenames}`}</FormDescription> */}
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{/* Captcha */}
|
|
||||||
<div className="flex flex-row flex-wrap justify-between">
|
|
||||||
<FormField
|
|
||||||
control={form.control}
|
|
||||||
name="captchaValue"
|
|
||||||
render={({ field }) => (
|
|
||||||
<FormItem className="w-full sm:w-[48%]">
|
|
||||||
<FormLabel className="text-[#7C838A] text-sm font-medium mt-7">
|
|
||||||
*کد امنیتی
|
|
||||||
</FormLabel>
|
|
||||||
<FormControl>
|
|
||||||
<Input
|
|
||||||
placeholder="کد تصویر روبرو را وارد کنید "
|
|
||||||
{...field}
|
|
||||||
/>
|
|
||||||
</FormControl>
|
|
||||||
<FormMessage />
|
|
||||||
</FormItem>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<div className="w-full sm:w-[48%] flex items-center justify-start">
|
|
||||||
{!isLoading && (
|
|
||||||
<Image
|
|
||||||
alt="icon"
|
|
||||||
src={srcForImage as string}
|
|
||||||
className="w-3/5 h-12 rounded-md shadow-md"
|
|
||||||
width={150}
|
|
||||||
height={20}
|
|
||||||
quality={100}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{/* <Image src={Img1} alt="1" width={50} height={50} /> */}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex justify-center sm:justify-end gap-2 w-full mt-4">
|
|
||||||
{/* <Link> */}
|
|
||||||
<Button
|
|
||||||
// href="/RequestResult"
|
|
||||||
type="submit"
|
|
||||||
className="w-1/2 sm:w-1/3 lg:w-1/4 bg-blue text-white p-2 rounded-xl text-center mb-4"
|
|
||||||
>
|
|
||||||
ارسال درخواست
|
|
||||||
</Button>
|
|
||||||
{/* </Link> */}
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</Form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
"use client"
|
|
||||||
import React from 'react'
|
|
||||||
import Link from 'next/link'
|
|
||||||
import { requestItems } from '@/constants'
|
|
||||||
import Image from 'next/image'
|
|
||||||
import svg1 from '../public/img/Connector line.svg'
|
|
||||||
import { cn } from '@/lib/utils'
|
|
||||||
import { IoArrowDown } from "react-icons/io5";
|
|
||||||
|
|
||||||
export default function SubmitRequest() {
|
|
||||||
return (
|
|
||||||
|
|
||||||
<div className="3xl:w-[60%] w-[75%] mx-auto pb-24">
|
|
||||||
<div className=" border my-6 mx-auto py-3 px-4 rounded-lg">
|
|
||||||
<p className="text-sm font-normal text-right text-black">
|
|
||||||
درباره سامانه سوت زنی
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className=" w-full flex flex-row gap-12 max-lg:flex-col-reverse items-center">
|
|
||||||
<div className='w-1/3 flex flex-col justify-between gap-8 max-lg:w-full'>
|
|
||||||
|
|
||||||
<p className="pr-6 font-normal text-sm leading-6 text-justify text-black line-clamp-5 tracking-wider max-sm:pr-0 ">
|
|
||||||
این سامانه با هدف بررسی درخواست های مردمی و شکایت های ایشان از پرسنل شهرداری و رسیدگی به آن ایجاد شده است.
|
|
||||||
فلوچارت روبرو نحوه ارسال درخواست و پیگیری آن را مشاهده می کنید.
|
|
||||||
</p>
|
|
||||||
<Link
|
|
||||||
href="#"
|
|
||||||
className="text-sm font-bold text-blue text-left underline underline-offset-4"
|
|
||||||
>
|
|
||||||
برای شروع ارسال درخواست کلیک کنید.
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
<div className='w-2/3 flex items-center max-lg:w-full max-sm:flex-wrap justify-center'>
|
|
||||||
{requestItems.map((item) => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<div
|
|
||||||
key={item.id}
|
|
||||||
className='min-w-3/12 w-3/12 h-full min-h-[11em] bg-blue transform -skew-x-[12deg] rounded-md flex items-center justify-center
|
|
||||||
max-md:min-h-[8em] max-sm:w-full max-sm:min-h-[3em]'>
|
|
||||||
<p className='text-white text-center text-sm font-bold px-6 max-md:px-3 max-md:font-medium max-sm:text-xs max-sm:font-normal '>
|
|
||||||
{item.name}</p>
|
|
||||||
</div>
|
|
||||||
<div className={cn("flex justify-center ",
|
|
||||||
item.id == 4 && "hidden"
|
|
||||||
)}>
|
|
||||||
<Image alt='!' src={svg1} className=" max-sm:hidden "/>
|
|
||||||
<IoArrowDown className="hidden max-sm:flex text-slate-600"/>
|
|
||||||
</div>
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
})}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
@ -68,130 +68,90 @@ export default function TabController() {
|
||||||
const finishedComplaints = data?.filter((item: any) => item.status == 4);
|
const finishedComplaints = data?.filter((item: any) => item.status == 4);
|
||||||
console.log(newComplaints);
|
console.log(newComplaints);
|
||||||
return (
|
return (
|
||||||
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-8 pt-9 mx-auto">
|
<div className="w-[95vw] lg:w-[82vw] xl:w-[70vw] 3xl:w-[65vw] mt-16 pt-9 mx-auto">
|
||||||
<Dialog>
|
<p className="3xl:ml-6 text-xs sm:text-sm font-bold md:hidden my-2">
|
||||||
<DialogTrigger className=" appearance-none" asChild>
|
لیست شکایت ها
|
||||||
<Button
|
</p>
|
||||||
// onClick={handelVerify}
|
<Tabs defaultValue="tab1" className="" dir="rtl">
|
||||||
type="submit"
|
<div className="w-full flex flex-col-reverse lg:flex-row gap-4 lg:gap-5 justify-between items-center mb-10">
|
||||||
className="bg-brown hover:bg-brown/90 text-white w-36 p-2 rounded-xl mt-6 md:mt-12 mb-2"
|
{/* 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">
|
||||||
</Button>
|
لیست شکایت ها |
|
||||||
</DialogTrigger>
|
</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">
|
|
||||||
لیست شکایت ها |
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
value="tab1"
|
value="tab1"
|
||||||
className="hover:border-b-2 border-b-blue"
|
className="hover:border-b-2 border-b-blue max-md:flex-1"
|
||||||
>
|
>
|
||||||
جدید (2)
|
جدید
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
value="tab2"
|
value="tab2"
|
||||||
className="hover:border-b-2 border-b-blue"
|
className="hover:border-b-2 border-b-blue max-md:flex-1"
|
||||||
>
|
>
|
||||||
در انتظار پاسخ
|
در انتظار پاسخ
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
value="tab3"
|
value="tab3"
|
||||||
className="hover:border-b-2 border-b-blue"
|
className="hover:border-b-2 border-b-blue max-md:flex-1"
|
||||||
>
|
>
|
||||||
در حال بررسی
|
در حال بررسی
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
value="tab4"
|
value="tab4"
|
||||||
className="hover:border-b-2 border-b-blue"
|
className="hover:border-b-2 border-b-blue max-md:flex-1"
|
||||||
>
|
>
|
||||||
پاسخ داده شده
|
پاسخ داده شده
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
<TabsTrigger
|
<TabsTrigger
|
||||||
value="tab5"
|
value="tab5"
|
||||||
className="hover:border-b-2 border-b-blue"
|
className="hover:border-b-2 border-b-blue max-md:flex-1"
|
||||||
>
|
>
|
||||||
پایان یافته
|
پایان یافته
|
||||||
</TabsTrigger>
|
</TabsTrigger>
|
||||||
</TabsList>
|
</TabsList>
|
||||||
|
|
||||||
{/* Search Box */}
|
{/* Search Box */}
|
||||||
<Search mode="controller" />
|
<Search mode="controller" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Tab Content */}
|
{/* Tab Content */}
|
||||||
<TabsContent value="tab1">
|
<TabsContent value="tab1">
|
||||||
<TableController
|
<TableController
|
||||||
checkKey={(item: any) => checkKey(item)}
|
checkKey={(item: any) => checkKey(item)}
|
||||||
data={newComplaints}
|
data={newComplaints}
|
||||||
/>
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="tab2">
|
<TabsContent value="tab2">
|
||||||
<TableController
|
<TableController
|
||||||
checkKey={(item: any) => checkKey(item)}
|
checkKey={(item: any) => checkKey(item)}
|
||||||
data={waitingForCitizenResponseComplaints}
|
data={waitingForCitizenResponseComplaints}
|
||||||
/>
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="tab3">
|
<TabsContent value="tab3">
|
||||||
<TableController
|
<TableController
|
||||||
checkKey={(item: any) => checkKey(item)}
|
checkKey={(item: any) => checkKey(item)}
|
||||||
data={inProgressComplaints}
|
data={inProgressComplaints}
|
||||||
/>
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="tab4">
|
<TabsContent value="tab4">
|
||||||
<TableController
|
<TableController
|
||||||
checkKey={(item: any) => checkKey(item)}
|
checkKey={(item: any) => checkKey(item)}
|
||||||
data={citizenRepliedComplaints}
|
data={citizenRepliedComplaints}
|
||||||
/>
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
|
|
||||||
<TabsContent value="tab5">
|
<TabsContent value="tab5">
|
||||||
<TableController
|
<TableController
|
||||||
checkKey={(item: any) => checkKey(item)}
|
checkKey={(item: any) => checkKey(item)}
|
||||||
data={finishedComplaints}
|
data={finishedComplaints}
|
||||||
/>
|
/>
|
||||||
</TabsContent>
|
</TabsContent>
|
||||||
</Tabs>
|
</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>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@ import { Label } from "./ui/label";
|
||||||
import { Input } from "./ui/input";
|
import { Input } from "./ui/input";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { toast } from "sonner";
|
import { toast } from "sonner";
|
||||||
|
import { ScrollArea } from "./ui/scroll-area";
|
||||||
|
import secureLocalStorage from "react-secure-storage";
|
||||||
|
import { Checkbox } from "./ui/checkbox";
|
||||||
interface Complaint {
|
interface Complaint {
|
||||||
id: string;
|
id: string;
|
||||||
trackingNumber: string;
|
trackingNumber: string;
|
||||||
|
|
@ -47,95 +50,90 @@ export default function TableController({
|
||||||
checkKey,
|
checkKey,
|
||||||
}: {
|
}: {
|
||||||
data: Complaint[];
|
data: Complaint[];
|
||||||
checkKey: (item:any) => any;
|
checkKey: (item: any) => any;
|
||||||
}) {
|
}) {
|
||||||
console.log(data);
|
|
||||||
const saveData = useData((state) => state.saveData);
|
const saveData = useData((state) => state.saveData);
|
||||||
const [selectedFile, setSelectedFile] = useState<any>(null);
|
const [selectedFile, setSelectedFile] = useState<any>(null);
|
||||||
|
const [open, setOpen] = useState<boolean>(false);
|
||||||
|
const [rowData, setRowData] = useState<Complaint | null>(null);
|
||||||
|
const [check, setCheck] = useState<any>(false);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
const handleFileChange = (event: any) => {
|
const handleFileChange = (event: any) => {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
const reader = new FileReader();
|
const reader = new FileReader();
|
||||||
reader.onload = (e) => {
|
reader.onload = (e) => {
|
||||||
const contents = e?.target?.result;
|
const contents = e?.target?.result;
|
||||||
// Process the contents of the file here
|
|
||||||
setSelectedFile(contents);
|
setSelectedFile(contents);
|
||||||
console.log(contents);
|
console.log(contents);
|
||||||
};
|
};
|
||||||
|
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
};
|
};
|
||||||
// const checkKey = (item: any) => {
|
|
||||||
// const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
|
const checkKey2 = (item: any) => {
|
||||||
// if (dcKey != false && dcKey != null) {
|
const dcKey = Decrypt(item.cipherKeyInspector, selectedFile);
|
||||||
// saveData({
|
if (dcKey != false && dcKey != null) {
|
||||||
// trackingNumber: item.trackingNumber,
|
saveData({
|
||||||
// password: Decrypt(item.cipherKeyInspector, selectedFile),
|
trackingNumber: item.trackingNumber,
|
||||||
// });
|
password: Decrypt(item.cipherKeyInspector, selectedFile),
|
||||||
// router.push(`/UserPanel/ControllerDashboard/Complaints/${item.id}`);
|
});
|
||||||
// } else {
|
secureLocalStorage.setItem("trackingNumber", item.trackingNumber);
|
||||||
// }
|
secureLocalStorage.setItem(
|
||||||
// };
|
"privateKey",
|
||||||
|
Decrypt(item.cipherKeyInspector, selectedFile)
|
||||||
|
);
|
||||||
|
router.push(`/UserPanel/ControllerDashboard/Complaints/${item.id}`);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
};
|
||||||
|
console.log(check);
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<Dialog>
|
<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">
|
||||||
{/* <DialogTrigger className=" appearance-none" asChild>
|
{/* <TableCaption>A list of your recent invoices.</TableCaption> */}
|
||||||
<Button
|
<TableHeader>
|
||||||
// onClick={handelVerify}
|
<TableRow>
|
||||||
type="submit"
|
<TableHead>ردیف</TableHead>
|
||||||
className="bg-blue hover:bg-blue/90 text-white w-36 p-2 rounded-xl"
|
<TableHead>تاریخ</TableHead>
|
||||||
>
|
<TableHead>موضوع</TableHead>
|
||||||
بارگذاری کلید جدید
|
<TableHead>دستگاه مربوطه</TableHead>
|
||||||
</Button>
|
</TableRow>
|
||||||
</DialogTrigger> */}
|
</TableHeader>
|
||||||
|
<TableBody className="bg-[#F5F5F5]">
|
||||||
<Table className="border-[1px] border-solid border-muted rounded-md ">
|
{data?.map((item: Complaint, index: number) => {
|
||||||
{/* <TableCaption>A list of your recent invoices.</TableCaption> */}
|
return (
|
||||||
<TableHeader>
|
<TableRow
|
||||||
<TableRow>
|
onClick={() => {
|
||||||
<TableHead>ردیف</TableHead>
|
localStorage.setItem("CompliantData", JSON.stringify(item));
|
||||||
<TableHead>تاریخ</TableHead>
|
router.push(
|
||||||
<TableHead>موضوع</TableHead>
|
`/UserPanel/ControllerDashboard/Complaints/${item.id}`
|
||||||
<TableHead>دستگاه مربوطه</TableHead>
|
);
|
||||||
</TableRow>
|
}}
|
||||||
</TableHeader>
|
className=" hover:bg-gray-200 cursor-pointer"
|
||||||
<TableBody className="bg-[#F5F5F5]">
|
key={item.id}
|
||||||
{data?.map((item: Complaint, index: number) => {
|
>
|
||||||
return (
|
{/* <Link
|
||||||
<TableRow
|
|
||||||
onClick={
|
|
||||||
() => checkKey(item)
|
|
||||||
// saveData({
|
|
||||||
// trackingNumber: item.trackingNumber,
|
|
||||||
// password: Decrypt(item.cipherKeyInspector),
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
className=" hover:bg-gray-200 cursor-pointer"
|
|
||||||
key={item.id}
|
|
||||||
>
|
|
||||||
{/* <Link
|
|
||||||
href={`/UserPanel/ControllerDashboard/Complaints/${item.id}`}
|
href={`/UserPanel/ControllerDashboard/Complaints/${item.id}`}
|
||||||
className="contents"
|
className="contents"
|
||||||
> */}
|
> */}
|
||||||
<TableCell className="w-1/12 font-medium ">
|
<TableCell className="w-1/12 font-medium ">
|
||||||
{index + 1}
|
{index + 1}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="w-2/12">
|
<TableCell className="w-2/12">
|
||||||
{convertDate(item.registeredAt)}
|
{convertDate(item.registeredAt)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="w-2/12">
|
<TableCell className="w-2/12">
|
||||||
{item?.category ? item.category.title : "-"}
|
{item?.title ? item.title : "-"}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell className="w-7/12">-</TableCell>
|
<TableCell className="w-7/12">-</TableCell>
|
||||||
{/* </Link> */}
|
{/* </Link> */}
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</TableBody>
|
</TableBody>
|
||||||
</Table>
|
</Table>
|
||||||
{/* <DialogTrigger asChild>
|
<Dialog open={open} onOpenChange={setOpen}>
|
||||||
<Button variant="outline">Edit Profile</Button>
|
|
||||||
</DialogTrigger> */}
|
|
||||||
<DialogContent dir="rtl" className="sm:max-w-[425px]">
|
<DialogContent dir="rtl" className="sm:max-w-[425px]">
|
||||||
<DialogHeader dir="rtl">
|
<DialogHeader dir="rtl">
|
||||||
<DialogTitle dir="rtl">بارگذاری کلید خصوصی</DialogTitle>
|
<DialogTitle dir="rtl">بارگذاری کلید خصوصی</DialogTitle>
|
||||||
|
|
@ -153,19 +151,25 @@ export default function TableController({
|
||||||
accept=".txt"
|
accept=".txt"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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>
|
<DialogFooter>
|
||||||
<DialogClose asChild>
|
<DialogClose asChild></DialogClose>
|
||||||
<Button
|
<Button onClick={() => checkKey2(rowData)} type="submit">
|
||||||
onClick={() => {
|
ذخیره
|
||||||
if (selectedFile) {
|
</Button>
|
||||||
toast("کلید شما با موفقیت بارگذاری شد.");
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
type="submit"
|
|
||||||
>
|
|
||||||
ذخیره
|
|
||||||
</Button>
|
|
||||||
</DialogClose>
|
|
||||||
</DialogFooter>
|
</DialogFooter>
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ export default function Verify() {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
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
|
<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]
|
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"
|
h-fit"
|
||||||
|
|
@ -127,60 +127,6 @@ export default function Verify() {
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
"use client"
|
"use client";
|
||||||
|
import React, { useState } from "react";
|
||||||
import React from 'react';
|
|
||||||
import {
|
import {
|
||||||
Chart as ChartJS,
|
Chart as ChartJS,
|
||||||
CategoryScale,
|
CategoryScale,
|
||||||
|
|
@ -9,10 +8,19 @@ import {
|
||||||
Title,
|
Title,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Legend,
|
Legend,
|
||||||
} from 'chart.js';
|
ChartOptions,
|
||||||
import { Bar } from 'react-chartjs-2';
|
ScaleChartOptions,
|
||||||
import { faker } from "@faker-js/faker";
|
} from "chart.js";
|
||||||
|
import { Bar, Line } from "react-chartjs-2";
|
||||||
|
import { useQuery } from "@tanstack/react-query";
|
||||||
|
import { getCookie } from "cookies-next";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
import utc from "dayjs/plugin/utc";
|
||||||
|
import jalaliday from "jalaliday";
|
||||||
|
import { backgroundColor, borderColor } from "@/constants/colors";
|
||||||
|
dayjs.extend(jalaliday);
|
||||||
|
dayjs.extend(utc);
|
||||||
|
// import faker from "faker";
|
||||||
ChartJS.register(
|
ChartJS.register(
|
||||||
CategoryScale,
|
CategoryScale,
|
||||||
LinearScale,
|
LinearScale,
|
||||||
|
|
@ -21,40 +29,119 @@ ChartJS.register(
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Legend
|
Legend
|
||||||
);
|
);
|
||||||
|
ChartJS.defaults.font.family = "Yekan";
|
||||||
export const options = {
|
interface Values {
|
||||||
responsive: true,
|
displayValue: string;
|
||||||
plugins: {
|
parameters: string;
|
||||||
legend: {
|
title: string;
|
||||||
position: 'top' as const,
|
value: string;
|
||||||
},
|
|
||||||
title: {
|
|
||||||
display: true,
|
|
||||||
text: 'Chart.js Bar Chart',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const labels = ['January', 'February', 'March', 'April', 'May', 'June', 'July'];
|
|
||||||
|
|
||||||
export const data = {
|
|
||||||
labels,
|
|
||||||
datasets: [
|
|
||||||
{
|
|
||||||
label: 'Dataset 1',
|
|
||||||
data: labels.map(() => faker.datatype.number({ min: 0, max: 1000 })),
|
|
||||||
backgroundColor: 'rgba(255, 99, 132, 0.5)',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Dataset 2',
|
|
||||||
data: labels.map(() => faker.datatype.number({ min: 0, max: 1000 })),
|
|
||||||
backgroundColor: 'rgba(53, 162, 235, 0.5)',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
export function VerticalChart() {
|
|
||||||
return (
|
|
||||||
<Bar options={options} data={data} className='!w-full !h-full'/>
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
function getRandomColor(n) {
|
||||||
|
var letters = "0123456789ABCDEF".split("");
|
||||||
|
var color = "#";
|
||||||
|
var colors = [];
|
||||||
|
for (var j = 0; j < n; j++) {
|
||||||
|
for (var i = 0; i < 6; i++) {
|
||||||
|
color += letters[Math.floor(Math.random() * 16)];
|
||||||
|
}
|
||||||
|
colors.push(color);
|
||||||
|
color = "#";
|
||||||
|
}
|
||||||
|
return colors;
|
||||||
|
}
|
||||||
|
function BarChart({
|
||||||
|
chartData,
|
||||||
|
chart,
|
||||||
|
chartTitle,
|
||||||
|
}: {
|
||||||
|
chartData: { title: string; icon: string; values: Values[] }[];
|
||||||
|
chart?: number;
|
||||||
|
chartTitle: string;
|
||||||
|
}) {
|
||||||
|
const DataSets = [];
|
||||||
|
// if (chartTitle == "درخواست های سی روز گذشته") {
|
||||||
|
// var labels = chartData[1].values.map((item) => {
|
||||||
|
// return item.title;
|
||||||
|
// });
|
||||||
|
|
||||||
|
// var label1 = chartData[0].title;
|
||||||
|
// var label2 = chartData[1].title;
|
||||||
|
// var value1 = chartData[0].values.map((item) => Number(item.value));
|
||||||
|
// var value2 = chartData[1].values.map((item) => Number(item.value));
|
||||||
|
// DataSets.push({ label: label1, data: value1 });
|
||||||
|
// DataSets.push({ label: label2, data: value2 });
|
||||||
|
// // console.log(labels);
|
||||||
|
// // console.log(value1);
|
||||||
|
// } else if ("گزارش تعداد درخواست ها بر اساس نوع بیمه") {
|
||||||
|
// var labels = chartData[0].values.map((item) => {
|
||||||
|
// return item.title;
|
||||||
|
// });
|
||||||
|
// var label1 = "";
|
||||||
|
// var value1 = chartData[0].values.map((item) => Number(item.value));
|
||||||
|
// DataSets.push({ label: label1, data: value1 });
|
||||||
|
// console.log(value1);
|
||||||
|
// }
|
||||||
|
console.log(chartData);
|
||||||
|
const options: ChartOptions<"bar"> = {
|
||||||
|
scales: { x: { ticks: { autoSkip: false } }, y: { stacked: false } },
|
||||||
|
responsive: true,
|
||||||
|
maintainAspectRatio: false,
|
||||||
|
plugins: {
|
||||||
|
title: {
|
||||||
|
display: true,
|
||||||
|
text: chartTitle,
|
||||||
|
position: "bottom",
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
textDirection: "rtl",
|
||||||
|
},
|
||||||
|
datalabels: {
|
||||||
|
display: true,
|
||||||
|
color: "black",
|
||||||
|
align: "end",
|
||||||
|
anchor: "end",
|
||||||
|
font: { size: 12 },
|
||||||
|
formatter: function (value, context) {
|
||||||
|
return value == 0 ? "" : value;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// scales: {
|
||||||
|
// x: { ticks: { autoSkip: false } },
|
||||||
|
// y: {
|
||||||
|
// stacked: false,
|
||||||
|
// // suggestedMax:
|
||||||
|
// // Math.max(
|
||||||
|
// // ...chartData.map((l, j) => {
|
||||||
|
// // console.log(l);
|
||||||
|
// // const a = l.values.map((v) => {
|
||||||
|
// // return Number(v.value);
|
||||||
|
// // });
|
||||||
|
// // const b = Math.max(...a);
|
||||||
|
// // console.log(b);
|
||||||
|
// // return l.values.map((v) => Number(v.value));
|
||||||
|
// // })
|
||||||
|
// // ) * 1.2,
|
||||||
|
// },
|
||||||
|
// },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
labels: chartData[0]?.values?.map((item) => {
|
||||||
|
return item.title;
|
||||||
|
}),
|
||||||
|
datasets: chartData.map((item: any, index: number) => {
|
||||||
|
return {
|
||||||
|
label: item.title,
|
||||||
|
data: item.values.map((item) => item.value),
|
||||||
|
backgroundColor: backgroundColor[index],
|
||||||
|
borderColor: borderColor[index],
|
||||||
|
borderWidth: 1,
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
// console.log(data);
|
||||||
|
return <Bar dir="rtl" className="min-h-[20rem]" options={options} data={data} />;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BarChart;
|
||||||
|
|
|
||||||
|
|
@ -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 }
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const ScrollArea = React.forwardRef<
|
||||||
|
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
|
||||||
|
>(({ className, children, ...props }, ref) => (
|
||||||
|
<ScrollAreaPrimitive.Root
|
||||||
|
ref={ref}
|
||||||
|
className={cn("relative overflow-hidden", className)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
||||||
|
{children}
|
||||||
|
</ScrollAreaPrimitive.Viewport>
|
||||||
|
<ScrollBar />
|
||||||
|
<ScrollAreaPrimitive.Corner />
|
||||||
|
</ScrollAreaPrimitive.Root>
|
||||||
|
))
|
||||||
|
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName
|
||||||
|
|
||||||
|
const ScrollBar = React.forwardRef<
|
||||||
|
React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||||
|
>(({ className, orientation = "vertical", ...props }, ref) => (
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaScrollbar
|
||||||
|
ref={ref}
|
||||||
|
orientation={orientation}
|
||||||
|
className={cn(
|
||||||
|
"flex touch-none select-none transition-colors",
|
||||||
|
orientation === "vertical" &&
|
||||||
|
"h-full w-2.5 border-l border-l-transparent p-[1px]",
|
||||||
|
orientation === "horizontal" &&
|
||||||
|
"h-2.5 flex-col border-t border-t-transparent p-[1px]",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
|
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
||||||
|
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
||||||
|
))
|
||||||
|
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName
|
||||||
|
|
||||||
|
export { ScrollArea, ScrollBar }
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
"use client"
|
||||||
|
|
||||||
|
import * as React from "react"
|
||||||
|
import * as SeparatorPrimitive from "@radix-ui/react-separator"
|
||||||
|
|
||||||
|
import { cn } from "@/lib/utils"
|
||||||
|
|
||||||
|
const Separator = React.forwardRef<
|
||||||
|
React.ElementRef<typeof SeparatorPrimitive.Root>,
|
||||||
|
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root>
|
||||||
|
>(
|
||||||
|
(
|
||||||
|
{ className, orientation = "horizontal", decorative = true, ...props },
|
||||||
|
ref
|
||||||
|
) => (
|
||||||
|
<SeparatorPrimitive.Root
|
||||||
|
ref={ref}
|
||||||
|
decorative={decorative}
|
||||||
|
orientation={orientation}
|
||||||
|
className={cn(
|
||||||
|
"shrink-0 bg-border",
|
||||||
|
orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
)
|
||||||
|
Separator.displayName = SeparatorPrimitive.Root.displayName
|
||||||
|
|
||||||
|
export { Separator }
|
||||||
|
|
@ -0,0 +1,65 @@
|
||||||
|
export const backgroundColor = [
|
||||||
|
"rgba(255, 99, 132, 0.2)",
|
||||||
|
"rgba(54, 162, 235, 0.2)",
|
||||||
|
"rgba(255, 206, 86, 0.2)",
|
||||||
|
"rgba(75, 192, 192, 0.2)",
|
||||||
|
"rgba(153, 102, 255, 0.2)",
|
||||||
|
"rgba(255, 159, 64, 0.2)",
|
||||||
|
"rgba(255, 0, 0, 0.2)",
|
||||||
|
"rgba(0, 255, 0, 0.2)",
|
||||||
|
"rgba(0, 0, 255, 0.2)",
|
||||||
|
"rgba(255, 255, 0, 0.2)",
|
||||||
|
"rgba(255, 0, 255, 0.2)",
|
||||||
|
"rgba(0, 255, 255, 0.2)",
|
||||||
|
"rgba(128, 0, 0, 0.2)",
|
||||||
|
"rgba(0, 128, 0, 0.2)",
|
||||||
|
"rgba(0, 0, 128, 0.2)",
|
||||||
|
"rgba(128, 128, 0, 0.2)",
|
||||||
|
"rgba(128, 0, 128, 0.2)",
|
||||||
|
"rgba(0, 128, 128, 0.2)",
|
||||||
|
"rgba(255, 128, 0, 0.2)",
|
||||||
|
"rgba(128, 255, 0, 0.2)",
|
||||||
|
"rgba(0, 255, 128, 0.2)",
|
||||||
|
"rgba(0, 128, 255, 0.2)",
|
||||||
|
"rgba(128, 0, 255, 0.2)",
|
||||||
|
"rgba(255, 0, 128, 0.2)",
|
||||||
|
"rgba(255, 128, 128, 0.2)",
|
||||||
|
"rgba(128, 255, 128, 0.2)",
|
||||||
|
"rgba(128, 128, 255, 0.2)",
|
||||||
|
"rgba(192, 192, 192, 0.2)",
|
||||||
|
"rgba(128, 128, 128, 0.2)",
|
||||||
|
"rgba(0, 0, 0, 0.2)",
|
||||||
|
];
|
||||||
|
|
||||||
|
export const borderColor = [
|
||||||
|
"rgba(255, 99, 132, 1)",
|
||||||
|
"rgba(54, 162, 235, 1)",
|
||||||
|
"rgba(255, 206, 86, 1)",
|
||||||
|
"rgba(75, 192, 192, 1)",
|
||||||
|
"rgba(153, 102, 255, 1)",
|
||||||
|
"rgba(255, 159, 64, 1)",
|
||||||
|
"rgba(255, 0, 0, 1)",
|
||||||
|
"rgba(0, 255, 0, 1)",
|
||||||
|
"rgba(0, 0, 255, 1)",
|
||||||
|
"rgba(255, 255, 0, 1)",
|
||||||
|
"rgba(255, 0, 255, 1)",
|
||||||
|
"rgba(0, 255, 255, 1)",
|
||||||
|
"rgba(128, 0, 0, 1)",
|
||||||
|
"rgba(0, 128, 0, 1)",
|
||||||
|
"rgba(0, 0, 128, 1)",
|
||||||
|
"rgba(128, 128, 0, 1)",
|
||||||
|
"rgba(128, 0, 128, 1)",
|
||||||
|
"rgba(0, 128, 128, 1)",
|
||||||
|
"rgba(255, 128, 0, 1)",
|
||||||
|
"rgba(128, 255, 0, 1)",
|
||||||
|
"rgba(0, 255, 128, 1)",
|
||||||
|
"rgba(0, 128, 255, 1)",
|
||||||
|
"rgba(128, 0, 255, 1)",
|
||||||
|
"rgba(255, 0, 128, 1)",
|
||||||
|
"rgba(255, 128, 128, 1)",
|
||||||
|
"rgba(128, 255, 128, 1)",
|
||||||
|
"rgba(128, 128, 255, 1)",
|
||||||
|
"rgba(192, 192, 192, 1)",
|
||||||
|
"rgba(128, 128, 128, 1)",
|
||||||
|
"rgba(0, 0, 0, 1)",
|
||||||
|
];
|
||||||
|
|
@ -143,8 +143,8 @@ export const AdminMenuItems = [
|
||||||
{ id: 1, name: "داشبورد", href: "/UserPanel/AdminDashboard" },
|
{ id: 1, name: "داشبورد", href: "/UserPanel/AdminDashboard" },
|
||||||
{ id: 2, name: "مدیریت کاربران", href: "/UserPanel/AdminDashboard/UserManagement" },
|
{ id: 2, name: "مدیریت کاربران", href: "/UserPanel/AdminDashboard/UserManagement" },
|
||||||
{ id: 3, name: "مدیریت کلید ها", href: "/UserPanel/AdminDashboard/KeysManagement" },
|
{ id: 3, name: "مدیریت کلید ها", href: "/UserPanel/AdminDashboard/KeysManagement" },
|
||||||
{ id: 4, name: "گزارشات و آمار", href: "/UserPanel/AdminDashboard/#" },
|
{ id: 4, name: "سازمان ها", href: "/UserPanel/AdminDashboard/Organizations" },
|
||||||
{ id: 5, name: "تنظیمات", href: "/UserPanel/AdminDashboard/#" },
|
{ id: 5, name: "دسته بندی ها", href: "/UserPanel/AdminDashboard/Categories" },
|
||||||
];
|
];
|
||||||
|
|
||||||
export const ControllerTableItems = [
|
export const ControllerTableItems = [
|
||||||
|
|
|
||||||
17
lib/utils.ts
17
lib/utils.ts
|
|
@ -19,22 +19,7 @@ export function convertDate(date: string) {
|
||||||
return convertedDate;
|
return convertedDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Decrypt(encryptedData: string , privateKey: string) {
|
export function Decrypt(encryptedData: any, privateKey: any) {
|
||||||
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-----`;
|
|
||||||
const decryptor = new JSEncrypt();
|
const decryptor = new JSEncrypt();
|
||||||
decryptor.setPrivateKey(privateKey);
|
decryptor.setPrivateKey(privateKey);
|
||||||
const decrypted = decryptor.decrypt(encryptedData);
|
const decrypted = decryptor.decrypt(encryptedData);
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,15 @@
|
||||||
"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",
|
||||||
|
"@radix-ui/react-checkbox": "^1.0.4",
|
||||||
"@radix-ui/react-dialog": "^1.0.5",
|
"@radix-ui/react-dialog": "^1.0.5",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
||||||
"@radix-ui/react-icons": "^1.3.0",
|
"@radix-ui/react-icons": "^1.3.0",
|
||||||
"@radix-ui/react-label": "^2.0.2",
|
"@radix-ui/react-label": "^2.0.2",
|
||||||
"@radix-ui/react-radio-group": "^1.1.3",
|
"@radix-ui/react-radio-group": "^1.1.3",
|
||||||
|
"@radix-ui/react-scroll-area": "^1.0.5",
|
||||||
"@radix-ui/react-select": "^2.0.0",
|
"@radix-ui/react-select": "^2.0.0",
|
||||||
|
"@radix-ui/react-separator": "^1.0.3",
|
||||||
"@radix-ui/react-slot": "^1.0.2",
|
"@radix-ui/react-slot": "^1.0.2",
|
||||||
"@radix-ui/react-tabs": "^1.0.4",
|
"@radix-ui/react-tabs": "^1.0.4",
|
||||||
"@radix-ui/react-toast": "^1.1.5",
|
"@radix-ui/react-toast": "^1.1.5",
|
||||||
|
|
@ -24,6 +27,7 @@
|
||||||
"@uidotdev/usehooks": "^2.4.1",
|
"@uidotdev/usehooks": "^2.4.1",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
"chart.js": "^4.4.1",
|
"chart.js": "^4.4.1",
|
||||||
|
"chartjs-plugin-datalabels": "^2.2.0",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.0.0",
|
"clsx": "^2.0.0",
|
||||||
"cookies-next": "^4.1.0",
|
"cookies-next": "^4.1.0",
|
||||||
|
|
@ -39,6 +43,7 @@
|
||||||
"lucide-react": "^0.292.0",
|
"lucide-react": "^0.292.0",
|
||||||
"next": "14.0.3",
|
"next": "14.0.3",
|
||||||
"next-themes": "^0.2.1",
|
"next-themes": "^0.2.1",
|
||||||
|
"nextjs-toploader": "^1.6.4",
|
||||||
"npm": "^10.2.5",
|
"npm": "^10.2.5",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-chartjs-2": "^5.2.0",
|
"react-chartjs-2": "^5.2.0",
|
||||||
|
|
@ -49,6 +54,7 @@
|
||||||
"react-loader-spinner": "^6.1.6",
|
"react-loader-spinner": "^6.1.6",
|
||||||
"react-otp-input": "^3.1.1",
|
"react-otp-input": "^3.1.1",
|
||||||
"react-responsive": "^9.0.2",
|
"react-responsive": "^9.0.2",
|
||||||
|
"react-secure-storage": "^1.3.2",
|
||||||
"react-spinners": "^0.13.8",
|
"react-spinners": "^0.13.8",
|
||||||
"react-to-print": "^2.14.15",
|
"react-to-print": "^2.14.15",
|
||||||
"react-use": "^17.4.2",
|
"react-use": "^17.4.2",
|
||||||
|
|
@ -69,6 +75,7 @@
|
||||||
"eslint": "^8",
|
"eslint": "^8",
|
||||||
"eslint-config-next": "14.0.3",
|
"eslint-config-next": "14.0.3",
|
||||||
"postcss": "^8",
|
"postcss": "^8",
|
||||||
|
"tailwind-scrollbar": "^3.0.5",
|
||||||
"tailwindcss": "^3.3.0",
|
"tailwindcss": "^3.3.0",
|
||||||
"typescript": "^5"
|
"typescript": "^5"
|
||||||
}
|
}
|
||||||
|
|
@ -576,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": {
|
"node_modules/@radix-ui/react-collection": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.0.3.tgz",
|
||||||
|
|
@ -1041,6 +1078,37 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-scroll-area": {
|
||||||
|
"version": "1.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-scroll-area/-/react-scroll-area-1.0.5.tgz",
|
||||||
|
"integrity": "sha512-b6PAgH4GQf9QEn8zbT2XUHpW5z8BzqEc7Kl11TwDrvuTrxlkcjTD5qa/bxgKr+nmuXKu4L/W5UZ4mlP/VG/5Gw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.13.10",
|
||||||
|
"@radix-ui/number": "1.0.1",
|
||||||
|
"@radix-ui/primitive": "1.0.1",
|
||||||
|
"@radix-ui/react-compose-refs": "1.0.1",
|
||||||
|
"@radix-ui/react-context": "1.0.1",
|
||||||
|
"@radix-ui/react-direction": "1.0.1",
|
||||||
|
"@radix-ui/react-presence": "1.0.1",
|
||||||
|
"@radix-ui/react-primitive": "1.0.3",
|
||||||
|
"@radix-ui/react-use-callback-ref": "1.0.1",
|
||||||
|
"@radix-ui/react-use-layout-effect": "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-select": {
|
"node_modules/@radix-ui/react-select": {
|
||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.0.0.tgz",
|
||||||
|
|
@ -1084,6 +1152,29 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@radix-ui/react-separator": {
|
||||||
|
"version": "1.0.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.0.3.tgz",
|
||||||
|
"integrity": "sha512-itYmTy/kokS21aiV5+Z56MZB54KrhPgn6eHDKkFeOLR34HMN2s8PaN47qZZAGnvupcjxHaFZnW4pQEh0BvvVuw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@babel/runtime": "^7.13.10",
|
||||||
|
"@radix-ui/react-primitive": "1.0.3"
|
||||||
|
},
|
||||||
|
"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-slot": {
|
"node_modules/@radix-ui/react-slot": {
|
||||||
"version": "1.0.2",
|
"version": "1.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.0.2.tgz",
|
||||||
|
|
@ -1433,6 +1524,11 @@
|
||||||
"undici-types": "~5.26.4"
|
"undici-types": "~5.26.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/nprogress": {
|
||||||
|
"version": "0.2.3",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/nprogress/-/nprogress-0.2.3.tgz",
|
||||||
|
"integrity": "sha512-k7kRA033QNtC+gLc4VPlfnue58CM1iQLgn1IMAU8VPHGOj7oIHPp9UlhedEnD/Gl8evoCjwkZjlBORtZ3JByUA=="
|
||||||
|
},
|
||||||
"node_modules/@types/prop-types": {
|
"node_modules/@types/prop-types": {
|
||||||
"version": "15.7.11",
|
"version": "15.7.11",
|
||||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz",
|
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.11.tgz",
|
||||||
|
|
@ -2092,6 +2188,14 @@
|
||||||
"pnpm": ">=7"
|
"pnpm": ">=7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/chartjs-plugin-datalabels": {
|
||||||
|
"version": "2.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/chartjs-plugin-datalabels/-/chartjs-plugin-datalabels-2.2.0.tgz",
|
||||||
|
"integrity": "sha512-14ZU30lH7n89oq+A4bWaJPnAG8a7ZTk7dKf48YAzMvJjQtjrgg5Dpk9f+LbjCF6bpx3RAGTeL13IXpKQYyRvlw==",
|
||||||
|
"peerDependencies": {
|
||||||
|
"chart.js": ">=3.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/chokidar": {
|
"node_modules/chokidar": {
|
||||||
"version": "3.5.3",
|
"version": "3.5.3",
|
||||||
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
|
||||||
|
|
@ -2240,6 +2344,11 @@
|
||||||
"node": ">= 8"
|
"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": {
|
"node_modules/css-color-keywords": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/css-color-keywords/-/css-color-keywords-1.0.0.tgz",
|
||||||
|
|
@ -4230,6 +4339,11 @@
|
||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||||
"dev": true
|
"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": {
|
"node_modules/mz": {
|
||||||
"version": "2.7.0",
|
"version": "2.7.0",
|
||||||
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz",
|
||||||
|
|
@ -4337,6 +4451,21 @@
|
||||||
"react-dom": "*"
|
"react-dom": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/nextjs-toploader": {
|
||||||
|
"version": "1.6.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/nextjs-toploader/-/nextjs-toploader-1.6.4.tgz",
|
||||||
|
"integrity": "sha512-KYLQ+0MvGdFk9JwOQfRtaYBAsyuX67Ca5QTa51RGNO4gQx64KLSE+ryHjUQ5LcDczHotp0l32GgksQW9vucUkw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/nprogress": "^0.2.1",
|
||||||
|
"nprogress": "^0.2.0",
|
||||||
|
"prop-types": "^15.8.1"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"next": ">= 6.0.0",
|
||||||
|
"react": ">= 16.0.0",
|
||||||
|
"react-dom": ">= 16.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/node-releases": {
|
"node_modules/node-releases": {
|
||||||
"version": "2.0.13",
|
"version": "2.0.13",
|
||||||
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz",
|
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.13.tgz",
|
||||||
|
|
@ -7091,6 +7220,11 @@
|
||||||
"inBundle": true,
|
"inBundle": true,
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
|
"node_modules/nprogress": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/nprogress/-/nprogress-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-I19aIingLgR1fmhftnbWWO3dXc0hSxqHQHQb3H8m+K3TnEn/iSeTZZOyvKXWqQESMwuUVnatlCnZdLBZZt2VSA=="
|
||||||
|
},
|
||||||
"node_modules/object-assign": {
|
"node_modules/object-assign": {
|
||||||
"version": "4.1.1",
|
"version": "4.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
|
||||||
|
|
@ -7710,6 +7844,15 @@
|
||||||
"react": ">=16.8.0"
|
"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": {
|
"node_modules/react-spinners": {
|
||||||
"version": "0.13.8",
|
"version": "0.13.8",
|
||||||
"resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.13.8.tgz",
|
"resolved": "https://registry.npmjs.org/react-spinners/-/react-spinners-0.13.8.tgz",
|
||||||
|
|
@ -8431,6 +8574,18 @@
|
||||||
"url": "https://github.com/sponsors/dcastil"
|
"url": "https://github.com/sponsors/dcastil"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/tailwind-scrollbar": {
|
||||||
|
"version": "3.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/tailwind-scrollbar/-/tailwind-scrollbar-3.0.5.tgz",
|
||||||
|
"integrity": "sha512-0ZwxTivevqq9BY9fRP9zDjHl7Tu+J5giBGbln+0O1R/7nHtBUKnjQcA1aTIhK7Oyjp6Uc/Dj6/dn8Dq58k5Uww==",
|
||||||
|
"dev": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=12.13.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"tailwindcss": "3.x"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/tailwindcss": {
|
"node_modules/tailwindcss": {
|
||||||
"version": "3.3.5",
|
"version": "3.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.5.tgz",
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,15 @@
|
||||||
"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",
|
||||||
|
"@radix-ui/react-checkbox": "^1.0.4",
|
||||||
"@radix-ui/react-dialog": "^1.0.5",
|
"@radix-ui/react-dialog": "^1.0.5",
|
||||||
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
||||||
"@radix-ui/react-icons": "^1.3.0",
|
"@radix-ui/react-icons": "^1.3.0",
|
||||||
"@radix-ui/react-label": "^2.0.2",
|
"@radix-ui/react-label": "^2.0.2",
|
||||||
"@radix-ui/react-radio-group": "^1.1.3",
|
"@radix-ui/react-radio-group": "^1.1.3",
|
||||||
|
"@radix-ui/react-scroll-area": "^1.0.5",
|
||||||
"@radix-ui/react-select": "^2.0.0",
|
"@radix-ui/react-select": "^2.0.0",
|
||||||
|
"@radix-ui/react-separator": "^1.0.3",
|
||||||
"@radix-ui/react-slot": "^1.0.2",
|
"@radix-ui/react-slot": "^1.0.2",
|
||||||
"@radix-ui/react-tabs": "^1.0.4",
|
"@radix-ui/react-tabs": "^1.0.4",
|
||||||
"@radix-ui/react-toast": "^1.1.5",
|
"@radix-ui/react-toast": "^1.1.5",
|
||||||
|
|
@ -25,6 +28,7 @@
|
||||||
"@uidotdev/usehooks": "^2.4.1",
|
"@uidotdev/usehooks": "^2.4.1",
|
||||||
"axios": "^1.6.2",
|
"axios": "^1.6.2",
|
||||||
"chart.js": "^4.4.1",
|
"chart.js": "^4.4.1",
|
||||||
|
"chartjs-plugin-datalabels": "^2.2.0",
|
||||||
"class-variance-authority": "^0.7.0",
|
"class-variance-authority": "^0.7.0",
|
||||||
"clsx": "^2.0.0",
|
"clsx": "^2.0.0",
|
||||||
"cookies-next": "^4.1.0",
|
"cookies-next": "^4.1.0",
|
||||||
|
|
@ -40,6 +44,7 @@
|
||||||
"lucide-react": "^0.292.0",
|
"lucide-react": "^0.292.0",
|
||||||
"next": "14.0.3",
|
"next": "14.0.3",
|
||||||
"next-themes": "^0.2.1",
|
"next-themes": "^0.2.1",
|
||||||
|
"nextjs-toploader": "^1.6.4",
|
||||||
"npm": "^10.2.5",
|
"npm": "^10.2.5",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-chartjs-2": "^5.2.0",
|
"react-chartjs-2": "^5.2.0",
|
||||||
|
|
@ -50,6 +55,7 @@
|
||||||
"react-loader-spinner": "^6.1.6",
|
"react-loader-spinner": "^6.1.6",
|
||||||
"react-otp-input": "^3.1.1",
|
"react-otp-input": "^3.1.1",
|
||||||
"react-responsive": "^9.0.2",
|
"react-responsive": "^9.0.2",
|
||||||
|
"react-secure-storage": "^1.3.2",
|
||||||
"react-spinners": "^0.13.8",
|
"react-spinners": "^0.13.8",
|
||||||
"react-to-print": "^2.14.15",
|
"react-to-print": "^2.14.15",
|
||||||
"react-use": "^17.4.2",
|
"react-use": "^17.4.2",
|
||||||
|
|
@ -70,6 +76,7 @@
|
||||||
"eslint": "^8",
|
"eslint": "^8",
|
||||||
"eslint-config-next": "14.0.3",
|
"eslint-config-next": "14.0.3",
|
||||||
"postcss": "^8",
|
"postcss": "^8",
|
||||||
|
"tailwind-scrollbar": "^3.0.5",
|
||||||
"tailwindcss": "^3.3.0",
|
"tailwindcss": "^3.3.0",
|
||||||
"typescript": "^5"
|
"typescript": "^5"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,5 +85,5 @@ module.exports = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [require("tailwindcss-animate")],
|
plugins: [require("tailwindcss-animate"), require("tailwind-scrollbar")],
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ axios.interceptors.request.use(function (config) {
|
||||||
return config;
|
return config;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
export async function GenerateKeyPair() {
|
export async function GenerateKeyPair() {
|
||||||
const data = await axios.get("api/Admin/GenerateKeyPair");
|
const data = await axios.get("api/Admin/GenerateKeyPair");
|
||||||
return data.data;
|
return data.data;
|
||||||
|
|
@ -32,3 +31,79 @@ export async function ChangeKey(payload: {
|
||||||
const data = await axios.post("api/Admin/ChangeKey", payload);
|
const data = await axios.post("api/Admin/ChangeKey", payload);
|
||||||
return data.data;
|
return data.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// .....Categories.......
|
||||||
|
export async function GetAllCategories() {
|
||||||
|
const data = await axios.get("api/ComplaintCategories");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GetSingleCategory({ id }: { id: string }) {
|
||||||
|
const data = await axios.get(`api/ComplaintCategories/${id}`);
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function SubmitCategory(payload: {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
}) {
|
||||||
|
const data = await axios.post("api/ComplaintCategories", payload);
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function UpdateCategory({
|
||||||
|
id,
|
||||||
|
payload,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
payload: {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
};
|
||||||
|
}) {
|
||||||
|
const data = await axios.put(`api/ComplaintCategories/${id}`, payload);
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function DeleteCategory({ id }: { id: string }) {
|
||||||
|
const data = await axios.delete(`api/ComplaintCategories/${id}`);
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// .....Organizations.......
|
||||||
|
export async function GetAllOrganizations() {
|
||||||
|
const data = await axios.get("api/ComplaintOrganizations");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function GetSingleOrganization({ id }: { id: string }) {
|
||||||
|
const data = await axios.get(`api/ComplaintOrganizations/${id}`);
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function SubmitOrganization(payload: {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
}) {
|
||||||
|
const data = await axios.post("api/ComplaintOrganizations", payload);
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function UpdateOrganization({
|
||||||
|
id,
|
||||||
|
payload,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
payload: {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
};
|
||||||
|
}) {
|
||||||
|
const data = await axios.put(`api/ComplaintOrganizations/${id}`, payload);
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function DeleteOrganization({ id }: { id: string }) {
|
||||||
|
const data = await axios.delete(`api/ComplaintOrganizations/${id}`);
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { CookieValueTypes } from "cookies-next";
|
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: {
|
export async function loginStaff(payload: {
|
||||||
username: string;
|
username: string;
|
||||||
|
|
|
||||||
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
import axios from "axios";
|
||||||
|
import { CookieValueTypes, getCookie } from "cookies-next";
|
||||||
|
|
||||||
|
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
||||||
|
|
||||||
|
axios.interceptors.request.use(function (config) {
|
||||||
|
const token = getCookie("Sootzani_Token");
|
||||||
|
config.headers.Authorization = token ? `Bearer ${token}` : "";
|
||||||
|
return config;
|
||||||
|
});
|
||||||
|
|
||||||
|
export async function getInfoList() {
|
||||||
|
const data = await axios.get("api/Info/List");
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
|
export async function getInfo(id: string = "0") {
|
||||||
|
const data = await axios.get(`api/Info/${id}`);
|
||||||
|
return data.data;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue