Part of Admin panel done
parent
4381d3a7f3
commit
38c23c9063
|
|
@ -0,0 +1,8 @@
|
|||
import AdminKeysManagement from '@/components/AdminKeysManagement'
|
||||
import React from 'react'
|
||||
|
||||
export default function page() {
|
||||
return (
|
||||
<AdminKeysManagement />
|
||||
)
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
import AdminManagement from '@/components/AdminManagement'
|
||||
import React from 'react'
|
||||
|
||||
export default function page() {
|
||||
return (
|
||||
<AdminManagement />
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
import AdminUserManagement from '@/components/AdminUserManagement'
|
||||
import React from 'react'
|
||||
|
||||
export default function page() {
|
||||
return (
|
||||
<AdminUserManagement />
|
||||
)
|
||||
}
|
||||
|
|
@ -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>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
);
|
||||
}
|
||||
|
|
@ -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 ">
|
||||
|
|
@ -90,7 +90,7 @@ export default function ComplainsDetails({ id }: { id: number }) {
|
|||
<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>
|
||||
|
|
@ -110,7 +110,7 @@ export default function ComplainsDetails({ id }: { id: number }) {
|
|||
})}
|
||||
{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>
|
||||
|
|
@ -130,7 +130,7 @@ export default function ComplainsDetails({ id }: { id: number }) {
|
|||
})}
|
||||
{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>
|
||||
|
|
@ -150,7 +150,7 @@ export default function ComplainsDetails({ id }: { id: number }) {
|
|||
})}
|
||||
{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>
|
||||
|
|
@ -170,7 +170,7 @@ export default function ComplainsDetails({ id }: { id: number }) {
|
|||
})}
|
||||
{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>
|
||||
|
|
@ -190,7 +190,7 @@ export default function ComplainsDetails({ id }: { id: number }) {
|
|||
})}
|
||||
{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>
|
||||
|
|
|
|||
|
|
@ -30,20 +30,27 @@ 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
|
||||
content: () => componentRef.current,
|
||||
// onBeforePrint() {
|
||||
// setPrintStyle(!printStyle);
|
||||
// },
|
||||
// onAfterPrint() {
|
||||
// setPrintStyle(!printStyle)
|
||||
// },
|
||||
});
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
setTrackingNumber(localStorage.getItem("trackingNumber2"));
|
||||
setPassword(localStorage.getItem("password2"));
|
||||
}, []);
|
||||
|
||||
|
||||
const complaintPrintMutation = useMutation({
|
||||
mutationKey: ["complaintPrint"],
|
||||
mutationFn: postComplaintTracking,
|
||||
|
|
@ -70,10 +77,7 @@ export default function FollowResult() {
|
|||
Data: { trackingNumber: trackingNumber, password: password },
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
const printableContent = 'This is the content to be printed.';
|
||||
|
||||
|
||||
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">
|
||||
|
|
@ -114,7 +118,7 @@ const printableContent = 'This is the content to be printed.';
|
|||
</AlertDialogCancel>
|
||||
</AlertDialogTitle>
|
||||
|
||||
<AlertDialogDescription className="h-full">
|
||||
<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
|
||||
|
|
@ -129,7 +133,9 @@ const printableContent = 'This is the content to be printed.';
|
|||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div dir="rtl" className=" font-[yekan]" id="details" ref={componentRef} >
|
||||
<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">
|
||||
{" "}
|
||||
موضوع شکایت:{" "}
|
||||
|
|
@ -164,8 +170,8 @@ const printableContent = 'This is the content to be printed.';
|
|||
)}
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
{/* <AlertDialogCancel>Cancel</AlertDialogCancel> */}
|
||||
<AlertDialogFooter>
|
||||
{/* <AlertDialogCancel>Cancel</AlertDialogCancel> */}
|
||||
<Button
|
||||
className="bg-blue text-white w-1/2 sm:w-1/6"
|
||||
onClick={handlePrint}
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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}>
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -133,9 +133,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 = [
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue