@@ -26,12 +26,13 @@ import TitleIcon from '@mui/icons-material/Title';
26
26
import { FormData , IAvailableRoomsDropdownOption } from '@helpers/types' ;
27
27
import { LoadingButton } from '@mui/lab' ;
28
28
import { AppBar , Box , Button , Checkbox , IconButton , Skeleton , Stack , Typography } from '@mui/material' ;
29
- import { DatePicker } from '@mui/x-date-pickers/DatePicker ' ;
29
+ import CalendarMonthIcon from '@mui/icons-material/CalendarMonth ' ;
30
30
import dayjs from 'dayjs' ;
31
31
import 'dayjs/locale/en-gb' ;
32
32
import { useEffect , useRef , useState } from 'react' ;
33
33
import { EventResponse , IConferenceRoom , IAvailableRooms , IPeopleInformation } from '@quickmeet/shared' ;
34
34
import { useNavigate } from 'react-router-dom' ;
35
+ import DatePickerPopper from '@/pages/Home/MyEventsView/DatePickerPopper' ;
35
36
36
37
const createRoomDropdownOptions = ( rooms : IConferenceRoom [ ] ) => {
37
38
return ( rooms || [ ] ) . map ( ( room ) => ( { value : room . email , text : room . name , seats : room . seats , floor : room . floor } ) as RoomsDropdownOption ) ;
@@ -85,6 +86,8 @@ export default function EditEventsView({ open, event, handleClose, currentRoom,
85
86
const [ formData , setFormData ] = useState < FormData > ( initFormData ( event ) ) ;
86
87
87
88
const [ date , setDate ] = useState ( dayjs ( event . start ! ) ) ;
89
+ const [ datePickerOpen , setDatePickerOpen ] = useState ( false ) ;
90
+ const [ datePickerAnchorEl , setDatePickerAnchorEl ] = useState < null | HTMLElement > ( null ) ;
88
91
89
92
// Utilities and hooks
90
93
const api = useApi ( ) ;
@@ -186,6 +189,11 @@ export default function EditEventsView({ open, event, handleClose, currentRoom,
186
189
setAvailableRoomOptions ( { others : unPreferredRoomOptions , preferred : preferredRoomOptions } ) ;
187
190
}
188
191
192
+ const handleDatePopperClick = ( event : React . MouseEvent < HTMLElement > ) => {
193
+ setDatePickerAnchorEl ( event . currentTarget ) ;
194
+ setDatePickerOpen ( true ) ;
195
+ } ;
196
+
189
197
async function setPreferences ( ) {
190
198
const eventTime = new Date ( event . start ! ) ;
191
199
const currentTime = new Date ( new Date ( ) . toUTCString ( ) ) ;
@@ -315,42 +323,28 @@ export default function EditEventsView({ open, event, handleClose, currentRoom,
315
323
/>
316
324
</ Box >
317
325
< Box sx = { { flex : 1 , display : 'flex' } } >
318
- < DatePicker
319
- disablePast
320
- defaultValue = { dayjs ( event . start ! ) }
321
- onChange = { ( newDate ) => {
322
- if ( newDate ) {
323
- setDate ( newDate ) ;
324
- }
325
- } }
326
- slotProps = { {
327
- inputAdornment : {
328
- position : 'start' ,
329
- sx : {
330
- input : {
331
- cursor : 'pointer' ,
332
- } ,
333
- } ,
334
- } ,
335
- } }
336
- sx = { {
337
- '.MuiOutlinedInput-root' : {
338
- '& fieldset' : {
339
- border : 'none' ,
340
- } ,
341
- } ,
342
- '.MuiInputBase-input' : {
343
- color : ( theme ) => theme . palette . common . black ,
344
- fontFamily : 'inherit' ,
345
- fontSize : '1.125rem' ,
346
- fontWeight : 400 ,
347
- } ,
348
- '.MuiSvgIcon-root' : {
349
- color : ( theme ) => theme . palette . grey [ 50 ] ,
350
- } ,
351
- '.MuiButtonBase-root' : { cursor : 'pointer' } ,
352
- } }
353
- />
326
+ < Box sx = { { display : 'flex' , flexDirection : 'row' , alignItems : 'center' } } >
327
+ < IconButton aria-label = "calender" size = "small" onClick = { handleDatePopperClick } >
328
+ < CalendarMonthIcon
329
+ sx = { [
330
+ ( theme ) => ( {
331
+ color : theme . palette . grey [ 50 ] ,
332
+ } ) ,
333
+ ] }
334
+ fontSize = "medium"
335
+ />
336
+ </ IconButton >
337
+ < Typography
338
+ sx = { {
339
+ cursor : 'pointer' ,
340
+ ml : 2 ,
341
+ } }
342
+ variant = "subtitle1"
343
+ onClick = { handleDatePopperClick }
344
+ >
345
+ { date . format ( 'DD/MM/YYYY' ) }
346
+ </ Typography >
347
+ </ Box >
354
348
</ Box >
355
349
</ Box >
356
350
@@ -509,6 +503,14 @@ export default function EditEventsView({ open, event, handleClose, currentRoom,
509
503
</ Typography >
510
504
</ Button >
511
505
</ Box >
506
+ < DatePickerPopper
507
+ disablePast = { true }
508
+ currentDate = { date }
509
+ setCurrentDate = { setDate }
510
+ open = { datePickerOpen }
511
+ setOpen = { setDatePickerOpen }
512
+ anchorEl = { datePickerAnchorEl }
513
+ />
512
514
</ Box >
513
515
) ;
514
516
}
0 commit comments