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

@ -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,7 +95,7 @@ export default function Landing() {
</SwiperSlide>
);
})}
{data?.length == 1 && (
{/* {data?.length == 1 && (
<SwiperSlide>
<Image
alt="bg"
@ -106,7 +107,7 @@ export default function Landing() {
className=" w-full h-full object-cover max-sm:object-[70%]"
/>
</SwiperSlide>
)}
)} */}
</>
) : (
<>

View File

@ -193,6 +193,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 <= 1024) {
setCharCount(newCharCount);
}
}
function onSubmit(data: z.infer<typeof FormSchema>) {
console.log(data);
const formData = new FormData();
@ -353,6 +361,16 @@ export default function RequestStep2() {
placeholder=" توضیحات خود را بنویسید"
className="mb-3 resize-none"
{...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>
<FormMessage />