diff --git a/client/src/Lessons/LessonsPage.tsx b/client/src/Lessons/LessonsPage.tsx index 13fc0068..876038d5 100644 --- a/client/src/Lessons/LessonsPage.tsx +++ b/client/src/Lessons/LessonsPage.tsx @@ -37,6 +37,7 @@ function LessonsPage() { const [addCardsWithImages, setAddCardsWithImages] = useState([]); const [lessonNumber, setLessonNumber] = useState(''); const [loading, setLoading] = useState(true); + const [errorMessage, setErrorMessage] = useState(''); useEffect(() => { const fetchResources = async () => { @@ -49,6 +50,17 @@ function LessonsPage() { resources = await getData(`coach/resources/${id}`); } + if (resources.error) { + if ( + resources.error.data.message.includes('connected to any students') + ) { + setErrorMessage('Coach is not connected to any students.'); + return; + } + setErrorMessage(resources.error.data.message); + return; + } + const lessonResources = resources?.data.resources || []; const addResources = resources?.data.additional_resources || []; const num = resources?.data.lesson_level || ''; @@ -94,6 +106,29 @@ function LessonsPage() { fetchResources(); }, [role, id]); + if (errorMessage) { + return ( + + + {errorMessage} + + + ); + } + if (loading) { return (