Skip to content

Commit 71010f7

Browse files
committed
Schedule added for sts
1 parent 1b71c87 commit 71010f7

File tree

1 file changed

+54
-10
lines changed
  • client/components/dashboard-componenets/mainContent/stsManagerContents

1 file changed

+54
-10
lines changed

client/components/dashboard-componenets/mainContent/stsManagerContents/Schedules.tsx

Lines changed: 54 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,72 @@ import RouteMap from "@/components/maps/RouteMap";
55
import STSVehicleList from "@/components/dataTables/StsVehicleList";
66
import GetStsCoordinateForRoute from "@/components/maps/getStsCoordinateForRoute";
77
import STSVehicleHistoryList from "@/components/dataTables/STSVehicleHistoryList";
8+
import { BillBySTSId } from "@/components/dataTables/BillBySTSId";
9+
import { getCookie } from "@/lib/cookieFunctions";
10+
import { stsId } from "@/data/cookieNames";
11+
import { useState } from "react";
12+
import {
13+
Select,
14+
SelectContent,
15+
SelectGroup,
16+
SelectItem,
17+
SelectLabel,
18+
SelectTrigger,
19+
SelectValue,
20+
} from "@/components/ui/select";
21+
import { Button } from "@/components/ui/button";
22+
import { CalendarSearchIcon } from "lucide-react";
23+
import useGetAllSTS from "@/hooks/dataQuery/useGetAllSTS";
24+
import { Calendar } from "@/components/ui/calendar";
25+
import {
26+
Popover,
27+
PopoverContent,
28+
PopoverTrigger,
29+
} from "@/components/ui/popover";
830

931
export default function STSManagerSchedules() {
32+
const [date, setDate] = useState<Date | undefined>(new Date());
33+
34+
function formatDate(dateString: string | undefined) {
35+
if (!dateString) return undefined;
36+
const date = new Date(dateString);
37+
const year = date.getFullYear();
38+
const month = ("0" + (date.getMonth() + 1)).slice(-2); // Months are 0 based, so +1 and pad with 0
39+
const day = ("0" + date.getDate()).slice(-2);
40+
41+
return `${year}-${month}-${day}`;
42+
}
1043
return (
1144
<main className="flex flex-1 flex-col gap-4 p-4 lg:gap-6 lg:p-6 max-h-[calc(100vh-60px)] overflow-scroll">
1245
<div className="flex flex-1 items-center justify-center rounded-lg border border-dashed shadow-sm">
1346
<div className="grid grid-cols-1 lg:grid-cols-10 grid-flow-row gap-2 lg:gap-4 w-full lg:h-full max-h-max">
14-
{/* <div className="col-span-1 row-span-1 min-h-48">
15-
<EmptyFillContainer>DISPATCH HISTORY</EmptyFillContainer>
16-
</div> */}
1747
<div className="col-span-1 lg:row-span-2 lg:col-span-4 min-h-[500px]">
1848
<EmptyFillContainer>
1949
<GetStsCoordinateForRoute />
2050
</EmptyFillContainer>
2151
</div>
22-
<div className="lg:col-span-6 min-h-48">
23-
<EmptyFillContainer>
24-
<STSVehicleList />
25-
</EmptyFillContainer>
26-
</div>
27-
<div className="lg:col-span-6 min-h-48">
52+
<div className="lg:col-span-6 lg:row-span-2 min-h-48">
53+
<div className="flex justify-center gap-4 items-center mb-5 flex-wrap content-center">
54+
SELECT DATE OF SCHEDULE :
55+
<Popover>
56+
<PopoverTrigger asChild>
57+
<Button variant={"outline"} className="flex gap-2">
58+
<CalendarSearchIcon />{" "}
59+
{formatDate(date?.toDateString()) || "Select a Date"}
60+
</Button>
61+
</PopoverTrigger>
62+
<PopoverContent className="w-auto p-0" align="start">
63+
<Calendar
64+
mode="single"
65+
selected={date}
66+
onSelect={setDate}
67+
className="rounded-md border"
68+
/>
69+
</PopoverContent>
70+
</Popover>
71+
</div>
2872
<EmptyFillContainer>
29-
<STSVehicleHistoryList />
73+
<BillBySTSId stsId={getCookie(stsId)} date={formatDate(date?.toDateString()) || ""} />
3074
</EmptyFillContainer>
3175
</div>
3276
</div>

0 commit comments

Comments
 (0)