-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmeeting-card.tsx
More file actions
166 lines (158 loc) · 3.84 KB
/
Copy pathmeeting-card.tsx
File metadata and controls
166 lines (158 loc) · 3.84 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import AccessTimeIcon from "@mui/icons-material/AccessTime";
import DateRangeIcon from "@mui/icons-material/DateRange";
import FmdGoodIcon from "@mui/icons-material/FmdGood";
import GroupIcon from "@mui/icons-material/Group";
import MoreVertIcon from "@mui/icons-material/MoreVert";
import NavigateNextIcon from "@mui/icons-material/NavigateNext";
import {
Box,
Button,
Card,
CardActions,
CardContent,
Chip,
IconButton,
Typography,
} from "@mui/material";
import Link from "next/link";
import type { ElementType } from "react";
interface MeetingCardProps {
meetingName: string;
meetingOrganizer: string;
dateStart: string;
dateEnd: string;
timeStart: string;
timeEnd: string;
availabilityMemberCount: number;
location?: string | null;
scheduled?: boolean;
scheduledLabel?: string;
meetingLink: string;
}
const metaIconSx = { fontSize: 16, color: "text.secondary", flexShrink: 0 };
const metaTextSx = { typography: { xs: "body2", sm: "body1" } };
const metaGridSx = {
display: "grid",
gridTemplateColumns: "1fr 1fr",
width: "100%",
columnGap: 1.5,
rowGap: 1.5,
};
const MetaItem = ({
icon: Icon,
label,
}: {
icon: ElementType;
label: string;
}) => (
<Box sx={{ display: "flex", alignItems: "center", gap: 0.5 }}>
<Icon sx={metaIconSx} />
<Typography color="text.secondary" noWrap sx={metaTextSx}>
{label}
</Typography>
</Box>
);
const MeetingCard = ({
meetingName,
meetingOrganizer,
dateStart,
dateEnd,
timeStart,
timeEnd,
availabilityMemberCount,
location,
scheduled = false,
scheduledLabel,
meetingLink,
}: MeetingCardProps) => {
const dateLabel =
dateStart && dateEnd && dateStart !== dateEnd
? `${dateStart} - ${dateEnd}`
: dateStart;
return (
<Card
variant="outlined"
sx={{ display: "flex", flexDirection: "column", p: 0 }}
>
<CardContent
sx={{
pt: { xs: 2.5, sm: 3 },
px: 2.5,
pb: 0,
"&:last-child": { pb: 0 },
display: "flex",
flexDirection: "column",
gap: 2,
flexGrow: 1,
}}
>
<Box sx={{ display: "flex", alignItems: "flex-start", gap: 1 }}>
<Box sx={{ flex: 1, minWidth: 0 }}>
<Typography
component="div"
noWrap
sx={{ typography: { xs: "h6", sm: "h5" } }}
>
{meetingName}
</Typography>
<Typography
component="div"
color="text.secondary"
noWrap
sx={metaTextSx}
>
{meetingOrganizer}
</Typography>
</Box>
<IconButton size="small" edge="end" sx={{ mt: -0.5, flexShrink: 0 }}>
<MoreVertIcon sx={{ fontSize: { xs: 24, sm: 20 } }} />
</IconButton>
</Box>
{scheduled && scheduledLabel ? (
<Box sx={{ display: "flex", flexDirection: "column", gap: 1.5 }}>
<Chip
label={scheduledLabel}
size="small"
color="secondary"
sx={{ borderRadius: "5px", fontWeight: 500, alignSelf: "start" }}
/>
<Box sx={metaGridSx}>
<MetaItem
icon={GroupIcon}
label={`${availabilityMemberCount} on availability`}
/>
{location && <MetaItem icon={FmdGoodIcon} label={location} />}
</Box>
</Box>
) : (
<Box sx={metaGridSx}>
<MetaItem icon={DateRangeIcon} label={dateLabel} />
<MetaItem
icon={AccessTimeIcon}
label={`${timeStart} - ${timeEnd}`}
/>
<MetaItem
icon={GroupIcon}
label={`${availabilityMemberCount} on availability`}
/>
{location && <MetaItem icon={FmdGoodIcon} label={location} />}
</Box>
)}
</CardContent>
<CardActions sx={{ px: 2.5, pb: 2.5, pt: 2, justifyContent: "flex-end" }}>
<Button
variant="text"
color="primary"
endIcon={<NavigateNextIcon />}
component={Link}
href={meetingLink}
size="small"
sx={{ textTransform: "capitalize", fontWeight: 600 }}
>
Add availability
</Button>
</CardActions>
</Card>
);
};
export default MeetingCard;