fix: chat — group creation (snake_case member_ids), readable mention color
This commit is contained in:
@@ -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<string, unknown>)?.member_ids)
|
||||
? (request.body as Record<string, unknown>).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])]
|
||||
|
||||
@@ -115,7 +115,7 @@ function renderWithMentions(text: string, myName?: string) {
|
||||
const mentioned = part.slice(1).toLowerCase()
|
||||
const isMe = myFirst && mentioned.startsWith(myFirst)
|
||||
return (
|
||||
<span key={i} className={cn('font-semibold', isMe ? 'bg-yellow-300/20 text-yellow-200 rounded px-0.5' : 'opacity-90')}>
|
||||
<span key={i} className={cn('font-semibold rounded px-0.5', isMe ? 'bg-amber-100 text-amber-700 dark:bg-yellow-300/20 dark:text-yellow-300' : 'text-brand-600 dark:text-brand-300')}>
|
||||
{part}
|
||||
</span>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user