The Counter and Slider problem has been solved

Kahdooei
yasaman 2024-02-19 11:10:45 +03:30
parent bb50eabb35
commit eb3f3a3f99
2 changed files with 23 additions and 4 deletions

View File

@ -47,7 +47,7 @@ export default function Landing() {
queryFn: () => getSliders(), queryFn: () => getSliders(),
refetchOnWindowFocus: false, refetchOnWindowFocus: false,
}); });
const { const {
data: NewsData, data: NewsData,
isLoading: NewsIsLoading, isLoading: NewsIsLoading,
@ -70,7 +70,8 @@ export default function Landing() {
delay: 2500, delay: 2500,
disableOnInteraction: false, disableOnInteraction: false,
}} }}
loop={false} // autoplay={ data?.length > 1 ? { delay: 2500, disableOnInteraction: false } : false }
loop={false}
pagination={{ pagination={{
clickable: true, clickable: true,
}} }}
@ -94,7 +95,7 @@ export default function Landing() {
</SwiperSlide> </SwiperSlide>
); );
})} })}
{data?.length == 1 && ( {/* {data?.length == 1 && (
<SwiperSlide> <SwiperSlide>
<Image <Image
alt="bg" alt="bg"
@ -106,7 +107,7 @@ export default function Landing() {
className=" w-full h-full object-cover max-sm:object-[70%]" className=" w-full h-full object-cover max-sm:object-[70%]"
/> />
</SwiperSlide> </SwiperSlide>
)} )} */}
</> </>
) : ( ) : (
<> <>

View File

@ -193,6 +193,14 @@ export default function RequestStep2() {
setCharCount(form.watch("description").length); setCharCount(form.watch("description").length);
}, [form.watch("description")]); }, [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 <= 1024) {
setCharCount(newCharCount);
}
}
function onSubmit(data: z.infer<typeof FormSchema>) { function onSubmit(data: z.infer<typeof FormSchema>) {
console.log(data); console.log(data);
const formData = new FormData(); const formData = new FormData();
@ -353,6 +361,16 @@ export default function RequestStep2() {
placeholder=" توضیحات خود را بنویسید" placeholder=" توضیحات خود را بنویسید"
className="mb-3 resize-none" className="mb-3 resize-none"
{...field} {...field}
onChange={(e) => {
const currentValue = e.target.value;
if (currentValue.length <= 1024) {
field.onChange(e);
handleDescriptionChange(e);
} else {
// Truncate the value to the allowed limit
field.onChange(currentValue.substring(0, 1024));
}
}}
/> />
</FormControl> </FormControl>
<FormMessage /> <FormMessage />