Skip to content

Commit

Permalink
fix show durations in bookingdrawer
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilkka Korhonen authored and Ilkka Korhonen committed Jun 26, 2024
1 parent fa3828c commit 9da87b8
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "",
"main": "src/app.ts",
"engines": {
"node": ">=20.14.0"
"node": ">=20.12.2"
},
"scripts": {
"test": "jest",
Expand Down
10 changes: 9 additions & 1 deletion frontend/src/components/AvailableRoomList/AvailableRoomList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import RoomCard from '../RoomCard/RoomCard';
import NoRoomsCard from '../RoomCard/NoRoomsCard';
import BookingDrawer from '../BookingDrawer/BookingDrawer';
import TimePickerDrawer from '../TimePickerDrawer/TimePickerDrawer';

const SKIP_CONFIRMATION = true;

const TimePickerButton = styled(ToggleButton)(() => ({
Expand Down Expand Up @@ -81,6 +82,8 @@ type BookingListProps = {
setPreferences: (pref: Preferences) => void;
startingTime: string;
setStartingTime: (newStartingTime: string) => void;
setBookingDuration: (minutes: number) => void;
setDuration: React.Dispatch<React.SetStateAction<number>>;
};

const AvailableRoomList = (props: BookingListProps) => {
Expand All @@ -94,7 +97,9 @@ const AvailableRoomList = (props: BookingListProps) => {
preferences,
setPreferences,
startingTime,
setStartingTime
setStartingTime,
setBookingDuration,
setDuration
} = props;
const { createSuccessNotification, createErrorNotification } =
useCreateNotification();
Expand Down Expand Up @@ -279,6 +284,9 @@ const AvailableRoomList = (props: BookingListProps) => {
onAddTimeUntilFull={handleUntilFull}
onAddTimeUntilNext={handleUntilNextDurationChange}
startingTime={startingTime}
bookingDuration={bookingDuration}
setBookingDuration={setBookingDuration}
setDuration={setDuration}
/>
<TimePickerDrawer
open={expandTimePickerDrawer}
Expand Down
21 changes: 20 additions & 1 deletion frontend/src/components/BookingDrawer/BookingDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import SwipeableEdgeDrawer, {
import { Room } from '../../types';
import { getTimeLeft, getTimeLeftMinutes2 } from '../util/TimeLeft';
import { theme } from '../../theme';
import DurationPicker from './DurationPicker';

const MIN_DURATION = 15;

Expand Down Expand Up @@ -174,6 +175,9 @@ interface Props {
availableMinutes: number;
room?: Room;
startingTime: string;
bookingDuration: number;
setBookingDuration: (minutes: number) => void;
setDuration: React.Dispatch<React.SetStateAction<number>>;
}

const BookingDrawer = (props: Props) => {
Expand All @@ -189,14 +193,21 @@ const BookingDrawer = (props: Props) => {
onAddTimeUntilFull,
onAddTimeUntilNext,
availableMinutes,
startingTime
startingTime,
bookingDuration,
setBookingDuration,
setDuration
} = props;

useEffect(() => {
updateHalfHour();
updateFullHour();
});

const handleDurationChange = (newDuration: number) => {
setBookingDuration(newDuration);
};

// Placeholder values
const [nextHalfHour, setNextHalfHour] = useState('00:30');
const [nextFullHour, setNextFullHour] = useState('01:00');
Expand Down Expand Up @@ -305,6 +316,14 @@ const BookingDrawer = (props: Props) => {
}}
>
<DrawerContent>
<RowCentered>
<DurationPicker
duration={duration}
setDuration={setDuration}
onChange={handleDurationChange}
title="duration"
/>
</RowCentered>
<RowCentered>
<TimeTextBold>
{minutesToSimpleString(
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/components/BookingView/BookingView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,8 @@ function BookingView(props: BookingViewProps) {
expandedFeaturesAll={expandedFeaturesAll}
preferences={preferences}
setPreferences={setPreferences}
setBookingDuration={setBookingDuration}
setDuration={setDuration}
/>
)}

Expand Down

0 comments on commit 9da87b8

Please sign in to comment.