Skip to content

datepicker added in landfill entry and sts release #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions client/components/modals/LandFillVehicleEntryModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ import useVehicleReleaseFromSTS from "@/hooks/StsDashboard/useVehicleReleaseFrom
import useUpcomingVehicle from "@/hooks/landFillDashboard/useUpcomingVehiclesList";
import useTripComplete from "@/hooks/landFillDashboard/useTripComplete";

import DatePicker from "react-datepicker";

import "react-datepicker/dist/react-datepicker.css";


type Vehicle = {
tripId: string,
Expand All @@ -61,6 +65,11 @@ export const LandfillVehicleEntryModal = ({ vehicleInfo }: { vehicleInfo: Vehicl
const { TripComplete } = useTripComplete();


const [selectedDateTime, setSelectedDateTime] = useState<Date>(new Date());

const handleDateChange = (date: Date) => {
setSelectedDateTime(date);
};


const handleSaveChanges = async () => {
Expand All @@ -69,7 +78,7 @@ export const LandfillVehicleEntryModal = ({ vehicleInfo }: { vehicleInfo: Vehicl
const postEntry = await TripComplete({
tripId: vehicleInfo.tripId,
weightOfWaste: weightOfWaste,
entryTime: entryTime,
entryTime: selectedDateTime.toISOString()//entryTime,
});

} catch (error) {
Expand Down Expand Up @@ -141,13 +150,24 @@ export const LandfillVehicleEntryModal = ({ vehicleInfo }: { vehicleInfo: Vehicl
<Label htmlFor="capacity" className="text-right">
LandFill Entry Time
</Label>
<Input
{/* <Input
id="capacity"
placeholder="1-100"
className="col-span-3"
value={entryTime}
onChange={(e) => setEntryTime(e.target.value)}
/>
/> */}
<div className="flex flex-col">
{/* Other component content */}
<DatePicker
selected={selectedDateTime}
onChange={handleDateChange}
showTimeSelect
timeFormat="hh:mm aa"
dateFormat="dd/MM/yy hh:mm aa" // Set desired date format
locale="en-GB"
/>
</div>
</div>
</div>
<DialogFooter>
Expand Down
44 changes: 22 additions & 22 deletions client/components/modals/STSVehicleReleaseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ import editSTS from "@/hooks/entityCreation/editSTS";
import getUserByRole from "@/hooks/user_data/getUserByRole";
import VehicleRelaseRoute from "../maps/VehicleReleaseRoute";
import useVehicleReleaseFromSTS from "@/hooks/StsDashboard/useVehicleReleaseFromSTS";
import DatePicker from "react-datepicker";

import "react-datepicker/dist/react-datepicker.css";

type Vehicle = {
entryId: string,
Expand Down Expand Up @@ -60,25 +62,12 @@ export const STSVehicleRelease = ({ vehicleInfo }: { vehicleInfo: Vehicle }) =>
const [distance, setDistance] = useState<string>("");
const [duration, setDuration] = useState<string>("");const { VehicleReleaseFromSTS } = useVehicleReleaseFromSTS();



// const dummyCoordinates[
// 23.76652752, 90.4258899
// 23.76449486, 90.3879528
// 23.73897468, 90.3750954
// 23.76431111, 90.3651622
// 23.77393625, 90.3814204
// 23.76461481, 90.3915441
// 23.77089053, 90.4042765
// 23.72965447, 90.3873709
// ]
// {
// "stsVehicleId": "sv1",
// "weightOfWaste" : 2,
// "exitTime" : "2024-03-27T08:00:00Z",
// "distance": "156.3",
// "estimatedDuration": "23"
// }
const [selectedDateTime, setSelectedDateTime] = useState<Date>(new Date());

const handleDateChange = (date: Date) => {
setSelectedDateTime(date);
};



const handleSaveChanges = async () => {
Expand All @@ -87,7 +76,7 @@ export const STSVehicleRelease = ({ vehicleInfo }: { vehicleInfo: Vehicle }) =>
const postEntry = await VehicleReleaseFromSTS({
stsVehicleId: vehicleInfo.entryId,
weightOfWaste: weightOfWaste,
exitTime: exitTime,
exitTime: selectedDateTime.toISOString(),
distance: distance,
estimatedDuration: duration
});
Expand Down Expand Up @@ -165,13 +154,24 @@ export const STSVehicleRelease = ({ vehicleInfo }: { vehicleInfo: Vehicle }) =>
<Label htmlFor="capacity" className="text-right">
Deparature Time
</Label>
<Input
{/* <Input
id="capacity"
placeholder="1-100"
className="col-span-3"
value={exitTime}
onChange={(e) => setExitTime(e.target.value)}
/>
/> */}
<div className="flex flex-col">
{/* Other component content */}
<DatePicker
selected={selectedDateTime}
onChange={handleDateChange}
showTimeSelect
timeFormat="hh:mm aa"
dateFormat="dd/MM/yy hh:mm aa" // Set desired date format
locale="en-GB"
/>
</div>
</div>
</div>
<DialogFooter>
Expand Down