From 018b11977237c744c6760342a4c7cdb32b083b22 Mon Sep 17 00:00:00 2001 From: HotelSync Date: Tue, 24 Mar 2026 19:57:12 +0300 Subject: [PATCH] fix: broadcast on task create (realtime), context menu position recalc, CDN_HOST in deploy.sh --- backend/src/routes/housekeeping.ts | 1 + src/components/rooms/RoomContextMenu.tsx | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/backend/src/routes/housekeeping.ts b/backend/src/routes/housekeeping.ts index 16ff5fa..02a4c04 100644 --- a/backend/src/routes/housekeeping.ts +++ b/backend/src/routes/housekeeping.ts @@ -119,6 +119,7 @@ const housekeeping: FastifyPluginAsync = async (fastify) => { WHERE t.id = $1`, [inserted[0].id], ) + broadcast(slug, { type: 'housekeeping_task_created', task: rows[0] }) return reply.code(201).send(rows[0]) }, ) diff --git a/src/components/rooms/RoomContextMenu.tsx b/src/components/rooms/RoomContextMenu.tsx index 30140c6..f57ce29 100644 --- a/src/components/rooms/RoomContextMenu.tsx +++ b/src/components/rooms/RoomContextMenu.tsx @@ -54,6 +54,17 @@ export function RoomContextMenu({ room, x, y, onClose, onStatusChange, onHkStatu const [photoUploading, setPhotoUploading] = useState(false) const photoInputRef = useRef(null) + // Recalculate position whenever content changes (e.g. photos added) + useEffect(() => { + if (ref.current) { + const rect = ref.current.getBoundingClientRect() + const overflowX = rect.right - window.innerWidth + 8 + const overflowY = rect.bottom - window.innerHeight + 8 + if (overflowX > 0) ref.current.style.left = `${rect.left - overflowX}px` + if (overflowY > 0) ref.current.style.top = `${Math.max(8, rect.top - overflowY)}px` + } + }, [techPhotos.length, subForm]) + useEffect(() => { const handler = (e: MouseEvent) => { if (ref.current && !ref.current.contains(e.target as Node)) onClose() @@ -131,8 +142,8 @@ export function RoomContextMenu({ room, x, y, onClose, onStatusChange, onHkStatu return createPortal(
e.preventDefault()} > {/* Header */}