diff --git a/components/ComplainsDetails.tsx b/components/ComplainsDetails.tsx index 2049d90..176cf1f 100644 --- a/components/ComplainsDetails.tsx +++ b/components/ComplainsDetails.tsx @@ -429,53 +429,61 @@ export default function ComplainsDetails({ className="flex flex-col mt-4 gap-y-4 overflow-y-auto scrollbar-thin scrollbar-thumb-gray-500 scrollbar-track-gray-100 " > - {data.contents?.map((item: any) => { + {data.contents?.map((item: any, index: any, array: any) => { return ( -
-
-

- - {item.operationWithDescription.description} توسط{" "} - {item.sender == 0 ? "شهروند" : "بازرس"} - -

-

- - {convertFullTime(item.dateTime)} + <> +

+
+ + {array.length - index} -

-
-

- {item.text ? item.text : "-"} -

- {item.media.length !== 0 && ( - - )} -
-
- {item?.media.map((item: any, index: number) => { - return ( -
- openFileInNewTab( - item.data, - item.mimeType, - item.title - ) - } - > - - -

- {item.title} -

-
- {/* +
+
+

+ + {item.operationWithDescription.description}{" "} + توسط {item.sender == 0 ? "شهروند" : "بازرس"} + +

+

+ + {convertFullTime(item.dateTime)} + +

+
+

+ {item.text ? item.text : "-"} +

+ {item.media.length !== 0 && ( + + )} +
+
+ {item?.media.map( + (item: any, index: number) => { + return ( +
+ openFileInNewTab( + item.data, + item.mimeType, + item.title + ) + } + > + + +

+ {item.title} +

+
+ {/* downloadFile( @@ -485,12 +493,15 @@ export default function ComplainsDetails({ ) } /> */} -
- ); - })} +
+ ); + } + )} +
+
-
+ ); })}
diff --git a/components/InspectorOperations.tsx b/components/InspectorOperations.tsx index 54c1dd2..8c00044 100644 --- a/components/InspectorOperations.tsx +++ b/components/InspectorOperations.tsx @@ -54,6 +54,7 @@ export default function InspectorOperations({ }) { const [file, setFile] = useState([]); const [check, setCheck] = useState(false); + const [charCount, setCharCount] = useState(0); // Queries const { data, isLoading, refetch } = useQuery({ @@ -131,6 +132,19 @@ export default function InspectorOperations({ }, }); + // Add the useEffect hook to monitor changes in the description field + useEffect(() => { + setCharCount(form.watch("text")?.length); + }, [form.watch("text")]); + + function handleTextChange(event: React.ChangeEvent) { + 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) { const storedData = JSON.parse( localStorage.getItem("CompliantData") as string @@ -188,13 +202,27 @@ export default function InspectorOperations({ name="text" render={({ field, fieldState: { error } }) => ( - متن + + متن({charCount}/{data?.maxTextLength}) +