Use time format setting in tooltip
This commit is contained in:
parent
d5508e9f99
commit
4503fa4bf2
|
|
@ -3,6 +3,8 @@ import dayjs from 'dayjs';
|
||||||
import localeData from 'dayjs/plugin/localeData';
|
import localeData from 'dayjs/plugin/localeData';
|
||||||
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
import customParseFormat from 'dayjs/plugin/customParseFormat';
|
||||||
|
|
||||||
|
import { useSettingsStore } from 'stores';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Wrapper,
|
Wrapper,
|
||||||
Container,
|
Container,
|
||||||
|
|
@ -35,6 +37,7 @@ const AvailabilityViewer = ({
|
||||||
...props
|
...props
|
||||||
}) => {
|
}) => {
|
||||||
const [tooltip, setTooltip] = useState(null);
|
const [tooltip, setTooltip] = useState(null);
|
||||||
|
const timeFormat = useSettingsStore(state => state.timeFormat);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Wrapper>
|
<Wrapper>
|
||||||
|
|
@ -77,11 +80,12 @@ const AvailabilityViewer = ({
|
||||||
minPeople={min}
|
minPeople={min}
|
||||||
onMouseEnter={(e) => {
|
onMouseEnter={(e) => {
|
||||||
const cellBox = e.currentTarget.getBoundingClientRect();
|
const cellBox = e.currentTarget.getBoundingClientRect();
|
||||||
|
const timeText = timeFormat === '12h' ? 'h:mma' : 'HH:mm';
|
||||||
setTooltip({
|
setTooltip({
|
||||||
x: Math.round(cellBox.x + cellBox.width/2),
|
x: Math.round(cellBox.x + cellBox.width/2),
|
||||||
y: Math.round(cellBox.y + cellBox.height)+6,
|
y: Math.round(cellBox.y + cellBox.height)+6,
|
||||||
available: `${peopleHere.length} / ${people.length} available`,
|
available: `${peopleHere.length} / ${people.length} available`,
|
||||||
date: parsedDate.hour(time.slice(0, 2)).minute(time.slice(2, 4)).format(isSpecificDates ? 'h:mma ddd, D MMM YYYY' : 'h:mma ddd'),
|
date: parsedDate.hour(time.slice(0, 2)).minute(time.slice(2, 4)).format(isSpecificDates ? `${timeText} ddd, D MMM YYYY` : `${timeText} ddd`),
|
||||||
people: peopleHere.join(', '),
|
people: peopleHere.join(', '),
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue