diff --git a/app/src/gui/components/workspace/CreateNewSurvey.tsx b/app/src/gui/components/workspace/CreateNewSurvey.tsx index 1b9e57720..1d617aab1 100644 --- a/app/src/gui/components/workspace/CreateNewSurvey.tsx +++ b/app/src/gui/components/workspace/CreateNewSurvey.tsx @@ -16,19 +16,18 @@ import NewNotebookForListing from '../notebook/NewNotebookForListing'; export interface CreateNewSurveyProps {} const CreateNewSurvey: React.FC = () => { const activeUser = useAuthStore(state => state.activeUser); + const theme = useTheme(); + const isMobile = useMediaQuery(theme.breakpoints.down('sm')); + // TODO guard this component with active user check if (!activeUser) { - return

An error occurred - you do not have an active user.

; + return

An error occurred - no user is currently active!

; } - const tokenInfo = - useAuthStore.getState().servers[activeUser?.serverId].users[ - activeUser.username - ]; - const theme = useTheme(); - const isMobile = useMediaQuery(theme.breakpoints.down('sm')); + + const tokenInfo = activeUser.parsedToken; // Check user has the right role - const allowed = userCanCreateNotebooks(tokenInfo.parsedToken); + const allowed = userCanCreateNotebooks(tokenInfo); // TODO guard this component with specific role - button should never appear. if (!allowed) {