diff --git a/components/AdminCategories.tsx b/components/AdminCategories.tsx index b193abb..4099df1 100644 --- a/components/AdminCategories.tsx +++ b/components/AdminCategories.tsx @@ -68,7 +68,7 @@ const AddCatFormSchema = z.object({ export default function AdminCategories() { const router = useRouter(); - + // states const [keyId, setKeyId] = useState(""); const [keyIdDel, setKeyIdDel] = useState(""); const [titleCat, setTitleCat] = useState(""); @@ -88,7 +88,6 @@ export default function AdminCategories() { } = useQuery({ queryKey: ["CategoriesList"], queryFn: () => GetAllCategories(), - // refetchOnWindowFocus: false, }); // Edit @@ -208,13 +207,13 @@ export default function AdminCategories() { description: data.description, }); } - -const resetFormAdd = () => { - formAdd.reset({ - titleCategory: "", - description: "", - }); -}; + + const resetFormAdd = () => { + formAdd.reset({ + titleCategory: "", + description: "", + }); + }; return (
@@ -244,7 +243,12 @@ const resetFormAdd = () => {

افزودن دسته بندی

- { resetFormAdd(); }}> + { + resetFormAdd(); + }} + > @@ -309,7 +313,12 @@ const resetFormAdd = () => { > افزودن - { resetFormAdd(); }}> + { + resetFormAdd(); + }} + > بستن
diff --git a/components/AdminKeysManagement.tsx b/components/AdminKeysManagement.tsx index d290e78..c0fe557 100644 --- a/components/AdminKeysManagement.tsx +++ b/components/AdminKeysManagement.tsx @@ -50,23 +50,6 @@ const MAX_FILE_SIZE = 5242880; // 5 MB // Edit Key Form const FormSchemaEditKey = z.object({ uploadPrivateKey: z.any(), - // .instanceof(File) - - // .custom((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 @@ -92,7 +75,8 @@ export default function AdminKeysManagement() { const inputPubRef = useRef(null); const inputPrvRef = useRef(null); const intervalRef = useRef(null); - // ..............Read .txt + + const [selectedFile, setSelectedFile] = useState(null); const handleFileChange = (event: any) => { const file = event.target.files[0]; @@ -206,7 +190,7 @@ export default function AdminKeysManagement() { publicKey: data.publicKey, }); } - // const { resetField } = useForm(); + // List Keys const { @@ -218,7 +202,6 @@ export default function AdminKeysManagement() { } = useQuery({ queryKey: ["KeysList"], queryFn: () => GetKeys(), - // refetchOnWindowFocus: false, }); // GenerateKeyPair @@ -253,17 +236,6 @@ export default function AdminKeysManagement() { } }, [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 = () => { ChangeKeyMutation.mutate({ privateKey: "", @@ -284,6 +256,7 @@ export default function AdminKeysManagement() { }; } }, [polling]); + const saveTextFile = () => { const textToSave = data2?.privateKey ?? ""; const fileName = "privateKey.txt"; diff --git a/components/AdminNews.tsx b/components/AdminNews.tsx index ab4be3c..f5cb634 100644 --- a/components/AdminNews.tsx +++ b/components/AdminNews.tsx @@ -177,11 +177,13 @@ export default function AdminNews() { setImageNews(image); // Reset the form with new default values }; + useEffect(() => { if (keyId) { refetch2(); } }, [keyId]); + useEffect(() => { if (data2) { formEdit.reset({ @@ -192,6 +194,7 @@ export default function AdminNews() { }); } }, [data2]); + // Form Edit type EditNewsFormValues = z.infer; // This can come from your database or API. @@ -347,6 +350,7 @@ export default function AdminNews() { description: "", }); }; + return (
diff --git a/components/AdminOrganizations.tsx b/components/AdminOrganizations.tsx index 71ba0ad..a1fcffc 100644 --- a/components/AdminOrganizations.tsx +++ b/components/AdminOrganizations.tsx @@ -76,10 +76,8 @@ export default function AdminOrganizations() { const [keyIdDel, setKeyIdDel] = useState(""); const [titleOrg, setTitleOrg] = useState(""); const [descOrg, setDescOrg] = useState(""); - const [openAdd, setOpenAdd] = React.useState(false); const [openEdit, setOpenEdit] = React.useState(false); - const [delOrg, setDelOrg] = React.useState(false); // List Categories @@ -135,9 +133,8 @@ export default function AdminOrganizations() { defaultValues: defaultValuesAdd, mode: "onChange", }); - // Edit Submit + - // ............'Mutation' Change Key Submit const ChangeOrgMutation = useMutation({ mutationKey: ["ChangeOrg"], mutationFn: UpdateOrganization, @@ -205,6 +202,7 @@ export default function AdminOrganizations() { }, }); } + function onSubmitAdd(data: AddOrgFormValues) { AddOrgMutation.mutate({ title: data.titleOrg, @@ -218,6 +216,7 @@ export default function AdminOrganizations() { description: "", }); }; + return (
diff --git a/components/InspectorOperations.tsx b/components/InspectorOperations.tsx index a715131..8cde843 100644 --- a/components/InspectorOperations.tsx +++ b/components/InspectorOperations.tsx @@ -137,7 +137,6 @@ export default function InspectorOperations({ const text = form.watch("text") as string; if (charCount != 0) { setCharCount(text?.length); - console.log(charCount); } }, [form.watch("text")]); @@ -323,7 +322,6 @@ export default function InspectorOperations({ { - console.log(field.value); field.onChange(value); setCheck(false); }} diff --git a/components/TabController.tsx b/components/TabController.tsx index f70094d..c99e0c2 100644 --- a/components/TabController.tsx +++ b/components/TabController.tsx @@ -103,7 +103,7 @@ export default function TabController() { setCurrentPage(activePage); } }, []); - console.log(currentPage); + const isZero = totalCount === 0; return ( diff --git a/hooks/useSignalR.jsx b/hooks/useSignalR.jsx index 4e3cfb2..6a0d3d4 100644 --- a/hooks/useSignalR.jsx +++ b/hooks/useSignalR.jsx @@ -30,9 +30,7 @@ const useSignalR = () => { const startConnection = async () => { try { await connection.start(); - console.log("SignalR connected"); - console.log(connection.connectionId); - + postConnectionIdMutation.mutate(connection.connectionId); connection.on("Created", (message) => { queryClient.invalidateQueries(["ComplaintsList"]); @@ -52,7 +50,7 @@ const useSignalR = () => { startConnection(); } - // console.log(connection.connectionId); + // return () => { // if (connection.state === "Connected") {