2026-01-16 15:47:16 -06:00
|
|
|
"use client";
|
2025-09-26 16:56:07 -06:00
|
|
|
|
2026-01-16 15:47:16 -06:00
|
|
|
import { useState } from "react";
|
2025-09-05 16:03:07 -06:00
|
|
|
|
2026-01-16 15:47:16 -06:00
|
|
|
import "./SearchDate.css";
|
2026-01-14 14:53:36 -06:00
|
|
|
interface Props {
|
|
|
|
|
onSearch: (desde: string, hasta: string) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function SearchDateBetween({ onSearch }: Props) {
|
2026-01-16 15:47:16 -06:00
|
|
|
const [startDate, setStartDate] = useState("");
|
2026-02-16 19:04:18 -06:00
|
|
|
const todayISO = new Date().toLocaleDateString("en-CA");
|
|
|
|
|
const [endDate, setEndDate] = useState(todayISO);
|
2025-09-05 16:03:07 -06:00
|
|
|
|
2025-10-01 15:29:23 -06:00
|
|
|
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
2025-09-05 16:03:07 -06:00
|
|
|
e.preventDefault();
|
2026-01-14 14:53:36 -06:00
|
|
|
if (!startDate || !endDate) return;
|
|
|
|
|
onSearch(startDate, endDate);
|
2025-09-05 16:03:07 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2026-01-16 15:47:16 -06:00
|
|
|
<form className="containerForm containerDate" onSubmit={handleSubmit}>
|
|
|
|
|
<div className="alingDate">
|
|
|
|
|
<div className="">
|
|
|
|
|
<label className="label">Desde</label>
|
|
|
|
|
<div className="groupInput">
|
|
|
|
|
<input
|
|
|
|
|
type="date"
|
|
|
|
|
value={startDate}
|
|
|
|
|
onChange={(e) => setStartDate(e.target.value)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div>
|
|
|
|
|
<label className="label">Hasta</label>
|
|
|
|
|
|
|
|
|
|
<div className="groupInput">
|
|
|
|
|
<input
|
|
|
|
|
type="date"
|
|
|
|
|
value={endDate}
|
|
|
|
|
onChange={(e) => setEndDate(e.target.value)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-01-14 14:53:36 -06:00
|
|
|
</div>
|
|
|
|
|
|
2026-01-16 15:47:16 -06:00
|
|
|
<button
|
|
|
|
|
className="button buttonSearch"
|
|
|
|
|
type="submit"
|
|
|
|
|
style={{ marginBottom: "10px" }}
|
|
|
|
|
>
|
2026-01-14 14:53:36 -06:00
|
|
|
Buscar
|
|
|
|
|
</button>
|
|
|
|
|
</form>
|
2025-09-05 16:03:07 -06:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default SearchDateBetween;
|