1- import { Box , Card , CardContent , Grid , IconButton , Stack , Typography } from '@mui/material' ;
1+ import { Box , Card , CardContent , Grid , IconButton , Link , Stack , Tooltip , Typography } from '@mui/material' ;
22import AddCircleOutlineIcon from '@mui/icons-material/AddCircleOutline' ;
33import { DesignReview } from 'shared' ;
44import { meetingStartTimePipe } from '../../../utils/pipes' ;
@@ -8,15 +8,16 @@ import ElectricalServicesIcon from '@mui/icons-material/ElectricalServices';
88import TerminalIcon from '@mui/icons-material/Terminal' ;
99import { useState } from 'react' ;
1010import DRCSummaryModal from '../DesignReviewSummaryModal' ;
11+ import DynamicTooltip from '../../../components/DynamicTooltip' ;
1112
12- export const getTeamTypeIcon = ( teamTypeId : string , isLarge ?: boolean ) => {
13+ export const getTeamTypeIcon = ( teamTypeName : string , isLarge ?: boolean ) => {
1314 const teamIcons : Map < string , JSX . Element > = new Map ( [
1415 [ 'Software' , < TerminalIcon fontSize = { isLarge ? 'large' : 'small' } /> ] ,
1516 [ 'Business' , < WorkOutlineIcon fontSize = { isLarge ? 'large' : 'small' } /> ] ,
1617 [ 'Electrical' , < ElectricalServicesIcon fontSize = { isLarge ? 'large' : 'small' } /> ] ,
1718 [ 'Mechanical' , < ConstructionIcon fontSize = { isLarge ? 'large' : 'small' } /> ]
1819 ] ) ;
19- return teamIcons . get ( teamTypeId ) ;
20+ return teamIcons . get ( teamTypeName ) ;
2021} ;
2122
2223interface CalendarDayCardProps {
@@ -40,33 +41,103 @@ const CalendarDayCard: React.FC<CalendarDayCardProps> = ({ cardDate, events }) =
4041 </ Grid >
4142 ) ;
4243
43- const EventCard = ( event : DesignReview ) => {
44+ const EventCard = ( { event } : { event : DesignReview } ) => {
4445 const [ isSummaryModalOpen , setIsSummaryModalOpen ] = useState ( false ) ;
45- const name = event . designReviewId ;
46+ const name = event . wbsName ;
4647 return (
4748 < >
4849 < DRCSummaryModal open = { isSummaryModalOpen } onHide = { ( ) => setIsSummaryModalOpen ( false ) } designReview = { event } />
4950 < Box marginLeft = { 0.5 } marginBottom = { 0.5 } onClick = { ( ) => setIsSummaryModalOpen ( true ) } sx = { { cursor : 'pointer' } } >
5051 < Card sx = { { backgroundColor : 'red' , borderRadius : 1 , minWidth : 140 , maxWidth : 140 , minHeight : 20 , maxHeight : 20 } } >
5152 < Stack direction = "row" >
52- { getTeamTypeIcon ( event . teamType . teamTypeId ) }
53- < Typography marginLeft = { 0.5 } marginBottom = { 0.3 } fontSize = { 14 } >
54- { name + ' ' + meetingStartTimePipe ( event . meetingTimes ) }
55- </ Typography >
53+ { getTeamTypeIcon ( event . teamType . name ) }
54+ < DynamicTooltip
55+ title = { name + ( event . meetingTimes . length > 0 ? ' - ' + meetingStartTimePipe ( event . meetingTimes ) : '' ) }
56+ >
57+ < Typography marginLeft = { 0.5 } marginBottom = { 0.3 } fontSize = { 14 } noWrap >
58+ { name + ( event . meetingTimes . length > 0 ? ' ' + meetingStartTimePipe ( event . meetingTimes ) : '' ) }
59+ </ Typography >
60+ </ DynamicTooltip >
5661 </ Stack >
5762 </ Card >
5863 </ Box >
5964 </ >
6065 ) ;
6166 } ;
6267
63- const ExtraEventsCard = ( extraEvents : number ) => {
68+ const ExtraEventNote = ( { event } : { event : DesignReview } ) => {
69+ const [ isSummaryModalOpen , setIsSummaryModalOpen ] = useState ( false ) ;
70+
71+ return (
72+ < >
73+ < DRCSummaryModal open = { isSummaryModalOpen } onHide = { ( ) => setIsSummaryModalOpen ( false ) } designReview = { event } />
74+ < Link
75+ style = { { cursor : 'pointer' } }
76+ fontSize = { 15 }
77+ onClick = { ( ) => {
78+ setIsSummaryModalOpen ( true ) ;
79+ } }
80+ >
81+ { event . wbsName + ( event . meetingTimes . length > 0 ? ' - ' + meetingStartTimePipe ( event . meetingTimes ) : '' ) }
82+ </ Link >
83+ </ >
84+ ) ;
85+ } ;
86+
87+ const ExtraEventsCard = ( { extraEvents } : { extraEvents : DesignReview [ ] } ) => {
88+ const [ showTooltip , setShowTooltip ] = useState ( false ) ;
6489 return (
6590 < Box marginLeft = { 0.5 } marginBottom = { 0.2 } >
66- < Card sx = { { backgroundColor : 'grey' , borderRadius : 1 , minWidth : 140 , maxWidth : 140 , minHeight : 20 , maxHeight : 20 } } >
67- < Typography marginLeft = { 0.5 } marginBottom = { 0.3 } align = "center" >
68- { '+' + extraEvents }
69- </ Typography >
91+ < Card
92+ sx = { {
93+ backgroundColor : 'grey' ,
94+ borderRadius : 1 ,
95+ minWidth : 140 ,
96+ maxWidth : 140 ,
97+ minHeight : 20 ,
98+ maxHeight : 20
99+ } }
100+ >
101+ < Tooltip
102+ id = "tooltip"
103+ open = { showTooltip }
104+ disableHoverListener
105+ onClick = { ( ) => setShowTooltip ( ! showTooltip ) }
106+ placement = "right"
107+ sx = { { cursor : 'pointer' } }
108+ PopperProps = { {
109+ popperOptions : {
110+ modifiers : [
111+ {
112+ name : 'flip' ,
113+ options : {
114+ fallbackPlacements : [ 'top' , 'bottom' ] ,
115+ padding : - 1 ,
116+ rootBoundary : 'document'
117+ }
118+ } ,
119+ {
120+ name : 'offset' ,
121+ options : {
122+ offset : [ 0 , - 1 ]
123+ }
124+ }
125+ ]
126+ }
127+ } }
128+ arrow
129+ title = {
130+ < Stack direction = "column" >
131+ { extraEvents . map ( ( event ) => (
132+ < ExtraEventNote event = { event } />
133+ ) ) }
134+ </ Stack >
135+ }
136+ >
137+ < Typography marginLeft = { 0.5 } marginBottom = { 0.3 } align = "center" >
138+ { '+' + extraEvents . length }
139+ </ Typography >
140+ </ Tooltip >
70141 </ Card >
71142 </ Box >
72143 ) ;
@@ -77,11 +148,11 @@ const CalendarDayCard: React.FC<CalendarDayCardProps> = ({ cardDate, events }) =
77148 < CardContent sx = { { padding : 0 } } >
78149 < DayCardTitle />
79150 { events . length < 3 ? (
80- events . map ( ( event ) => EventCard ( event ) )
151+ events . map ( ( event ) => < EventCard event = { event } /> )
81152 ) : (
82153 < >
83- { EventCard ( events [ 1 ] ) }
84- { ExtraEventsCard ( events . length - 1 ) }
154+ < EventCard event = { events [ 0 ] } />
155+ < ExtraEventsCard extraEvents = { events . slice ( 1 ) } />
85156 </ >
86157 ) }
87158 </ CardContent >
0 commit comments