From 2c3a4e6376b8edf220150df4d79aaf3babd17f5e Mon Sep 17 00:00:00 2001 From: Daria Mikhailova Date: Mon, 4 Mar 2024 14:09:43 +1300 Subject: [PATCH] stealth mode --- src/client/components/OfficeFloorMap.tsx | 8 +++--- .../hub-map/client/components/HubMap.tsx | 26 +++++++++++++++++-- src/modules/hub-map/server/router.ts | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/client/components/OfficeFloorMap.tsx b/src/client/components/OfficeFloorMap.tsx index 4f6827f5..2a49368f 100644 --- a/src/client/components/OfficeFloorMap.tsx +++ b/src/client/components/OfficeFloorMap.tsx @@ -33,12 +33,14 @@ const PointComponent: Record< disabled={!isAvailable} color={isSelected ? 'purple' : 'default'} className={cn( + pointCommonStyle, isSelected ? 'border-pink-600 bg-accents-pink' : 'bg-violet-300 border-violet-300', - 'hover:bg-cta-purple hover:border-cta-hover-purpleNoOpacity hover:text-white', - 'min-h-[32px] min-w-[32px]', - pointCommonStyle + isAvailable + ? 'hover:bg-cta-purple hover:border-cta-hover-purpleNoOpacity hover:text-white' + : 'hover:scale-100 hover:bg-violet-300', + 'min-h-[32px] min-w-[32px]' )} onClick={onClick(item.id, VisitType.Visit)} > diff --git a/src/modules/hub-map/client/components/HubMap.tsx b/src/modules/hub-map/client/components/HubMap.tsx index 2119bf2b..20cfc42e 100644 --- a/src/modules/hub-map/client/components/HubMap.tsx +++ b/src/modules/hub-map/client/components/HubMap.tsx @@ -1,5 +1,11 @@ import * as React from 'react' -import { Avatar, Input, Select, WidgetWrapper } from '#client/components/ui' +import { + Avatar, + Input, + Select, + StealthMode, + WidgetWrapper, +} from '#client/components/ui' import { useStore } from '@nanostores/react' import * as stores from '#client/stores' import { useOffice } from '#client/utils/hooks' @@ -11,6 +17,7 @@ import { ScheduledItemsList } from './ScheduledItemsList' import { useAvailableDesks, useOfficeVisitors, + useToggleStealthMode, useVisitsAreas, } from '#modules/visits/client/queries' import { propEq } from '#shared/utils' @@ -51,6 +58,14 @@ export const _HubMap = () => { dayjs().toString() ) + const { mutate: toggleStealthMode } = useToggleStealthMode(() => { + refetchVisits() + refetchVisitors() + }) + const onToggleStealthMode = React.useCallback((value: boolean) => { + toggleStealthMode({ stealthMode: value }) + }, []) + React.useEffect(() => { setOfficeVisits(upcomingVisitsAll?.byDate[date.format(DATE_FORMAT)]) }, [upcomingVisitsAll?.byDate, date]) @@ -74,7 +89,7 @@ export const _HubMap = () => { [] ) - const { data: visitors } = useOfficeVisitors( + const { data: visitors, refetch: refetchVisitors } = useOfficeVisitors( officeId, dayjs(date).format(DATE_FORMAT) ) @@ -226,6 +241,13 @@ export const _HubMap = () => { }} /> +
+ +
)} diff --git a/src/modules/hub-map/server/router.ts b/src/modules/hub-map/server/router.ts index 353931e0..3349fad7 100644 --- a/src/modules/hub-map/server/router.ts +++ b/src/modules/hub-map/server/router.ts @@ -93,7 +93,7 @@ const userRouter: FastifyPluginCallback = async function (fastify, opts) { let dailyEventsVisits = [] const userIds = Array.from(new Set(visits.map(fp.prop('userId')))) const users = await fastify.db.User.findAll({ - where: { id: { [Op.in]: userIds } }, + where: { id: { [Op.in]: userIds }, stealthMode: false }, raw: true, }) const usersById = users.reduce(fp.by('id'), {})