a bug fixed

Kahdooie
YasamanKahdooei 2024-07-17 15:39:21 +03:30
parent bb86584422
commit 00cd74a9c5
2 changed files with 89 additions and 50 deletions

View File

@ -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 (
<div
key={item.id}
className="p-4 bg-white rounded-lg shadow-md "
>
<div className="flex items-center gap-4 justify-between">
<p className="">
<Badge>
{item.operationWithDescription.description} توسط{" "}
{item.sender == 0 ? "شهروند" : "بازرس"}
</Badge>
</p>
<p className="">
<span className="text-[#7C838A] text-sm">
{convertFullTime(item.dateTime)}
<>
<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>
</p>
</div>
<p className="text-[#7C838A] text-sm flex flex-wrap whitespace-normal break-all mt-2">
{item.text ? item.text : "-"}
</p>
{item.media.length !== 0 && (
<Separator className="mt-2 mb-1 " />
)}
<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">
{item?.media.map((item: any, index: number) => {
return (
<div
key={index}
className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center cursor-pointer"
onClick={() =>
openFileInNewTab(
item.data,
item.mimeType,
item.title
)
}
>
<a className="flex items-center gap-2 truncate cursor-pointer ">
<File className="w-6 h-6 " />
<p className=" max-w-full truncate">
{item.title}
</p>
</a>
{/* <ArrowDownToLine
</div>
<div
key={item.id}
className="p-4 bg-white rounded-lg shadow-md w-full relative"
>
<div className="flex items-center sm:gap-4 justify-between flex-col sm:flex-row gap-1">
<p className="">
<Badge>
{item.operationWithDescription.description}{" "}
توسط {item.sender == 0 ? "شهروند" : "بازرس"}
</Badge>
</p>
<p className="">
<span className="text-[#7C838A] text-sm">
{convertFullTime(item.dateTime)}
</span>
</p>
</div>
<p className="text-[#7C838A] text-sm flex flex-wrap whitespace-normal break-all mt-2">
{item.text ? item.text : "-"}
</p>
{item.media.length !== 0 && (
<Separator className="mt-2 mb-1 " />
)}
<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">
{item?.media.map(
(item: any, index: number) => {
return (
<div
key={index}
className=" bg-gray-100 text-[#7C838A] w-full md:w-[30%] rounded-md h-12 p-2 flex justify-between gap-3 items-center cursor-pointer"
onClick={() =>
openFileInNewTab(
item.data,
item.mimeType,
item.title
)
}
>
<a className="flex items-center gap-2 truncate cursor-pointer ">
<File className="w-6 h-6 " />
<p className=" max-w-full truncate">
{item.title}
</p>
</a>
{/* <ArrowDownToLine
className="cursor-pointer "
onClick={() =>
downloadFile(
@ -485,12 +493,15 @@ export default function ComplainsDetails({
)
}
/> */}
</div>
);
})}
</div>
);
}
)}
</div>
</div>
</div>
</div>
</div>
</>
);
})}
</div>

View File

@ -54,6 +54,7 @@ export default function InspectorOperations({
}) {
const [file, setFile] = useState<File[]>([]);
const [check, setCheck] = useState<any>(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<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>) {
const storedData = JSON.parse(
localStorage.getItem("CompliantData") as string
@ -188,13 +202,27 @@ export default function InspectorOperations({
name="text"
render={({ field, fieldState: { error } }) => (
<FormItem>
<FormLabel className="">متن</FormLabel>
<FormLabel className="">
متن({charCount}/{data?.maxTextLength})
</FormLabel>
<FormControl>
<Textarea
// placeholder="متن خود را وارد نمایید"
className="resize-none bg-white lg:min-h-[18em]"
{...field}
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>
{!error ? (