From 33ac849d3bc96e52e3c1df4acfc50506e5c02e88 Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Mon, 25 May 2026 22:59:09 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=EF=B8=8F(frontend)=20add=20component?= =?UTF-8?q?=20to=20render=20children=20only=20for=20Admin=20or=20User?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce a component that renders its children only if the logged-in user is considered Admin or User. This helps avoid mounting the hooks and logic of components that previously early-returned when the user was not admin or owner, but were still re-rendering whenever their internal logic updated. --- .../features/rooms/components/AdminOrOwnerOnly.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/frontend/src/features/rooms/components/AdminOrOwnerOnly.tsx diff --git a/src/frontend/src/features/rooms/components/AdminOrOwnerOnly.tsx b/src/frontend/src/features/rooms/components/AdminOrOwnerOnly.tsx new file mode 100644 index 00000000..c6f750a0 --- /dev/null +++ b/src/frontend/src/features/rooms/components/AdminOrOwnerOnly.tsx @@ -0,0 +1,11 @@ +import { useIsAdminOrOwner } from '@/features/rooms/livekit/hooks/useIsAdminOrOwner' + +export const AdminOrOwnerOnly = ({ + children, +}: { + children: React.ReactNode +}) => { + const isAdminOrOwner = useIsAdminOrOwner() + if (!isAdminOrOwner) return null + return children +}