Skip to content

Commit d430b06

Browse files
authored
Merge pull request #4234 from Northeastern-Electric-Racing/#4228-highlight-cell
highlight cell if all required members are available
2 parents ecc36a0 + faf2d2c commit d430b06

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

src/frontend/src/pages/CalendarPage/AvailabilityScheduleView.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,17 @@ const AvailabilityScheduleView: React.FC<AvailabilityScheduleViewProps> = ({
4545
}
4646
};
4747

48+
// Boolean check to see if all required users can attend at the time.
49+
const allRequiredUsersAvailable = (index: number) => {
50+
const currUnavailableUsers: User[] = unavailableUsers.get(index) ?? [];
51+
for (const user of currUnavailableUsers) {
52+
if (event && event.requiredMembers.some((m) => m.userId === user.userId)) {
53+
return false; // there is a required member unavailable
54+
}
55+
}
56+
return true;
57+
};
58+
4859
// Handle mouse leave - clears the hover state and shows selected slot's users if any
4960
const handleMouseLeave = () => {
5061
if (setCurrentHoveredSlot) {
@@ -160,10 +171,16 @@ const AvailabilityScheduleView: React.FC<AvailabilityScheduleViewProps> = ({
160171
{potentialDays.map((day, dayIndex) => {
161172
const index = dayIndex * enumToArray(REVIEW_TIMES).length + timeIndex;
162173
return (
163-
<TableCell key={index} sx={{ p: 0 }}>
174+
<TableCell
175+
key={index}
176+
sx={{
177+
p: 0
178+
}}
179+
>
164180
<EventTimeSlot
165181
backgroundColor={getBackgroundColor(availableUsers.get(index)?.length, totalUsers)}
166182
selected={selectedTimeslot === index}
183+
allRequiredAvailable={allRequiredUsersAvailable(index)}
167184
onClick={() => handleTimeslotClick(index, day, timeIndex)}
168185
onMouseEnter={() => handleTimeslotHover(index, day, timeIndex)}
169186
/>

src/frontend/src/pages/CalendarPage/Components/EventTimeSlot.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ interface EventTimeSlotProps {
44
backgroundColor?: string;
55
onClick?: () => void;
66
selected?: boolean;
7+
allRequiredAvailable?: boolean;
78
onMouseDown?: (e: React.MouseEvent) => void;
89
onMouseEnter?: (e: React.MouseEvent) => void;
910
onMouseUp?: () => void;
@@ -13,17 +14,19 @@ const EventTimeSlot: React.FC<EventTimeSlotProps> = ({
1314
backgroundColor,
1415
onClick,
1516
selected = false,
17+
allRequiredAvailable = false,
1618
onMouseDown,
1719
onMouseEnter,
1820
onMouseUp
1921
}) => {
2022
const getBorderColor = () => {
2123
if (selected) return '#ffff8c';
24+
if (allRequiredAvailable) return '#216799';
2225
return 'gray';
2326
};
2427

2528
const getBorderWidth = () => {
26-
if (selected) return '3px';
29+
if (selected || allRequiredAvailable) return '3px';
2730
return '0.1px';
2831
};
2932

0 commit comments

Comments
 (0)