diff --git a/backend/src/routes/chat.ts b/backend/src/routes/chat.ts index 05a30de..4200711 100644 --- a/backend/src/routes/chat.ts +++ b/backend/src/routes/chat.ts @@ -341,8 +341,13 @@ const chatRoutes: FastifyPluginAsync = async (fastify) => { const hotelId = await getHotelId(slug) if (!hotelId) return reply.code(404).send({ error: 'Hotel not found' }) - const { name, memberIds } = request.body + const name = request.body?.name + // Frontend sends snake_case (transformKeysToSnake converts camelCase) + const memberIds: string[] = Array.isArray((request.body as Record)?.member_ids) + ? (request.body as Record).member_ids as string[] + : Array.isArray(request.body?.memberIds) ? request.body.memberIds : [] if (!name?.trim()) return reply.code(400).send({ error: 'Name required' }) + if (memberIds.length === 0) return reply.code(400).send({ error: 'At least one member required' }) const userId = request.user.sub const allMembers = [...new Set([userId, ...memberIds])] diff --git a/src/components/chat/ChatWidget.tsx b/src/components/chat/ChatWidget.tsx index d23fad6..1cb4791 100644 --- a/src/components/chat/ChatWidget.tsx +++ b/src/components/chat/ChatWidget.tsx @@ -115,7 +115,7 @@ function renderWithMentions(text: string, myName?: string) { const mentioned = part.slice(1).toLowerCase() const isMe = myFirst && mentioned.startsWith(myFirst) return ( - + {part} )