Merge branch 'Kahdooei' of https://gitea.shetabdahi.ir/Hossein-Rahmani/Sootzani into Kahdooei
commit
1f932149d9
|
|
@ -70,6 +70,7 @@ export default function Landing() {
|
|||
delay: 2500,
|
||||
disableOnInteraction: false,
|
||||
}}
|
||||
// autoplay={ data?.length > 1 ? { delay: 2500, disableOnInteraction: false } : false }
|
||||
loop={false}
|
||||
pagination={{
|
||||
clickable: true,
|
||||
|
|
@ -94,19 +95,6 @@ export default function Landing() {
|
|||
</SwiperSlide>
|
||||
);
|
||||
})}
|
||||
{data?.length == 1 && (
|
||||
<SwiperSlide>
|
||||
<Image
|
||||
alt="bg"
|
||||
src={`${process.env.NEXT_PUBLIC_BASE_URL_APP}${data[0]?.image?.url}`}
|
||||
// width={20}
|
||||
// height={20}
|
||||
layout="fill"
|
||||
quality={100}
|
||||
className=" w-full h-full object-cover max-sm:object-[70%]"
|
||||
/>
|
||||
</SwiperSlide>
|
||||
)}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
|
|
|
|||
|
|
@ -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<File[]>([]);
|
||||
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<HTMLTextAreaElement>) {
|
||||
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<typeof FormSchema>) {
|
||||
const formData = new FormData();
|
||||
|
|
@ -162,12 +176,26 @@ export default function InspectorOperations({
|
|||
name="text"
|
||||
render={({ field, fieldState: { error } }) => (
|
||||
<FormItem>
|
||||
<FormLabel className="">متن</FormLabel>
|
||||
<FormLabel className="">
|
||||
متن({charCount}/{data?.maxTextLength})
|
||||
</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea
|
||||
className="resize-none bg-white lg:min-h-[20em]"
|
||||
{...field}
|
||||
readOnly={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 ? (
|
||||
|
|
|
|||
|
|
@ -202,6 +202,14 @@ export default function RequestStep2() {
|
|||
setCharCount(form.watch("description").length);
|
||||
}, [form.watch("description")]);
|
||||
|
||||
function handleDescriptionChange(event: React.ChangeEvent<HTMLTextAreaElement>) {
|
||||
const newCharCount = event.target.value.length;
|
||||
// Update charCount only when the user types or removes characters
|
||||
if (newCharCount <= optionsData?.maxTextLength) {
|
||||
setCharCount(newCharCount);
|
||||
}
|
||||
}
|
||||
|
||||
function onSubmit(data: z.infer<typeof FormSchema>) {
|
||||
console.log(data);
|
||||
const formData = new FormData();
|
||||
|
|
|
|||
Loading…
Reference in New Issue