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

View File

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