diff --git a/client/src/components/home/index.tsx b/client/src/components/home/index.tsx index 055b59cb..26654a57 100644 --- a/client/src/components/home/index.tsx +++ b/client/src/components/home/index.tsx @@ -35,7 +35,7 @@ import parseMentor, { defaultMentorInfo, } from "components/my-mentor-card/mentor-info"; import NavBar from "components/nav-bar"; -import { canEditContent, launchMentor } from "helpers"; +import { canEditContent, isAdmin, launchMentor } from "helpers"; import { QuestionEdits, useWithReviewAnswerState, @@ -57,6 +57,7 @@ import { trainMentor } from "api"; import { useWithConfig } from "store/slices/config/useWithConfig"; import { BuildMentorTooltip } from "./build-mentor-tooltip"; import { MentorConfig } from "types-gql"; +import { useAppSelector } from "store/hooks"; const useStyles = makeStyles({ name: { HomePage } })((theme: Theme) => ({ toolbar: { @@ -155,7 +156,9 @@ function HomePage(props: { const mentorConfig: MentorConfig | undefined = getData( (m) => m.data?.mentorConfig ); - const lockedToConfig: boolean = getData((m) => m.data?.lockedToConfig); + const user = useAppSelector((state) => state.login.user); + const lockedToConfig: boolean = + !isAdmin(user) && getData((m) => m.data?.lockedToConfig); const defaultMentor = props.user.defaultMentor._id; const { classes } = useStyles(); const [showSetupAlert, setShowSetupAlert] = useState(true); @@ -532,7 +535,7 @@ function HomePage(props: { {name} ))} - {mentorConfig?.lockedToSubjects ? undefined : ( + {lockedToConfig && mentorConfig?.lockedToSubjects ? undefined : ( ({ toolbar: { @@ -320,7 +321,8 @@ export function NavBar(props: { } = props; const { getData } = useActiveMentor(); const mentor: Mentor | undefined = getData((state) => state.data); - + const user = useAppSelector((state) => state.login.user); + const lockedToConfig = mentor?.lockedToConfig && !isAdmin(user); const importStatus = useWithImportStatus(); const { importTask } = importStatus; const numUploadsInProgress = @@ -403,7 +405,9 @@ export function NavBar(props: { > state.login.user); + const lockedToConfig = !isAdmin(user) && mentor.lockedToConfig; + const mentorSubjectsLocked = + lockedToConfig && mentor.mentorConfig?.lockedToSubjects; const mentorPrivacyLocked = - mentor.mentorConfig?.publiclyVisible !== undefined || - mentor.mentorConfig?.orgPermissions.length; - const mentorTypeLocked = mentor.mentorConfig?.mentorType; + lockedToConfig && + (mentor.mentorConfig?.publiclyVisible !== undefined || + mentor.mentorConfig?.orgPermissions.length); + const mentorTypeLocked = lockedToConfig && mentor.mentorConfig?.mentorType; + const disabledMyGoalSlide = + lockedToConfig && mentor.mentorConfig?.disableMyGoalSlide; const status: SetupStep[] = [ { type: SetupStepType.WELCOME, complete: true }, { type: SetupStepType.MENTOR_INFO, complete: isMentorInfoDone }, @@ -208,7 +219,7 @@ export function useWithSetup( ...(mentorPrivacyLocked ? [] : [{ type: SetupStepType.MENTOR_PRIVACY, complete: true }]), - ...(mentor.mentorConfig?.disableMyGoalSlide + ...(disabledMyGoalSlide ? [] : [ { type: SetupStepType.MENTOR_GOAL, complete: Boolean(mentor.goal) },