diff --git a/app/CitizenLogin/page.tsx b/app/CitizenLogin/page.tsx
index f7d8040..f8de261 100644
--- a/app/CitizenLogin/page.tsx
+++ b/app/CitizenLogin/page.tsx
@@ -9,5 +9,11 @@ export default function page() {
if (token) {
redirect("/RequestStep2");
}
- return ;
+ return (
+
+ );
}
diff --git a/app/components/Landing.tsx b/app/components/Landing.tsx
index 6c9276b..acf9a55 100644
--- a/app/components/Landing.tsx
+++ b/app/components/Landing.tsx
@@ -95,19 +95,6 @@ export default function Landing() {
);
})}
- {/* {data?.length == 1 && (
-
-
-
- )} */}
>
) : (
<>
diff --git a/components/InspectorOperations.tsx b/components/InspectorOperations.tsx
index 1959a4c..6732555 100644
--- a/components/InspectorOperations.tsx
+++ b/components/InspectorOperations.tsx
@@ -33,7 +33,7 @@ import { useMutation, useQuery } from "@tanstack/react-query";
import { OperateByInspector } from "@/utils/inspectorApi";
import { toast } from "sonner";
import { postComplaintsDetails } from "@/utils/citizenApi";
-import { useState } from "react";
+import { useEffect, useState } from "react";
import { DialogTrigger } from "./ui/dialog";
import AttachmentsDialog from "./AttachmentsDialog";
import { Eye, Upload } from "lucide-react";
@@ -52,6 +52,7 @@ export default function InspectorOperations({
password?: string;
}) {
const [first, setfirst] = useState([]);
+ const [charCount, setCharCount] = useState(0);
// Queries
const { data, isLoading, refetch } = useQuery({
@@ -118,6 +119,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);
+ }
+ }
+
//Functions
function onSubmit(data: z.infer) {
const formData = new FormData();
@@ -162,12 +176,26 @@ export default function InspectorOperations({
name="text"
render={({ field, fieldState: { error } }) => (
- متن
+
+ متن({charCount}/{data?.maxTextLength})
+
{!error ? (
diff --git a/components/RequestStep2.tsx b/components/RequestStep2.tsx
index bae022d..f42c8df 100644
--- a/components/RequestStep2.tsx
+++ b/components/RequestStep2.tsx
@@ -87,7 +87,7 @@ export default function RequestStep2() {
.min(1, {
message: "لطفا توضیحات خود را بنویسید.",
})
- .max(1024, {
+ .max(optionsData?.maxTextLength, {
message: "تعداد کاراکترها بیشتر از حد مجاز میباشد.",
}),
uploadFile: z
@@ -196,7 +196,7 @@ export default function RequestStep2() {
function handleDescriptionChange(event: React.ChangeEvent) {
const newCharCount = event.target.value.length;
// Update charCount only when the user types or removes characters
- if (newCharCount <= 1024) {
+ if (newCharCount <= optionsData?.maxTextLength) {
setCharCount(newCharCount);
}
}
@@ -354,7 +354,7 @@ export default function RequestStep2() {
render={({ field }) => (
- توضیحات ({charCount}/1024)
+ توضیحات ({charCount}/{optionsData?.maxTextLength})