a bug fixed
parent
bb86584422
commit
00cd74a9c5
|
|
@ -429,17 +429,24 @@ export default function ComplainsDetails({
|
||||||
className="flex flex-col mt-4 gap-y-4 overflow-y-auto
|
className="flex flex-col mt-4 gap-y-4 overflow-y-auto
|
||||||
scrollbar-thin scrollbar-thumb-gray-500 scrollbar-track-gray-100 "
|
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 (
|
return (
|
||||||
|
<>
|
||||||
|
<div className="flex flex-row gap-2 ">
|
||||||
|
<div className="flex">
|
||||||
|
<span className=" flex items-center justify-center w-7 h-7 mt-1 mr-1 bg-blue-100 rounded-md -start-4 ring-2 ring-blue bg-blue2 text-white bg-blue">
|
||||||
|
{array.length - index}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
key={item.id}
|
key={item.id}
|
||||||
className="p-4 bg-white rounded-lg shadow-md "
|
className="p-4 bg-white rounded-lg shadow-md w-full relative"
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-4 justify-between">
|
<div className="flex items-center sm:gap-4 justify-between flex-col sm:flex-row gap-1">
|
||||||
<p className="">
|
<p className="">
|
||||||
<Badge>
|
<Badge>
|
||||||
{item.operationWithDescription.description} توسط{" "}
|
{item.operationWithDescription.description}{" "}
|
||||||
{item.sender == 0 ? "شهروند" : "بازرس"}
|
توسط {item.sender == 0 ? "شهروند" : "بازرس"}
|
||||||
</Badge>
|
</Badge>
|
||||||
</p>
|
</p>
|
||||||
<p className="">
|
<p className="">
|
||||||
|
|
@ -456,7 +463,8 @@ export default function ComplainsDetails({
|
||||||
)}
|
)}
|
||||||
<div className=" text-[#464646] mt-2">
|
<div className=" text-[#464646] mt-2">
|
||||||
<div className="flex flex-wrap items-center w-full gap-2 mt-2 text-xs max-md:flex-col">
|
<div className="flex flex-wrap items-center w-full gap-2 mt-2 text-xs max-md:flex-col">
|
||||||
{item?.media.map((item: any, index: number) => {
|
{item?.media.map(
|
||||||
|
(item: any, index: number) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
|
|
@ -487,10 +495,13 @@ export default function ComplainsDetails({
|
||||||
/> */}
|
/> */}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
})}
|
}
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -54,6 +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);
|
||||||
|
|
||||||
// Queries
|
// Queries
|
||||||
const { data, isLoading, refetch } = useQuery({
|
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<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(
|
||||||
localStorage.getItem("CompliantData") as string
|
localStorage.getItem("CompliantData") as string
|
||||||
|
|
@ -188,13 +202,27 @@ export default function InspectorOperations({
|
||||||
name="text"
|
name="text"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field, fieldState: { error } }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel className="">متن</FormLabel>
|
<FormLabel className="">
|
||||||
|
متن({charCount}/{data?.maxTextLength})
|
||||||
|
</FormLabel>
|
||||||
<FormControl>
|
<FormControl>
|
||||||
<Textarea
|
<Textarea
|
||||||
// placeholder="متن خود را وارد نمایید"
|
// placeholder="متن خود را وارد نمایید"
|
||||||
className="resize-none bg-white lg:min-h-[18em]"
|
className="resize-none bg-white lg:min-h-[18em]"
|
||||||
{...field}
|
{...field}
|
||||||
disabled={possibleOperations.length == 0}
|
disabled={possibleOperations.length == 0}
|
||||||
|
onChange={(e) => {
|
||||||
|
const currentValue = e.target.value;
|
||||||
|
if (currentValue.length <= data?.maxTextLength) {
|
||||||
|
field.onChange(e);
|
||||||
|
handleTextChange(e);
|
||||||
|
} else {
|
||||||
|
// Truncate the value to the allowed limit
|
||||||
|
field.onChange(
|
||||||
|
currentValue.substring(0, data?.maxTextLength)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
{!error ? (
|
{!error ? (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue