fix pagination bug
deploy to danak / build_and_deploy (push) Has been cancelled

This commit is contained in:
hamid zarghami
2026-07-22 16:11:27 +03:30
parent 76a68adc1c
commit b5b8344888
2 changed files with 13 additions and 9 deletions
+10 -8
View File
@@ -1,5 +1,5 @@
import { SearchNormal } from "iconsax-react";
import { FC, InputHTMLAttributes, useEffect, useState } from "react";
import { FC, InputHTMLAttributes, useEffect, useRef, useState } from "react";
import EyeIcon from "../assets/images/eye.svg";
import { clx } from "../helpers/utils";
import Error from "./Error";
@@ -30,6 +30,8 @@ const Input: FC<Props> = (props: Props) => {
const [showPassword, setShowPassword] = useState<boolean>(false);
const [search, setSearch] = useState<string>("");
const onChangeSearchFinalRef = useRef(props.onChangeSearchFinal);
onChangeSearchFinalRef.current = props.onChangeSearchFinal;
const inputClass = clx(
"w-full h-10 text-black block px-4 text-xs rounded-xl border border-border",
@@ -68,13 +70,13 @@ const Input: FC<Props> = (props: Props) => {
}, [props.value]);
useEffect(() => {
if (props.variant === "search" && props.onChangeSearchFinal) {
const timeout = setTimeout(() => {
props.onChangeSearchFinal?.(search);
}, 1000);
return () => clearTimeout(timeout);
}
}, [search, props]);
if (props.variant !== "search" || !onChangeSearchFinalRef.current) return;
const timeout = setTimeout(() => {
onChangeSearchFinalRef.current?.(search);
}, 1000);
return () => clearTimeout(timeout);
}, [search, props.variant]);
return (
<div className="w-full">
+3 -1
View File
@@ -19,7 +19,9 @@ const CustomerList: FC = () => {
const getCustomers = useGetCustomers(page, limit, false, search);
const handleSearch = (value: string) => {
setPage(1);
if (value !== search) {
setPage(1);
}
setSearch(value);
};