From 56118870f330cd7c08e459138aa0062f0b838c14 Mon Sep 17 00:00:00 2001 From: Daria Mikhailova Date: Tue, 26 Mar 2024 20:20:02 +1300 Subject: [PATCH] formatting, showing manual guest entries on the map, improved query for upcoming events --- src/client/components/OfficeFloorMap.tsx | 7 ++- src/client/constants.ts | 2 + .../events/client/components/EventsPage.tsx | 4 +- .../hub-map/client/components/HubMap.tsx | 21 ++++++- .../client/components/ScheduledItemsList.tsx | 5 +- src/modules/hub-map/server/helpers/index.ts | 5 +- src/modules/hub-map/server/router.ts | 63 +++++++++++++++---- 7 files changed, 83 insertions(+), 24 deletions(-) diff --git a/src/client/components/OfficeFloorMap.tsx b/src/client/components/OfficeFloorMap.tsx index a5562bfa..97a15622 100644 --- a/src/client/components/OfficeFloorMap.tsx +++ b/src/client/components/OfficeFloorMap.tsx @@ -11,6 +11,7 @@ import { useStore } from '@nanostores/react' import * as stores from '#client/stores' import { ImageWithPanZoom } from './ui/ImageWithPanZoom' import { ScheduledItemType } from '#modules/hub-map/types' +import { ROBOT_USER_ID } from '#client/constants' type PointComponentFunctionProps = ( item: OfficeAreaDesk | OfficeRoom, @@ -106,7 +107,6 @@ export const OfficeFloorMap: React.FC = ({ [onToggle] ) - // @todo fix types here const mapObjects = (scale: number) => !mappablePoints ? [] @@ -140,7 +140,10 @@ export const OfficeFloorMap: React.FC = ({ transformOrigin: 'top left', } if (!!user && !!me) { - const userLink = !user.id ? '' : `/profile/${user.id}` + const userLink = + !user.id || user.id === ROBOT_USER_ID + ? '' + : `/profile/${user.id}` return ( { const [uniqueUpcoming, setUniqueUpcoming] = React.useState([]) React.useEffect(() => { - if (!!events && !!myEvents && !myEvents.pending.length) { - return - } else if (!!events && !!myEvents) { + if (!!events && !!myEvents) { const upcomingEventIds = new Set(myEvents.pending.map((e) => e.id)) const uniqueEvents = events[EventTimeCategory.upcoming].filter( (e) => !upcomingEventIds.has(e.id) diff --git a/src/modules/hub-map/client/components/HubMap.tsx b/src/modules/hub-map/client/components/HubMap.tsx index daa8d15e..13e56df7 100644 --- a/src/modules/hub-map/client/components/HubMap.tsx +++ b/src/modules/hub-map/client/components/HubMap.tsx @@ -137,6 +137,24 @@ export const _HubMap = () => { const isMobile = width <= 480 + const inOfficeMessage = React.useMemo(() => { + if (!visitorsNumber) { + return `No one in the ${office?.name} hub` + } + + if (userIsInOffce) { + if (visitorsNumber === 1) { + return `Only you in the ${office?.name} hub` + } else { + return `You and ${visitorsNumber - 1} others are in the ${ + office?.name + } hub` + } + } else { + return `${visitorsNumber} people in the ${office?.name} hub` + } + }, [office, visitorsNumber]) + if (!office?.allowDeskReservation) { return <> } @@ -207,8 +225,7 @@ export const _HubMap = () => {
- {userIsInOffce ? `You and ${visitorsNumber - 1}` : visitorsNumber}{' '} - people in the {office?.name} hub + {inOfficeMessage}