diff --git a/crabfit-frontend/src/components/AvailabilityViewer/AvailabilityViewer.tsx b/crabfit-frontend/src/components/AvailabilityViewer/AvailabilityViewer.tsx
index 881eaee..4597830 100644
--- a/crabfit-frontend/src/components/AvailabilityViewer/AvailabilityViewer.tsx
+++ b/crabfit-frontend/src/components/AvailabilityViewer/AvailabilityViewer.tsx
@@ -1,4 +1,4 @@
-import { useState, useEffect, useRef, Fragment } from 'react';
+import { useState, useEffect, useRef, useMemo, Fragment } from 'react';
import { useTranslation } from 'react-i18next';
import dayjs from 'dayjs';
import localeData from 'dayjs/plugin/localeData';
@@ -65,6 +65,94 @@ const AvailabilityViewer = ({
setTouched(people.length <= 1);
}, [people]);
+ const heatmap = useMemo(() => (
+
+
+ {!!timeLabels.length && timeLabels.map((label, i) =>
+
+ {label.label?.length !== '' && {label.label}}
+
+ )}
+
+ {dates.map((date, i) => {
+ const parsedDate = isSpecificDates ? dayjs(date, 'DDMMYYYY') : dayjs().day(date);
+ const last = dates.length === i+1 || (isSpecificDates ? dayjs(dates[i+1], 'DDMMYYYY') : dayjs().day(dates[i+1])).diff(parsedDate, 'day') > 1;
+ return (
+
+
+ {isSpecificDates && {parsedDate.format('MMM D')}}
+ {parsedDate.format('ddd')}
+
+ 1}
+ >
+ {timeLabels.map((timeLabel, i) => {
+ if (!timeLabel.time) return null;
+ if (!times.includes(`${timeLabel.time}-${date}`)) {
+ return (
+
+ );
+ }
+ const time = `${timeLabel.time}-${date}`;
+ const peopleHere = tempFocus !== null
+ ? people.filter(person => person.availability.includes(time) && tempFocus === person.name).map(person => person.name)
+ : people.filter(person => person.availability.includes(time) && filteredPeople.includes(person.name)).map(person => person.name);
+
+ return (
+
+
+ {last && dates.length !== i+1 && (
+
+ )}
+
+ );
+ })}
+
+ ), [
+ people,
+ filteredPeople,
+ tempFocus,
+ focusCount,
+ highlight,
+ locale,
+ dates,
+ isSpecificDates,
+ max,
+ min,
+ t,
+ timeFormat,
+ timeLabels,
+ times,
+ ]);
+
return (
<>
@@ -108,76 +196,8 @@ const AvailabilityViewer = ({
-
-
- {!!timeLabels.length && timeLabels.map((label, i) =>
-
- {label.label?.length !== '' && {label.label}}
-
- )}
-
- {dates.map((date, i) => {
- const parsedDate = isSpecificDates ? dayjs(date, 'DDMMYYYY') : dayjs().day(date);
- const last = dates.length === i+1 || (isSpecificDates ? dayjs(dates[i+1], 'DDMMYYYY') : dayjs().day(dates[i+1])).diff(parsedDate, 'day') > 1;
- return (
-
-
- {isSpecificDates && {parsedDate.format('MMM D')}}
- {parsedDate.format('ddd')}
+ {heatmap}
- 1}
- >
- {timeLabels.map((timeLabel, i) => {
- if (!timeLabel.time) return null;
- if (!times.includes(`${timeLabel.time}-${date}`)) {
- return (
-
- );
- }
- const time = `${timeLabel.time}-${date}`;
- const peopleHere = tempFocus !== null
- ? people.filter(person => person.availability.includes(time) && tempFocus === person.name).map(person => person.name)
- : people.filter(person => person.availability.includes(time) && filteredPeople.includes(person.name)).map(person => person.name);
-
- return (
-
-
- {last && dates.length !== i+1 && (
-
- )}
-
- );
- })}
-
{tooltip && (
props.highlight && props.peopleCount === props.maxPeople ? `
+ ${props => props.highlight && props.peopleCount === props.maxPeople && props.peopleCount > 0 ? `
background-image: repeating-linear-gradient(
45deg,
${props.theme.primary},
diff --git a/crabfit-frontend/src/components/Legend/Legend.tsx b/crabfit-frontend/src/components/Legend/Legend.tsx
index e8477a0..2760ded 100644
--- a/crabfit-frontend/src/components/Legend/Legend.tsx
+++ b/crabfit-frontend/src/components/Legend/Legend.tsx
@@ -34,7 +34,7 @@ const Legend = ({
0}
onMouseOver={() => onSegmentFocus(i)}
/>
)}