Merge branch 'Kahdooie' of https://gitea.shetabdahi.ir/Hossein-Rahmani/Sootzani-Inspector into Kahdooie
commit
4eba3d1c16
|
|
@ -0,0 +1,7 @@
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default function page() {
|
||||||
|
return (
|
||||||
|
<div>page</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -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 />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
export default function AdminCategories() {
|
||||||
|
return (
|
||||||
|
<div>AdminCategories</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,18 +31,179 @@ 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";
|
||||||
|
|
||||||
// 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<HTMLInputElement | null>(null);
|
||||||
|
const inputPrvRef = useRef<HTMLInputElement | 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);
|
||||||
|
|
||||||
|
// if (keyId) {
|
||||||
|
ChangeKeyMutation.mutate({
|
||||||
|
privateKey: selectedFile,
|
||||||
|
publicKeyId: keyId,
|
||||||
|
|
||||||
|
// publicKeyId: data1?.id,
|
||||||
|
});
|
||||||
|
// }
|
||||||
|
// else{
|
||||||
|
// console.error("keyId is undefined");
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
|
@ -64,177 +228,218 @@ export default function AdminKeysManagement() {
|
||||||
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 (inputPubRef.current && inputPrvRef.current) {
|
||||||
|
inputPubRef.current.value = data2?.publicKey ?? "";
|
||||||
|
inputPrvRef.current.value = data2?.privateKey ?? "";
|
||||||
|
}
|
||||||
|
}, [handleClickGenerate]);
|
||||||
|
|
||||||
|
|
||||||
|
const handleClickAddKey = () => {
|
||||||
|
// refetch2();
|
||||||
|
console.log(data1);
|
||||||
|
};
|
||||||
|
|
||||||
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 ">
|
||||||
{/* 1 */}
|
{/* 1 */}
|
||||||
<AlertDialog>
|
<AlertDialog open={openAdd} onOpenChange={setOpenAdd}>
|
||||||
<AlertDialogTrigger asChild>
|
<AlertDialogTrigger asChild>
|
||||||
<Button
|
<Button
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={handleClick}
|
onClick={handleClickAddKey}
|
||||||
disabled={isNewKeyLoading}
|
className="bg-orange-500 text-white"
|
||||||
>
|
// 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>
|
</Button>
|
||||||
</AlertDialogTrigger>
|
</AlertDialogTrigger>
|
||||||
<AlertDialogContent className=" w-full max-w-6xl h-full max-h-[80vh]">
|
<AlertDialogContent className=" w-full max-w-6xl h-full max-h-[90vh] lg:max-h-[70vh]">
|
||||||
<AlertDialogHeader>
|
<AlertDialogHeader>
|
||||||
<AlertDialogTitle>افزودن کلید جدید</AlertDialogTitle>
|
<AlertDialogTitle>
|
||||||
|
<p className="text-[#464646] text-base font-bold">
|
||||||
|
افزودن کلید جدید
|
||||||
|
</p>
|
||||||
|
<AlertDialogCancel className="p-0 border-0 h-auto">
|
||||||
|
<IoMdClose />
|
||||||
|
</AlertDialogCancel>
|
||||||
|
</AlertDialogTitle>
|
||||||
|
|
||||||
<AlertDialogDescription>
|
<AlertDialogDescription>
|
||||||
{isNewKeyLoading ? (
|
<div className="w-full ">
|
||||||
<div className="felx justify-center items-center self-center h-full">
|
<div className="w-full text-right text-neutral-600 text-lg font-bold mb-4">
|
||||||
<ThreeDots
|
ایجاد جفت کلید جدید
|
||||||
visible={true}
|
|
||||||
height="80"
|
|
||||||
width="100"
|
|
||||||
color="#003778"
|
|
||||||
radius="9"
|
|
||||||
ariaLabel="three-dots-loading"
|
|
||||||
wrapperStyle={{}}
|
|
||||||
wrapperClass=""
|
|
||||||
/>
|
|
||||||
</div>
|
</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
|
{isNewKeyLoading ? (
|
||||||
// control={form.control}
|
<div className="felx justify-center items-center self-center">
|
||||||
// name="password"
|
<ThreeDots
|
||||||
// render={({ field }) => (
|
visible={true}
|
||||||
// <FormItem className=" w-full lg:w-[48%]">
|
height="50"
|
||||||
// <FormLabel className="text-[#7C838A] text-sm font-medium ">
|
width="100"
|
||||||
// رمز عبور
|
color="#003778"
|
||||||
// </FormLabel>
|
radius="9"
|
||||||
// <FormControl>
|
ariaLabel="three-dots-loading"
|
||||||
// <Input
|
wrapperStyle={{}}
|
||||||
// placeholder="رمز عبور خود را وارد کنید"
|
wrapperClass=""
|
||||||
// {...field}
|
/>
|
||||||
// />
|
</div>
|
||||||
// </FormControl>
|
) : (
|
||||||
// <FormMessage />
|
<div>
|
||||||
// </FormItem>
|
<Button
|
||||||
// )}
|
variant="outline"
|
||||||
// />
|
onClick={handleClickGenerate}
|
||||||
// </div>
|
disabled={isNewKeyLoading}
|
||||||
|
className="my-2"
|
||||||
|
>
|
||||||
|
{" "}
|
||||||
|
ایجاد جفت کلید
|
||||||
|
</Button>
|
||||||
|
{isNewKeyLoading ? (
|
||||||
|
<div className="felx justify-center items-center self-center h-full">
|
||||||
|
<ThreeDots
|
||||||
|
visible={true}
|
||||||
|
height="20"
|
||||||
|
width="50"
|
||||||
|
color="#003778"
|
||||||
|
radius="9"
|
||||||
|
ariaLabel="three-dots-loading"
|
||||||
|
wrapperStyle={{}}
|
||||||
|
wrapperClass=""
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
className="flex flex-row flex-wrap justify-between"
|
||||||
|
id="KeyFetch"
|
||||||
|
>
|
||||||
|
<div className=" w-full lg:w-[48%]">
|
||||||
|
<p className="text-[#7C838A] text-sm font-semibold">
|
||||||
|
کلید عمومی :
|
||||||
|
</p>
|
||||||
|
{/* <p className="text-slate-700 text-sm text-left mb-4">
|
||||||
|
{data2?.publicKey}
|
||||||
|
</p> */}
|
||||||
|
<Input
|
||||||
|
name="pubKey"
|
||||||
|
ref={inputPubRef}
|
||||||
|
// value={data2?.publicKey}
|
||||||
|
readOnly={true}
|
||||||
|
className="text-slate-700 text-sm text-left mb-4 w-full bg-white"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className=" w-full lg:w-[48%]">
|
||||||
|
<p className="text-[#7C838A] text-sm font-semibold">
|
||||||
|
کلید خصوصی :
|
||||||
|
</p>
|
||||||
|
{/* <p className="text-slate-700 text-sm text-left mb-4">
|
||||||
|
{data2?.privateKey}
|
||||||
|
</p> */}
|
||||||
|
<Input
|
||||||
|
ref={inputPrvRef}
|
||||||
|
name="privKey"
|
||||||
|
// value={data2?.privateKey}
|
||||||
|
readOnly={true}
|
||||||
|
className="text-slate-700 text-sm text-left mb-4 w-full bg-white"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
// <div className="flex justify-center sm:justify-end gap-2 w-full mt-8">
|
<div className="w-full text-right text-neutral-600 text-lg font-bold mt-4 mb-2">
|
||||||
// <Button
|
افزودن کلید جدید
|
||||||
// // href="/FollowResult"
|
</div>
|
||||||
// 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"
|
<Form {...formAdd}>
|
||||||
// >
|
<form
|
||||||
// پیگیری درخواست
|
onSubmit={formAdd.handleSubmit(onSubmitAdd)}
|
||||||
// </Button>
|
className="w-full flex flex-col mt-6 "
|
||||||
// </div>
|
>
|
||||||
// </form>
|
<div className="flex flex-row flex-wrap justify-between">
|
||||||
// </Form>
|
<FormField
|
||||||
)}
|
control={formAdd.control}
|
||||||
|
name="title"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem className=" w-full lg:w-[48%]">
|
||||||
|
<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 lg:w-[48%]">
|
||||||
|
<FormLabel className="text-[#7C838A] text-sm font-medium ">
|
||||||
|
کلید عمومی
|
||||||
|
</FormLabel>
|
||||||
|
<FormControl>
|
||||||
|
<Input
|
||||||
|
placeholder="کلید عمومی را وارد کنید"
|
||||||
|
{...field}
|
||||||
|
className="bg-white"
|
||||||
|
/>
|
||||||
|
</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>
|
||||||
|
</div>
|
||||||
</AlertDialogDescription>
|
</AlertDialogDescription>
|
||||||
</AlertDialogHeader>
|
</AlertDialogHeader>
|
||||||
<AlertDialogFooter>
|
<AlertDialogFooter>
|
||||||
<AlertDialogCancel>بستن</AlertDialogCancel>
|
{/* <AlertDialogCancel>بستن</AlertDialogCancel> */}
|
||||||
{/* <AlertDialogAction>Continue</AlertDialogAction> */}
|
{/* <AlertDialogAction>Continue</AlertDialogAction> */}
|
||||||
</AlertDialogFooter>
|
</AlertDialogFooter>
|
||||||
</AlertDialogContent>
|
</AlertDialogContent>
|
||||||
</AlertDialog>
|
</AlertDialog>
|
||||||
|
|
||||||
|
{/* 2 */}
|
||||||
<div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
|
<div className="w-full text-right text-neutral-600 text-lg font-bold my-4">
|
||||||
لیست کلیدها
|
لیست کلیدها
|
||||||
</div>
|
</div>
|
||||||
{/* 2 */}
|
<div className="w-full flex flex-row flex-wrap justify-between gap-8 md:gap-4 ">
|
||||||
<div className="w-full flex flex-row max-md:flex-wrap justify-between gap-3">
|
|
||||||
{data1?.map((item: any) => {
|
{data1?.map((item: any) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={item.id}
|
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
|
className={`flex flex-col justify-center gap-2 w-full lg:w-[49%] h-28 px-5 rounded-md shadow-md items-start
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
<p className=" text-slate-500 text-sm font-normal leading-normal">
|
<p className=" text-slate-500 text-sm font-normal leading-normal">
|
||||||
|
|
@ -247,6 +452,100 @@ export default function AdminKeysManagement() {
|
||||||
{item.inspectorId}
|
{item.inspectorId}
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</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>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
|
||||||
|
|
@ -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 */}
|
||||||
|
|
|
||||||
|
|
@ -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 = [
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue