Files
front-AT/app/Components/SearchUser/searchUser.tsx
T

51 lines
1.2 KiB
TypeScript
Raw Normal View History

2025-09-02 19:50:17 -04:00
'use client'
2025-09-17 16:47:19 -06:00
import { useRouter } from "next/navigation";
2025-09-02 19:50:17 -04:00
import { useState } from "react";
2025-09-17 19:42:13 -06:00
interface urlProp{
urlBase:string
}
function SearchUser(url:urlProp) {
2025-09-17 16:47:19 -06:00
const [numAccount, setNumAccount] = useState("");
const router = useRouter();
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
2025-09-17 19:42:13 -06:00
2025-09-17 16:47:19 -06:00
if (numAccount) {
2025-09-17 19:42:13 -06:00
router.push(`/${url.urlBase}?numAccount=${numAccount}`);
2025-09-17 16:47:19 -06:00
}
};
return (
<>
<form className="containerForm"
onSubmit={handleSubmit}>
<label className="label">No.Cuenta</label>
<div className="groupInput">
<input
type="text"
value={numAccount}
onChange={(e) => {
const value = e.target.value;
if (/^\d*$/.test(value) && value.length <= 9) {
setNumAccount(value);
}
}}
placeholder="Coloca un número de cuenta..."
inputMode="numeric"
pattern="[0-9]*"
/>
<button className="button buttonSearch" type="submit">
Buscar
</button>
</div>
</form>
</>
);
2025-09-02 19:50:17 -04:00
}
2025-09-17 16:47:19 -06:00
export default SearchUser;