Merge branch 'Kahdooei'

Kahdooei
Hossein Rahmani 2024-01-02 00:39:25 +03:30
commit e1d9413e99
13 changed files with 405 additions and 33 deletions

View File

@ -0,0 +1,8 @@
import AdminKeysManagement from '@/components/AdminKeysManagement'
import React from 'react'
export default function page() {
return (
<AdminKeysManagement />
)
}

View File

@ -1,8 +0,0 @@
import AdminManagement from '@/components/AdminManagement'
import React from 'react'
export default function page() {
return (
<AdminManagement />
)
}

View File

@ -0,0 +1,8 @@
import AdminUserManagement from '@/components/AdminUserManagement'
import React from 'react'
export default function page() {
return (
<AdminUserManagement />
)
}

View File

@ -21,7 +21,7 @@ import { sliderItems } from "@/constants";
export default function Landing() {
return (
<div>
<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}
@ -47,7 +47,7 @@ export default function Landing() {
// width={20}
// height={20}
quality={100}
className=" w-full h-full object-cover"
className=" w-full h-full object-cover max-sm:object-[70%]"
/>
</SwiperSlide>
);

View File

@ -0,0 +1,257 @@
"use client";
import React, { useState } from "react";
import { useQuery } from "@tanstack/react-query";
import { GenerateKeyPair, GetKeys } from "@/utils/adminApi";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { ThreeDots } from "react-loader-spinner";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
// const FormSchema = z.object({
// title: 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 AdminKeysManagement() {
// List Keys
const {
data: data1,
error: Error1,
isLoading: isListLoading,
refetch: refetch1,
} = useQuery({
queryKey: ["KeysList"],
queryFn: () => GetKeys(),
// refetchOnWindowFocus: false,
});
console.log(data1);
// GenerateKeyPair
const {
data: data2,
error: Error2,
isLoading: isNewKeyLoading,
refetch: refetch2,
} = useQuery({
queryKey: ["GenerateKey"],
queryFn: () => GenerateKeyPair(),
enabled: false, // Disable automatic fetching
});
const handleClick = () => {
refetch2();
console.log(data2);
// Manually trigger the query when the button is clicked
};
// }
return (
<div className="w-full bg-[#F5F5F5] min-h-[82vh] flex justify-center">
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">
{/* 1 */}
<AlertDialog>
<AlertDialogTrigger asChild>
<Button
variant="outline"
onClick={handleClick}
disabled={isNewKeyLoading}
>
{" "}
ایجاد جفت کلید
</Button>
</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>
) : (
<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">
کلید خصوصی :
</p>
<p className="text-slate-700 text-sm text-left mb-4">
{data2?.privateKey}
</p>
</div>
)}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>بستن</AlertDialogCancel>
{/* <AlertDialogAction>Continue</AlertDialogAction> */}
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
{/* 1 */}
<AlertDialog>
<AlertDialogTrigger asChild>
<Button
variant="outline"
onClick={handleClick}
disabled={isNewKeyLoading}
>
افزودن کلید جدید
</Button>
</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">
عنوان کلید :
<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>
</div>
);
})}
</div>
</div>
</div>
);
}

View File

@ -22,7 +22,7 @@ import { Button } from "./ui/button";
import { AdminCardItems } from "@/constants";
import TableAdmin from "./TableAdmin";
export default function AdminManagement() {
export default function AdminUserManagement() {
return (
<div className="w-full bg-[#F5F5F5] min-h-[82vh] flex justify-center">
<div className="w-[95vw] lg:w-[85vw] 3xl:w-[70vw] mt-8 max-sm:mt-16 pt-9 ">

View File

@ -118,7 +118,7 @@ export default function ComplainsDetails({
<div className=" flex flex-col gap-y-4 mt-4">
{data.contents?.map((item: any) => {
return (
<div className=" bg-white p-4 rounded-lg shadow-md">
<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>
@ -140,6 +140,26 @@ export default function ComplainsDetails({
);
})}
{/* {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-[#7C838A] mt-2">
متن: {item.text ? item.text : "-"}
</div>
</div>
);
})}
{data.contents?.map((item: any) => {
return (
<div className=" bg-white p-4 rounded-lg shadow-md">
<div className=" flex gap-4 items-center">
@ -158,7 +178,47 @@ export default function ComplainsDetails({
</div>
</div>
);
})} */}
})}
{data.contents?.map((item: any) => {
return (
<div 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-[#7C838A] mt-2">
متن: {item.text ? item.text : "-"}
</div>
</div>
);
})}
{data.contents?.map((item: any) => {
return (
<div 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-[#7C838A] mt-2">
متن: {item.text ? item.text : "-"}
</div>
</div>
);
})}
</div>
</div>
<div className=" lg:hidden order-2 w-full bg-[#E9E9E9] rounded-md py-4 px-10 flex flex-col">

View File

@ -31,11 +31,19 @@ export default function FollowResult() {
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(() => {
@ -119,6 +127,39 @@ export default function FollowResult() {
</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 />
<AlertDialogDescription className="h-full">
{complaintPrintMutation.isPending ? (
<div className="felx justify-center items-center self-center h-full">

View File

@ -68,7 +68,9 @@ export default function NavbarPanel() {
</div>
<h1 className="text-white inline-block bg-clip-text before:max-md:hidden text-sm font-bold max-md:text-xs max-md:font-medium">
نام و نام خانوادگی (بازرس)
{role === 'Admin' ? 'نام و نام خانوادگی (ادمین)' : 'نام و نام خانوادگی (بازرس)'}
</h1>
</div>
);

View File

@ -64,7 +64,7 @@ export default function RequestStep1() {
<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-800 dark:text-white">
<p className="text-sm md:text-base font-bold leading-tight tracking-tight text-red-500 dark:text-white">
در صورت عدم تمایل به ثبت مشخصات شخصی می توانید به صفحه ی بعد مراجعه کنید.
</p>
<Form {...form}>

View File

@ -68,19 +68,19 @@ const FormSchema = z.object({
}),
uploadFile: z
.custom<FileList>((val) => val instanceof FileList, "Required")
.refine((files) => files.length > 0, `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"
),
// .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.",
}),
@ -331,7 +331,7 @@ export default function RequestStep2() {
<Input
type="file"
className="mb-3"
accept="image/*"
accept="image/* , .pdf"
multiple={true}
disabled={form.formState.isSubmitting}
{...field}

View File

@ -141,13 +141,10 @@ export const ControllerMenuItems = [
export const AdminMenuItems = [
{ id: 1, name: "داشبورد", href: "/UserPanel/AdminDashboard" },
{
id: 2,
name: "مدیریت کاربران",
href: "/UserPanel/AdminDashboard/Management",
},
{ id: 2, name: "تنظیمات", href: "/UserPanel/AdminDashboard" },
{ id: 3, name: "گزارشات و آمار", href: "/UserPanel/AdminDashboard" },
{ id: 2, name: "مدیریت کاربران", href: "/UserPanel/AdminDashboard/UserManagement" },
{ id: 3, name: "مدیریت کلید ها", href: "/UserPanel/AdminDashboard/KeysManagement" },
{ id: 4, name: "گزارشات و آمار", href: "/UserPanel/AdminDashboard/#" },
{ id: 5, name: "تنظیمات", href: "/UserPanel/AdminDashboard/#" },
];
export const ControllerTableItems = [

View File

@ -1,8 +1,15 @@
import axios from "axios";
import { CookieValueTypes } from "cookies-next";
import { CookieValueTypes, getCookie } from "cookies-next";
axios.defaults.baseURL = "https://sootzaniapi.shetabdahi.ir/";
axios.interceptors.request.use(function (config) {
const token = getCookie("Sootzani_Token");
config.headers.Authorization = token ? `Bearer ${token}` : "";
return config;
});
export async function GenerateKeyPair() {
const data = await axios.get("api/Admin/GenerateKeyPair");
return data.data;