Compare commits

..

5 Commits

Author SHA1 Message Date
Hossein Rahmani 074fa67d7a Code Cleaned 2024-08-03 14:26:51 +03:30
Hossein Rahmani dd0f39591b packages v updated 2024-07-21 13:07:54 +03:30
Hossein Rahmani a97d4ae1a9 a bug fixed 2024-07-21 13:06:31 +03:30
Hossein Rahmani 5ecf47e3d1 packages v updated 2024-07-20 17:40:21 +03:30
Hossein Rahmani 2abf0edf4c Other bugs of meeting fixed 2024-07-20 17:39:15 +03:30
11 changed files with 56 additions and 71 deletions

View File

@ -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
@ -208,13 +207,13 @@ export default function AdminCategories() {
description: data.description, description: data.description,
}); });
} }
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>

View File

@ -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";

View File

@ -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 ">

View File

@ -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 ">

View File

@ -10,9 +10,9 @@ export default function BoxDashboard({
}) { }) {
const boxIcons = { const boxIcons = {
"درخواست ناشناس": <EyeOff className=" mb-2 mx-auto" />, "گزارش ناشناس": <EyeOff className=" mb-2 mx-auto" />,
"درخواست شناس": <UserCheck className=" mb-2 mx-auto" />, "گزارش شناس": <UserCheck className=" mb-2 mx-auto" />,
درخواست: <ClipboardList className=" mb-2 mx-auto" />, گزارش: <ClipboardList className=" mb-2 mx-auto" />,
کاربر: <User className=" mb-2 mx-auto" />, کاربر: <User className=" mb-2 mx-auto" />,
}; };

View File

@ -54,7 +54,7 @@ export default function InspectorOperations({
}) { }) {
const [file, setFile] = useState<File[]>([]); const [file, setFile] = useState<File[]>([]);
const [check, setCheck] = useState<any>(false); const [check, setCheck] = useState<any>(false);
const [charCount, setCharCount] = useState(0); const [charCount, setCharCount] = useState<any>(0);
// Queries // Queries
const { data, isLoading, refetch } = useQuery({ const { data, isLoading, refetch } = useQuery({
@ -132,18 +132,21 @@ export default function InspectorOperations({
}, },
}); });
// Add the useEffect hook to monitor changes in the description field // Add the useEffect hook to monitor changes in the description field
useEffect(() => { useEffect(() => {
setCharCount(form.watch("text")?.length); const text = form.watch("text") as string;
}, [form.watch("text")]); if (charCount != 0) {
setCharCount(text?.length);
function handleTextChange(event: React.ChangeEvent<HTMLTextAreaElement>) {
const newCharCount = event.target.value.length;
// Update charCount only when the user types or removes characters
if (newCharCount <= data?.maxTextLength) {
setCharCount(newCharCount);
}
} }
}, [form.watch("text")]);
function handleTextChange(event: React.ChangeEvent<HTMLTextAreaElement>) {
const newCharCount = event.target.value.length;
// Update charCount only when the user types or removes characters
if (newCharCount <= data?.maxTextLength) {
setCharCount(newCharCount);
}
}
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
const storedData = JSON.parse( const storedData = JSON.parse(
@ -319,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);
}} }}

View File

@ -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 (

View File

@ -14,7 +14,7 @@ const TabsList = React.forwardRef<
<TabsPrimitive.List <TabsPrimitive.List
ref={ref} ref={ref}
className={cn( className={cn(
"inline-flex min-h-[3.5rem] items-center justify-start rounded-md bg-[#E9E9E9] p-2 text-muted-foreground", "inline-flex min-h-[3.1rem] items-center justify-start rounded-md bg-[#E9E9E9] p-2 text-muted-foreground",
className className
)} )}
{...props} {...props}

View File

@ -30,9 +30,7 @@ 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) => {
queryClient.invalidateQueries(["ComplaintsList"]); queryClient.invalidateQueries(["ComplaintsList"]);
@ -52,7 +50,7 @@ const useSignalR = () => {
startConnection(); startConnection();
} }
// console.log(connection.connectionId);
// return () => { // return () => {
// if (connection.state === "Connected") { // if (connection.state === "Connected") {

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "sootzani", "name": "sootzani",
"version": "0.2.20", "version": "0.2.23",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "sootzani", "name": "sootzani",
"version": "0.2.20", "version": "0.2.23",
"dependencies": { "dependencies": {
"@hookform/resolvers": "^3.3.2", "@hookform/resolvers": "^3.3.2",
"@microsoft/signalr": "^8.0.0", "@microsoft/signalr": "^8.0.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "sootzani", "name": "sootzani",
"version": "0.2.20", "version": "0.2.23",
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",