From 1fd70094a116b671e50a5dfe864aea6bd9372dbd Mon Sep 17 00:00:00 2001 From: tiffanyvu Date: Wed, 15 Jan 2025 13:02:19 -0800 Subject: [PATCH] extract --- react-app/src/features/dashboard/index.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/react-app/src/features/dashboard/index.tsx b/react-app/src/features/dashboard/index.tsx index f53728168..e7bc5c73c 100644 --- a/react-app/src/features/dashboard/index.tsx +++ b/react-app/src/features/dashboard/index.tsx @@ -41,11 +41,14 @@ export const Dashboard = () => { const { data: userObj } = useGetUser(); const osData = useOsData(); - if ( - userObj === undefined || - (userObj.user["custom:cms-roles"] && - !Object.values(UserRoles).some((role) => userObj.user["custom:cms-roles"].includes(role))) - ) { + const isAbleToAccessDashboard = () => { + return ( + userObj.user["custom:cms-roles"] && + Object.values(UserRoles).some((role) => userObj.user["custom:cms-roles"].includes(role)) + ); + }; + + if (userObj === undefined || !isAbleToAccessDashboard()) { return ; }