From ce058a678ee73cfd4e2f4dabd45fcfaff7cd8906 Mon Sep 17 00:00:00 2001 From: Tristan Yang Date: Wed, 30 Oct 2024 09:17:05 +0800 Subject: [PATCH] chore: admin only files --- src/routes/home/index.tsx | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/routes/home/index.tsx b/src/routes/home/index.tsx index c5f7b680..4b4f7419 100644 --- a/src/routes/home/index.tsx +++ b/src/routes/home/index.tsx @@ -31,6 +31,7 @@ function HomePage() { const roleChanged = useAppSelector((store) => store.authData.roleChanged, shallowEqual); const guest = useAppSelector((store) => store.authData.guest, shallowEqual); const loginUid = useAppSelector((store) => store.authData.user?.uid ?? 0, shallowEqual); + const isAdmin = useAppSelector((store) => store.authData.user?.is_admin ?? false, shallowEqual); const { chat: chatPath, user: userPath } = useAppSelector( (store) => store.ui.rememberedNavs, shallowEqual @@ -117,20 +118,22 @@ function HomePage() { ); }} - - `${linkClass} ${isActive ? "bg-primary-400 md:hover:bg-primary-400" : ""}` - } - to={"/files"} - > - {({ isActive }) => { - return ( - - - - ); - }} - + {isAdmin && ( + + `${linkClass} ${isActive ? "bg-primary-400 md:hover:bg-primary-400" : ""}` + } + to={"/files"} + > + {({ isActive }) => { + return ( + + + + ); + }} + + )}