-
Notifications
You must be signed in to change notification settings - Fork 15
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
Feat/issue 170 - Add option to pick dates #175
Merged
+205
−41
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import { Box, Checkbox, Typography } from '@mui/material'; | ||
import { useEffect, useRef, useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import AttendeeInput from '@/components/AttendeeInput'; | ||
import StyledTextField from '@/components/StyledTextField'; | ||
import { useApi } from '@/context/ApiContext'; | ||
import { usePreferences } from '@/context/PreferencesContext'; | ||
import Dropdown, { DropdownOption } from '@components/Dropdown'; | ||
import LoadingButton from '@mui/lab/LoadingButton'; | ||
import RoomsDropdown, { RoomsDropdownOption } from '@components/RoomsDropdown'; | ||
import { FormData } from '@helpers/types'; | ||
import { | ||
convertToRFC3339, | ||
createDropdownOptions, | ||
|
@@ -13,20 +15,21 @@ import { | |
populateTimeOptions, | ||
renderError, | ||
} from '@helpers/utility'; | ||
import toast from 'react-hot-toast'; | ||
import AccessTimeFilledRoundedIcon from '@mui/icons-material/AccessTimeFilledRounded'; | ||
import EventSeatRoundedIcon from '@mui/icons-material/EventSeatRounded'; | ||
import { FormData } from '@helpers/types'; | ||
import { BookRoomDto, EventResponse, IConferenceRoom } from '@quickmeet/shared'; | ||
import MeetingRoomRoundedIcon from '@mui/icons-material/MeetingRoomRounded'; | ||
import HourglassBottomRoundedIcon from '@mui/icons-material/HourglassBottomRounded'; | ||
import RoomsDropdown, { RoomsDropdownOption } from '@components/RoomsDropdown'; | ||
import { usePreferences } from '@/context/PreferencesContext'; | ||
import StyledTextField from '@/components/StyledTextField'; | ||
import MeetingRoomRoundedIcon from '@mui/icons-material/MeetingRoomRounded'; | ||
import TitleIcon from '@mui/icons-material/Title'; | ||
import { useApi } from '@/context/ApiContext'; | ||
import AttendeeInput from '@/components/AttendeeInput'; | ||
|
||
import LoadingButton from '@mui/lab/LoadingButton'; | ||
import { Box, Checkbox, Typography } from '@mui/material'; | ||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; | ||
import { DatePicker } from '@mui/x-date-pickers/DatePicker'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
import { BookRoomDto, EventResponse, IConferenceRoom } from '@quickmeet/shared'; | ||
import dayjs from 'dayjs'; | ||
import { useEffect, useRef, useState } from 'react'; | ||
import toast from 'react-hot-toast'; | ||
import { useNavigate } from 'react-router-dom'; | ||
const createRoomDropdownOptions = (rooms: IConferenceRoom[]) => { | ||
return (rooms || []).map((room) => ({ value: room.email, text: room.name, seats: room.seats, floor: room.floor }) as RoomsDropdownOption); | ||
}; | ||
|
@@ -58,6 +61,8 @@ export default function BookRoomView({ onRoomBooked }: BookRoomViewProps) { | |
seats: preferences.seats, | ||
}); | ||
|
||
const [date, setDate] = useState(dayjs()); | ||
|
||
// Utilities and hooks | ||
const navigate = useNavigate(); | ||
const abortControllerRef = useRef<AbortController | null>(null); | ||
|
@@ -119,10 +124,8 @@ export default function BookRoomView({ onRoomBooked }: BookRoomViewProps) { | |
async function setAvailableRooms() { | ||
const { startTime, duration, seats } = formData; | ||
const { floor } = preferences; | ||
|
||
const date = new Date(Date.now()).toISOString().split('T')[0]; | ||
const formattedStartTime = convertToRFC3339(date, startTime); | ||
|
||
const currentDate = date.toISOString().split('T')[0]; | ||
const formattedStartTime = convertToRFC3339(currentDate, startTime); | ||
setRoomLoading(true); | ||
|
||
if (abortControllerRef.current) { | ||
|
@@ -167,8 +170,7 @@ export default function BookRoomView({ onRoomBooked }: BookRoomViewProps) { | |
return; | ||
} | ||
|
||
const date = new Date(Date.now()).toISOString().split('T')[0]; | ||
const formattedStartTime = convertToRFC3339(date, startTime); | ||
const formattedStartTime = convertToRFC3339(date.toISOString().split('T')[0], startTime); | ||
const { floor, title: preferredTitle } = preferences; | ||
|
||
const payload: BookRoomDto = { | ||
|
@@ -215,30 +217,71 @@ export default function BookRoomView({ onRoomBooked }: BookRoomViewProps) { | |
> | ||
<Box | ||
sx={{ | ||
px: 1, | ||
pt: 1, | ||
display: 'flex', | ||
alignItems: 'center', | ||
flexDirection: 'row', | ||
backgroundColor: (theme) => theme.palette.common.white, | ||
border: 'none', | ||
width: '100%', | ||
}} | ||
> | ||
<Dropdown | ||
id="startTime" | ||
options={timeOptions} | ||
value={formData.startTime} | ||
onChange={handleInputChange} | ||
sx={{ | ||
borderTopLeftRadius: 10, | ||
borderTopRightRadius: 10, | ||
}} | ||
icon={ | ||
<AccessTimeFilledRoundedIcon | ||
sx={[ | ||
(theme) => ({ | ||
color: theme.palette.grey[50], | ||
}), | ||
]} | ||
<Box sx={{ width: '50%' }}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the same needs to be done in EditEventsView |
||
<Dropdown | ||
id="startTime" | ||
options={timeOptions} | ||
value={formData.startTime} | ||
onChange={handleInputChange} | ||
sx={{ | ||
borderTopLeftRadius: 10, | ||
borderTopRightRadius: 10, | ||
}} | ||
icon={ | ||
<AccessTimeFilledRoundedIcon | ||
sx={[ | ||
(theme) => ({ | ||
color: theme.palette.grey[50], | ||
}), | ||
]} | ||
/> | ||
} | ||
/> | ||
</Box> | ||
<Box sx={{ flex: 1, display: 'flex', justifyContent: 'center', alignItems: 'center' }}> | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<DatePicker | ||
defaultValue={date} | ||
onChange={(newDate) => { | ||
if (newDate) { | ||
setDate(newDate); | ||
} | ||
}} | ||
slotProps={{ | ||
inputAdornment: { | ||
position: 'start', | ||
}, | ||
}} | ||
sx={{ | ||
'.MuiOutlinedInput-root': { | ||
'& fieldset': { | ||
border: 'none', | ||
}, | ||
}, | ||
'.MuiInputBase-input': { | ||
color: (theme) => theme.palette.common.black, | ||
fontFamily: 'inherit', | ||
fontSize: '1.125rem', | ||
fontWeight: 400, | ||
}, | ||
'.MuiSvgIcon-root': { | ||
color: (theme) => theme.palette.grey[50], | ||
}, | ||
ml: 0.2, | ||
}} | ||
/> | ||
} | ||
/> | ||
|
||
</LocalizationProvider> | ||
</Box> | ||
</Box> | ||
<Box> | ||
<Box sx={{ display: 'flex' }}> | ||
<Dropdown | ||
id="duration" | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use the existing hook
formData
with a new field added there "date"There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, try replacing dayjs with existing method
convertToRFC3339()`