-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathEventPartialInfoView.tsx
More file actions
121 lines (112 loc) · 3.95 KB
/
Copy pathEventPartialInfoView.tsx
File metadata and controls
121 lines (112 loc) · 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import AccessTimeIcon from '@mui/icons-material/AccessTime';
import LocationOnIcon from '@mui/icons-material/LocationOn';
import { Calendar, EventInstance, EventType, formatEventTime } from 'shared';
import GroupIcon from '@mui/icons-material/Group';
import { Stack } from '@mui/system';
import { getTeamTypeIcon } from './CalendarDayCard';
import { Typography } from '@mui/material';
import { getMutedColor } from '../../utils/calendar.utils';
import { formatHourInCurrentTimeZone } from '../../utils/design-review.utils';
interface EventInfoProps {
event: EventInstance;
eventTypes?: EventType[];
calendars?: Calendar[];
onClick: () => void;
}
const EventPartialInfoView: React.FC<EventInfoProps> = ({ event, eventTypes, calendars, onClick }) => {
const name = event.title;
const specificEventType = eventTypes?.find((eventType) => eventType.eventTypeId === event.eventTypeId);
const specificCalendar = calendars?.find((calendar) =>
calendar.eventTypes.some((eventType) => eventType.eventTypeId === specificEventType?.eventTypeId)
);
const baseColor = specificCalendar?.color ?? 'gray';
const isPending = event.status === 'UNCONFIRMED' || event.approved === 'PENDING' || event.approved === 'DENIED';
const bgColor = isPending ? getMutedColor(baseColor, 0.35) : baseColor;
return (
<Stack
direction="column"
spacing={2}
bgcolor={bgColor}
margin={1}
borderRadius={2}
padding={1}
onClick={(e) => {
e.stopPropagation();
onClick();
}}
sx={{
cursor: 'pointer',
'&:hover': { opacity: 0.8 },
...(isPending && {
border: `1px dashed ${baseColor}`,
opacity: 0.8
})
}}
>
<Stack direction="row" spacing={5}>
<Stack direction="row" sx={{ minWidth: 0, flex: 1 }}>
{getTeamTypeIcon(event.teamType?.name ?? '', false)}
<Typography
marginX={0.5}
marginY={0.5}
lineHeight={'120%'}
fontSize={12}
fontWeight="bold"
align="left"
sx={{
flex: 1,
minWidth: 0,
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap'
}}
>
{name}
</Typography>
</Stack>
<Stack direction="row" sx={{ minWidth: 150, flexShrink: 0 }}>
<AccessTimeIcon />
{event.allDay ? (
<Typography marginX={0.5} marginY={0.5} lineHeight={'120%'} fontSize={12} fontWeight="bold" align="left">
All Day
</Typography>
) : (
<Typography marginX={0.5} marginY={0.5} lineHeight={'120%'} fontSize={12} fontWeight="bold" align="left">
{formatHourInCurrentTimeZone(formatEventTime(event.startTime))} -{' '}
{formatHourInCurrentTimeZone(formatEventTime(event.endTime))}
</Typography>
)}
</Stack>
</Stack>
<Stack direction="row" spacing={5}>
<Stack direction="row" sx={{ minWidth: 0, flex: 1 }}>
<LocationOnIcon />
<Typography
marginX={0.5}
marginY={0.5}
lineHeight={'120%'}
fontSize={12}
fontWeight="bold"
align="left"
sx={{
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap'
}}
>
{event.location ?? 'N/A'}
</Typography>
</Stack>
<Stack direction="row" sx={{ minWidth: 150, flexShrink: 0 }}>
<GroupIcon />
<Typography marginX={0.5} marginY={0.5} lineHeight={'120%'} fontSize={12} fontWeight="bold" align="left">
{event.requiredMembers[0]
? `${event.requiredMembers[0].firstName} ${event.requiredMembers[0].lastName}...`
: 'N/A '}
</Typography>
</Stack>
</Stack>
</Stack>
);
};
export default EventPartialInfoView;