Code Cleaned
parent
dd0f39591b
commit
074fa67d7a
|
|
@ -68,7 +68,7 @@ const AddCatFormSchema = z.object({
|
||||||
|
|
||||||
export default function AdminCategories() {
|
export default function AdminCategories() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
// states
|
||||||
const [keyId, setKeyId] = useState("");
|
const [keyId, setKeyId] = useState("");
|
||||||
const [keyIdDel, setKeyIdDel] = useState("");
|
const [keyIdDel, setKeyIdDel] = useState("");
|
||||||
const [titleCat, setTitleCat] = useState("");
|
const [titleCat, setTitleCat] = useState("");
|
||||||
|
|
@ -88,7 +88,6 @@ export default function AdminCategories() {
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["CategoriesList"],
|
queryKey: ["CategoriesList"],
|
||||||
queryFn: () => GetAllCategories(),
|
queryFn: () => GetAllCategories(),
|
||||||
// refetchOnWindowFocus: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Edit
|
// Edit
|
||||||
|
|
@ -209,12 +208,12 @@ export default function AdminCategories() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const resetFormAdd = () => {
|
const resetFormAdd = () => {
|
||||||
formAdd.reset({
|
formAdd.reset({
|
||||||
titleCategory: "",
|
titleCategory: "",
|
||||||
description: "",
|
description: "",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-[85vh] flex justify-center">
|
<div className="w-full min-h-[85vh] flex justify-center">
|
||||||
|
|
@ -244,7 +243,12 @@ const resetFormAdd = () => {
|
||||||
<p className="text-[#464646] text-base font-bold">
|
<p className="text-[#464646] text-base font-bold">
|
||||||
افزودن دسته بندی
|
افزودن دسته بندی
|
||||||
</p>
|
</p>
|
||||||
<AlertDialogCancel className="h-auto p-0 border-0" onClick={() => { resetFormAdd(); }}>
|
<AlertDialogCancel
|
||||||
|
className="h-auto p-0 border-0"
|
||||||
|
onClick={() => {
|
||||||
|
resetFormAdd();
|
||||||
|
}}
|
||||||
|
>
|
||||||
<IoMdClose />
|
<IoMdClose />
|
||||||
</AlertDialogCancel>
|
</AlertDialogCancel>
|
||||||
</AlertDialogTitle>
|
</AlertDialogTitle>
|
||||||
|
|
@ -309,7 +313,12 @@ const resetFormAdd = () => {
|
||||||
>
|
>
|
||||||
افزودن
|
افزودن
|
||||||
</Button>
|
</Button>
|
||||||
<AlertDialogCancel className="mt-0 text-white bg-blue rounded-xl" onClick={() => { resetFormAdd(); }}>
|
<AlertDialogCancel
|
||||||
|
className="mt-0 text-white bg-blue rounded-xl"
|
||||||
|
onClick={() => {
|
||||||
|
resetFormAdd();
|
||||||
|
}}
|
||||||
|
>
|
||||||
بستن
|
بستن
|
||||||
</AlertDialogCancel>
|
</AlertDialogCancel>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -50,23 +50,6 @@ const MAX_FILE_SIZE = 5242880; // 5 MB
|
||||||
// Edit Key Form
|
// Edit Key Form
|
||||||
const FormSchemaEditKey = z.object({
|
const FormSchemaEditKey = z.object({
|
||||||
uploadPrivateKey: z.any(),
|
uploadPrivateKey: z.any(),
|
||||||
// .instanceof(File)
|
|
||||||
|
|
||||||
// .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
|
// Add Key Form
|
||||||
|
|
@ -92,7 +75,8 @@ export default function AdminKeysManagement() {
|
||||||
const inputPubRef = useRef<HTMLTextAreaElement | null>(null);
|
const inputPubRef = useRef<HTMLTextAreaElement | null>(null);
|
||||||
const inputPrvRef = useRef<HTMLTextAreaElement | null>(null);
|
const inputPrvRef = useRef<HTMLTextAreaElement | null>(null);
|
||||||
const intervalRef = useRef<NodeJS.Timeout | null>(null);
|
const intervalRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
// ..............Read .txt
|
|
||||||
|
|
||||||
const [selectedFile, setSelectedFile] = useState<any>(null);
|
const [selectedFile, setSelectedFile] = useState<any>(null);
|
||||||
const handleFileChange = (event: any) => {
|
const handleFileChange = (event: any) => {
|
||||||
const file = event.target.files[0];
|
const file = event.target.files[0];
|
||||||
|
|
@ -206,7 +190,7 @@ export default function AdminKeysManagement() {
|
||||||
publicKey: data.publicKey,
|
publicKey: data.publicKey,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// const { resetField } = useForm();
|
|
||||||
|
|
||||||
// List Keys
|
// List Keys
|
||||||
const {
|
const {
|
||||||
|
|
@ -218,7 +202,6 @@ export default function AdminKeysManagement() {
|
||||||
} = useQuery({
|
} = useQuery({
|
||||||
queryKey: ["KeysList"],
|
queryKey: ["KeysList"],
|
||||||
queryFn: () => GetKeys(),
|
queryFn: () => GetKeys(),
|
||||||
// refetchOnWindowFocus: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// GenerateKeyPair
|
// GenerateKeyPair
|
||||||
|
|
@ -253,17 +236,6 @@ export default function AdminKeysManagement() {
|
||||||
}
|
}
|
||||||
}, [handleClickGenerate]);
|
}, [handleClickGenerate]);
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// const isChangingKey = localStorage.getItem("isChangingKey");
|
|
||||||
// if (isChangingKey) {
|
|
||||||
// setPolling(true);
|
|
||||||
// ChangeKeyMutation.mutate({
|
|
||||||
// privateKey: "",
|
|
||||||
// publicKeyId: "cb7258da-64b0-4f43-b4f7-8ee11799d643",
|
|
||||||
// isPolling: true,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// }, [polling]);
|
|
||||||
const refethKey = () => {
|
const refethKey = () => {
|
||||||
ChangeKeyMutation.mutate({
|
ChangeKeyMutation.mutate({
|
||||||
privateKey: "",
|
privateKey: "",
|
||||||
|
|
@ -284,6 +256,7 @@ export default function AdminKeysManagement() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}, [polling]);
|
}, [polling]);
|
||||||
|
|
||||||
const saveTextFile = () => {
|
const saveTextFile = () => {
|
||||||
const textToSave = data2?.privateKey ?? "";
|
const textToSave = data2?.privateKey ?? "";
|
||||||
const fileName = "privateKey.txt";
|
const fileName = "privateKey.txt";
|
||||||
|
|
|
||||||
|
|
@ -177,11 +177,13 @@ export default function AdminNews() {
|
||||||
setImageNews(image);
|
setImageNews(image);
|
||||||
// Reset the form with new default values
|
// Reset the form with new default values
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (keyId) {
|
if (keyId) {
|
||||||
refetch2();
|
refetch2();
|
||||||
}
|
}
|
||||||
}, [keyId]);
|
}, [keyId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data2) {
|
if (data2) {
|
||||||
formEdit.reset({
|
formEdit.reset({
|
||||||
|
|
@ -192,6 +194,7 @@ export default function AdminNews() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [data2]);
|
}, [data2]);
|
||||||
|
|
||||||
// Form Edit
|
// Form Edit
|
||||||
type EditNewsFormValues = z.infer<typeof EditNewsFormSchema>;
|
type EditNewsFormValues = z.infer<typeof EditNewsFormSchema>;
|
||||||
// This can come from your database or API.
|
// This can come from your database or API.
|
||||||
|
|
@ -347,6 +350,7 @@ export default function AdminNews() {
|
||||||
description: "",
|
description: "",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-[85vh] flex justify-center max-lg:pb-20">
|
<div className="w-full min-h-[85vh] flex justify-center max-lg:pb-20">
|
||||||
<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 ">
|
||||||
|
|
|
||||||
|
|
@ -76,10 +76,8 @@ export default function AdminOrganizations() {
|
||||||
const [keyIdDel, setKeyIdDel] = useState("");
|
const [keyIdDel, setKeyIdDel] = useState("");
|
||||||
const [titleOrg, setTitleOrg] = useState("");
|
const [titleOrg, setTitleOrg] = useState("");
|
||||||
const [descOrg, setDescOrg] = useState("");
|
const [descOrg, setDescOrg] = useState("");
|
||||||
|
|
||||||
const [openAdd, setOpenAdd] = React.useState(false);
|
const [openAdd, setOpenAdd] = React.useState(false);
|
||||||
const [openEdit, setOpenEdit] = React.useState(false);
|
const [openEdit, setOpenEdit] = React.useState(false);
|
||||||
|
|
||||||
const [delOrg, setDelOrg] = React.useState(false);
|
const [delOrg, setDelOrg] = React.useState(false);
|
||||||
|
|
||||||
// List Categories
|
// List Categories
|
||||||
|
|
@ -135,9 +133,8 @@ export default function AdminOrganizations() {
|
||||||
defaultValues: defaultValuesAdd,
|
defaultValues: defaultValuesAdd,
|
||||||
mode: "onChange",
|
mode: "onChange",
|
||||||
});
|
});
|
||||||
// Edit Submit
|
|
||||||
|
|
||||||
// ............'Mutation' Change Key Submit
|
|
||||||
const ChangeOrgMutation = useMutation({
|
const ChangeOrgMutation = useMutation({
|
||||||
mutationKey: ["ChangeOrg"],
|
mutationKey: ["ChangeOrg"],
|
||||||
mutationFn: UpdateOrganization,
|
mutationFn: UpdateOrganization,
|
||||||
|
|
@ -205,6 +202,7 @@ export default function AdminOrganizations() {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSubmitAdd(data: AddOrgFormValues) {
|
function onSubmitAdd(data: AddOrgFormValues) {
|
||||||
AddOrgMutation.mutate({
|
AddOrgMutation.mutate({
|
||||||
title: data.titleOrg,
|
title: data.titleOrg,
|
||||||
|
|
@ -218,6 +216,7 @@ export default function AdminOrganizations() {
|
||||||
description: "",
|
description: "",
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full min-h-[85vh] 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 ">
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,6 @@ export default function InspectorOperations({
|
||||||
const text = form.watch("text") as string;
|
const text = form.watch("text") as string;
|
||||||
if (charCount != 0) {
|
if (charCount != 0) {
|
||||||
setCharCount(text?.length);
|
setCharCount(text?.length);
|
||||||
console.log(charCount);
|
|
||||||
}
|
}
|
||||||
}, [form.watch("text")]);
|
}, [form.watch("text")]);
|
||||||
|
|
||||||
|
|
@ -323,7 +322,6 @@ export default function InspectorOperations({
|
||||||
<FormControl dir="rtl">
|
<FormControl dir="rtl">
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
onValueChange={(value) => {
|
onValueChange={(value) => {
|
||||||
console.log(field.value);
|
|
||||||
field.onChange(value);
|
field.onChange(value);
|
||||||
setCheck(false);
|
setCheck(false);
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ export default function TabController() {
|
||||||
setCurrentPage(activePage);
|
setCurrentPage(activePage);
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
console.log(currentPage);
|
|
||||||
const isZero = totalCount === 0;
|
const isZero = totalCount === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,6 @@ const useSignalR = () => {
|
||||||
const startConnection = async () => {
|
const startConnection = async () => {
|
||||||
try {
|
try {
|
||||||
await connection.start();
|
await connection.start();
|
||||||
console.log("SignalR connected");
|
|
||||||
console.log(connection.connectionId);
|
|
||||||
|
|
||||||
postConnectionIdMutation.mutate(connection.connectionId);
|
postConnectionIdMutation.mutate(connection.connectionId);
|
||||||
connection.on("Created", (message) => {
|
connection.on("Created", (message) => {
|
||||||
|
|
@ -52,7 +50,7 @@ const useSignalR = () => {
|
||||||
startConnection();
|
startConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log(connection.connectionId);
|
|
||||||
|
|
||||||
// return () => {
|
// return () => {
|
||||||
// if (connection.state === "Connected") {
|
// if (connection.state === "Connected") {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue