From b5adc63940ec1d99a1ceba8bc4dbbdbe7f0fe448 Mon Sep 17 00:00:00 2001 From: Aaron shiel <57824522+aaronshiel@users.noreply.github.com> Date: Thu, 28 Sep 2023 16:36:02 -0700 Subject: [PATCH] can upload same file name, preview button opens in new tab (#310) * can upload same file name, preview button opens in new tab * disable keyword+thumbnail rec's + disable level progress w/ config * notify locked users when they complete all their subjects --- client/src/api.ts | 12 +++++++ client/src/components/home/index.tsx | 32 ++++++++++++++++++- .../top-mentor-card/mentor-status.tsx | 19 +++++++---- .../src/components/record/video-recorder.tsx | 3 ++ client/src/components/setup/welcome-slide.tsx | 3 +- .../use-with-mentor-recommender.tsx | 12 +++++-- client/src/types-gql.ts | 4 +++ 7 files changed, 73 insertions(+), 12 deletions(-) diff --git a/client/src/api.ts b/client/src/api.ts index 768e996c..09f357f8 100644 --- a/client/src/api.ts +++ b/client/src/api.ts @@ -356,6 +356,10 @@ export async function fetchUsers( welcomeSlideText disableMyGoalSlide disableFollowups + disableKeywordsRecommendation + disableThumbnailRecommendation + disableLevelProgressDisplay + completeSubjectsNotificationText } orgPermissions { orgId @@ -1072,6 +1076,10 @@ export async function fetchMentorById( welcomeSlideText disableMyGoalSlide disableFollowups + disableKeywordsRecommendation + disableThumbnailRecommendation + disableLevelProgressDisplay + completeSubjectsNotificationText } orgPermissions { orgId @@ -1244,6 +1252,10 @@ export async function fetchMentorConfig( welcomeSlideText disableMyGoalSlide disableFollowups + disableKeywordsRecommendation + disableThumbnailRecommendation + disableLevelProgressDisplay + completeSubjectsNotificationText } } `, diff --git a/client/src/components/home/index.tsx b/client/src/components/home/index.tsx index ee53587d..1ed03b52 100644 --- a/client/src/components/home/index.tsx +++ b/client/src/components/home/index.tsx @@ -155,6 +155,7 @@ function HomePage(props: { const mentorConfig: MentorConfig | undefined = getData( (m) => m.data?.mentorConfig ); + const lockedToConfig: boolean = getData((m) => m.data?.lockedToConfig); const defaultMentor = props.user.defaultMentor._id; const { classes } = useStyles(); const [showSetupAlert, setShowSetupAlert] = useState(true); @@ -190,7 +191,8 @@ function HomePage(props: { useState(); const [confirmSaveOnRecordOne, setConfirmSaveOnRecordOne] = useState(); - + const [notifyCompleteAllQuestions, setNotifyCompleteAllQuestions] = + useState(false); const loginState = useWithLogin(); const [localHasSeenSplash, setLocalHasSeenSplash] = useState(false); @@ -273,6 +275,26 @@ function HomePage(props: { mentorId, ]); + useEffect(() => { + const lockedToSubjects = mentorConfig?.subjects.length; + if ( + !lockedToConfig || + !mentorConfig || + !lockedToSubjects || + !mentorConfig.completeSubjectsNotificationText + ) { + return; + } + if ( + reviewAnswerState.progress.total != 0 && + reviewAnswerState.progress.complete === + reviewAnswerState.progress.total && + !notifyCompleteAllQuestions + ) { + setNotifyCompleteAllQuestions(true); + } + }, [reviewAnswerState.progress, mentorConfig, lockedToConfig]); + // memoized train mentor const startTrainingMentor = useCallback(() => { startTraining(mentorId); @@ -745,6 +767,14 @@ function HomePage(props: { + { + setNotifyCompleteAllQuestions(false); + }} + /> + ms.data ? parseMentor(ms.data, allQuestions) : defaultMentorInfo ); + const mentorConfig: MentorConfig | undefined = getData( + (ms) => ms.data?.mentorConfig + ); const leftColumnAlign = "left"; @@ -59,13 +63,14 @@ function MentorStatus(props: { - {mentorInfo.currentStage.floor != 1000 && ( - - )} + {mentorInfo.currentStage.floor != 1000 && + !mentorConfig?.disableLevelProgressDisplay && ( + + )} ); diff --git a/client/src/components/record/video-recorder.tsx b/client/src/components/record/video-recorder.tsx index 17563531..07eb2095 100644 --- a/client/src/components/record/video-recorder.tsx +++ b/client/src/components/record/video-recorder.tsx @@ -47,6 +47,7 @@ function VideoRecorder(props: { const canvasRef = useRef(null); const { segmentVideoAndDrawToCanvas } = useWithVideoSegmentation(); const { aspectRatio: vbgAspectRatio } = useWithImage(virtualBackgroundUrl); + const [uploadCounter, setUploaderCounter] = useState(0); const videoRecordMimeType = isVirtualBgMentor ? "video/webm;codecs=vp9" : "video/mp4"; @@ -525,10 +526,12 @@ function VideoRecorder(props: { {recordState.isRecording ? "Stop" : "Record"} { + setUploaderCounter((prevState) => prevState + 1); if (!e.target.files?.length) { return; } else { diff --git a/client/src/components/setup/welcome-slide.tsx b/client/src/components/setup/welcome-slide.tsx index 15c1e245..7d9d5075 100644 --- a/client/src/components/setup/welcome-slide.tsx +++ b/client/src/components/setup/welcome-slide.tsx @@ -55,8 +55,9 @@ export function WelcomeSlide(props: { > {"If you'd like to view a walkthrough, "} - click here. + click here + . } diff --git a/client/src/hooks/mentor-recommender/use-with-mentor-recommender.tsx b/client/src/hooks/mentor-recommender/use-with-mentor-recommender.tsx index c96a8f84..100ff4bb 100644 --- a/client/src/hooks/mentor-recommender/use-with-mentor-recommender.tsx +++ b/client/src/hooks/mentor-recommender/use-with-mentor-recommender.tsx @@ -102,7 +102,10 @@ export function useWithMentorRecommender( ); }; const keywordsMissing = (state: RecommenderState) => { - return !state.mentorData.keywords.length; + return ( + !state.mentorData.keywords.length && + !state.mentorData.mentorConfig?.disableKeywordsRecommendation + ); }; const noSubject = (state: RecommenderState) => { return !state.mentorData.subjects.length; @@ -138,7 +141,10 @@ export function useWithMentorRecommender( ); }; const thumbnailMissing = (state: RecommenderState) => { - return !state.mentorData.thumbnail; + return ( + !state.mentorData.thumbnail && + !state.mentorData.mentorConfig?.disableThumbnailRecommendation + ); }; // Note: All reccomendations have same weights in this phase, but other phases rec's have different weights @@ -724,7 +730,7 @@ export function useWithMentorRecommender( "Preview your mentor", RecommendationName.PREVIEW_MENTOR, "Preview your mentor to review its current status.", - () => launchMentor(mentorData?._id || "") + () => launchMentor(mentorData?._id || "", true) ); const activeCondition = (state: RecommenderState) => { const lastPreviewedDate = state.mentorData.lastPreviewedAt diff --git a/client/src/types-gql.ts b/client/src/types-gql.ts index 937094c0..4d81b8c0 100644 --- a/client/src/types-gql.ts +++ b/client/src/types-gql.ts @@ -64,6 +64,10 @@ export interface MentorConfig { welcomeSlideText: string; disableMyGoalSlide: boolean; disableFollowups: boolean; + disableKeywordsRecommendation: boolean; + disableThumbnailRecommendation: boolean; + disableLevelProgressDisplay: boolean; + completeSubjectsNotificationText: string; } export interface MentorGQL {