2025-09-08 15:21:17 +01:00
|
|
|
import Card from "../UI/Card";
|
|
|
|
|
import CardHeader from "../UI/CardHeader";
|
|
|
|
|
import FormGroup from "../SettingForms/components/FormGroup";
|
2025-09-16 11:07:35 +01:00
|
|
|
import { useAlertHitContext } from "../../context/AlertHitContext";
|
|
|
|
|
import { useState } from "react";
|
2025-09-08 15:21:17 +01:00
|
|
|
|
|
|
|
|
const SessionCard = () => {
|
2025-09-16 11:07:35 +01:00
|
|
|
const [searchTerm, setSearchTerm] = useState("");
|
2025-09-16 14:20:38 +01:00
|
|
|
const { dispatch } = useAlertHitContext();
|
2025-09-08 15:21:17 +01:00
|
|
|
|
|
|
|
|
return (
|
2025-09-26 13:58:14 +01:00
|
|
|
<Card className="p-4">
|
2025-09-08 15:21:17 +01:00
|
|
|
<CardHeader title={"Hit Search"} />
|
2025-09-26 13:58:14 +01:00
|
|
|
<div className="flex flex-col gap-4 px-2">
|
2025-09-08 15:21:17 +01:00
|
|
|
<FormGroup>
|
2025-09-16 11:07:35 +01:00
|
|
|
<label
|
|
|
|
|
htmlFor="VRM"
|
|
|
|
|
className="font-medium whitespace-nowrap md:w-1/2 text-left"
|
|
|
|
|
>
|
|
|
|
|
VRM (Min 2 letters)
|
|
|
|
|
</label>
|
2025-09-08 15:21:17 +01:00
|
|
|
<div className="flex-1 flex justify-end md:w-2/3">
|
|
|
|
|
<input
|
|
|
|
|
id="VRMSelect"
|
|
|
|
|
name="VRMSelect"
|
|
|
|
|
type="text"
|
|
|
|
|
className="p-2 border border-gray-400 rounded-lg w-full max-w-xs"
|
|
|
|
|
placeholder="Enter VRM"
|
2025-09-16 14:20:38 +01:00
|
|
|
value={searchTerm}
|
2025-09-16 11:07:35 +01:00
|
|
|
onChange={(e) => setSearchTerm(e.target.value)}
|
2025-09-08 15:21:17 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</FormGroup>
|
|
|
|
|
<button
|
2025-09-23 16:02:14 +01:00
|
|
|
className="bg-[#26B170] text-white px-4 py-2 rounded hover:bg-green-700 transition w-full mx-auto"
|
2025-09-16 14:20:38 +01:00
|
|
|
onClick={() => dispatch({ type: "SEARCH", payload: searchTerm })}
|
|
|
|
|
disabled={searchTerm.trim().length < 2}
|
2025-09-08 15:21:17 +01:00
|
|
|
>
|
|
|
|
|
Search Hit list
|
|
|
|
|
</button>
|
2025-09-16 14:20:38 +01:00
|
|
|
{searchTerm && (
|
|
|
|
|
<button
|
2025-09-23 16:02:14 +01:00
|
|
|
className="bg-gray-300 text-gray-900 px-4 py-2 rounded hover:bg-gray-700 transition w-full mx-auto"
|
2025-09-16 14:20:38 +01:00
|
|
|
onClick={() => {
|
|
|
|
|
setSearchTerm("");
|
|
|
|
|
dispatch({ type: "SEARCH", payload: "" });
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Clear Search
|
|
|
|
|
</button>
|
|
|
|
|
)}
|
2025-09-08 15:21:17 +01:00
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default SessionCard;
|