From 153e1d72d672e6ebc3430679c195cb25d71b1d1e Mon Sep 17 00:00:00 2001 From: HotelSync Date: Mon, 20 Apr 2026 20:04:01 +0300 Subject: [PATCH] fix: role-permissions GET/PUT return camelCase (isSystem, roleKey, homePage) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend was returning raw Postgres snake_case column names; frontend SavedRolePermission interface expected camelCase. This caused isSystem to always be undefined → all roles treated as custom in UserModal. Also adds home_page to the SELECT so homePage is available. Co-Authored-By: Claude Sonnet 4.6 --- backend/src/routes/role-permissions.ts | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/backend/src/routes/role-permissions.ts b/backend/src/routes/role-permissions.ts index 5a4045d..e41f612 100644 --- a/backend/src/routes/role-permissions.ts +++ b/backend/src/routes/role-permissions.ts @@ -29,13 +29,22 @@ const rolePermissionsRoute: FastifyPluginAsync = async (fastify) => { if (!hotelId) return reply.code(404).send({ error: 'Hotel not found' }) const { rows } = await db.query( - `SELECT id, hotel_id, role_key, name, color, is_system, permissions, created_at, updated_at + `SELECT id, hotel_id, role_key, name, color, is_system, permissions, home_page, created_at, updated_at FROM role_permissions WHERE hotel_id = $1 ORDER BY is_system DESC, name`, [hotelId], ) - return rows + return rows.map(r => ({ + id: r.id, + hotelId: r.hotel_id, + roleKey: r.role_key, + name: r.name, + color: r.color, + isSystem: r.is_system, + permissions: r.permissions, + homePage: r.home_page, + })) }, ) @@ -70,7 +79,17 @@ const rolePermissionsRoute: FastifyPluginAsync = async (fastify) => { RETURNING *`, [hotelId, roleKey, name, color, isSystem, JSON.stringify(permissions), homePage], ) - return rows[0] + const r = rows[0] + return { + id: r.id, + hotelId: r.hotel_id, + roleKey: r.role_key, + name: r.name, + color: r.color, + isSystem: r.is_system, + permissions: r.permissions, + homePage: r.home_page, + } }, )