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

58 lines
1.3 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-22 11:57:52 -06:00
import { useEffect, useState } from "react";
2025-09-17 19:42:13 -06:00
interface urlProp{
urlBase:string
2025-09-22 11:57:52 -06:00
value:string|null
2025-09-17 19:42:13 -06:00
}
2025-09-22 11:57:52 -06:00
function SearchUser(props:urlProp) {
2025-09-22 12:15:32 -04:00
const [numAcount, setnumAcount] = useState("");
2025-09-17 16:47:19 -06:00
const router = useRouter();
2025-09-22 11:57:52 -06:00
useEffect(() => {
if (props.value) {
setnumAcount(props.value);
}
}, [props.value]);
2025-09-17 16:47:19 -06:00
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
2025-09-17 19:42:13 -06:00
2025-09-22 12:15:32 -04:00
if (numAcount) {
2025-09-22 11:57:52 -06:00
router.push(`/${props.urlBase}?numAcount=${numAcount}`);
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"
2025-09-22 12:15:32 -04:00
value={numAcount}
2025-09-17 16:47:19 -06:00
onChange={(e) => {
const value = e.target.value;
if (/^\d*$/.test(value) && value.length <= 9) {
2025-09-22 12:15:32 -04:00
setnumAcount(value);
2025-09-17 16:47:19 -06:00
}
}}
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;