-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨(frontend) build page teacher dashboard classrooms
- Loading branch information
1 parent
d0f1071
commit dc048de
Showing
26 changed files
with
378 additions
and
40 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
src/frontend/js/pages/TeacherCourseClassroomsDashboardLoader/CourseRunSection/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { FormattedMessage, defineMessages, useIntl } from 'react-intl'; | ||
import { capitalize } from 'lodash-es'; | ||
import { CourseMock } from 'api/mocks/joanie/courses'; | ||
import { CourseRun } from 'types/Joanie'; | ||
import { DashboardCard } from 'widgets/Dashboard/components/DashboardCard'; | ||
import SyllabusLink from 'widgets/Dashboard/components/SyllabusLink'; | ||
import { getCourseUrl } from 'widgets/Dashboard/utils/course'; | ||
import CourseRunLabel, { | ||
CourseRunLabelVariantEnum, | ||
} from 'widgets/Dashboard/components/CourseRunLabel'; | ||
|
||
const messages = defineMessages({ | ||
syllabusLinkLabel: { | ||
defaultMessage: 'Access the course', | ||
description: 'Message displayed in classrooms page for the syllabus link label', | ||
id: 'components.TeacherCourseClassroomsDashboardLoader.syllabusLinkLabel', | ||
}, | ||
classroomPeriod: { | ||
defaultMessage: 'Session from {from} to {to}', | ||
description: 'Message displayed in classrooms page for classroom period', | ||
id: 'components.TeacherCourseClassroomsDashboardLoader.classroomPeriod', | ||
}, | ||
}); | ||
|
||
interface StudentsSectionProps { | ||
course: CourseMock; | ||
courseRun: CourseRun; | ||
} | ||
|
||
const CourseRunSection = ({ course, courseRun }: StudentsSectionProps) => { | ||
const intl = useIntl(); | ||
|
||
return ( | ||
<DashboardCard | ||
header={ | ||
<div className="teacher-course-page__course-title__container-small dashboard-card__header__left"> | ||
<h2 className="dashboard__title-h1 teacher-course-page__course-title dashboard-card__header__left"> | ||
{capitalize(course.title)} | ||
</h2> | ||
<SyllabusLink href={getCourseUrl(course.code, intl)}> | ||
<FormattedMessage {...messages.syllabusLinkLabel} /> | ||
</SyllabusLink> | ||
</div> | ||
} | ||
expandable={false} | ||
> | ||
{courseRun && ( | ||
<span> | ||
<CourseRunLabel courseRun={courseRun} variant={CourseRunLabelVariantEnum.DATE} /> | ||
</span> | ||
)} | ||
</DashboardCard> | ||
); | ||
}; | ||
export default CourseRunSection; |
31 changes: 31 additions & 0 deletions
31
src/frontend/js/pages/TeacherCourseClassroomsDashboardLoader/StudentsSection/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { FormattedMessage, defineMessages } from 'react-intl'; | ||
import { DashboardCard } from 'widgets/Dashboard/components/DashboardCard'; | ||
|
||
const messages = defineMessages({ | ||
loading: { | ||
defaultMessage: 'Loading classrooms ...', | ||
description: 'Message displayed while loading a classrooms', | ||
id: 'components.TeacherCourseClassroomsDashboardLoader.TeachersSection.loading', | ||
}, | ||
studentsListTitle: { | ||
defaultMessage: 'Learners registered for training', | ||
description: 'Message displayed in classrooms page as students section title', | ||
id: 'components.TeacherCourseClassroomsDashboardLoader.TeachersSection.studentsListTitle', | ||
}, | ||
}); | ||
|
||
const StudentsSection = () => { | ||
return ( | ||
<DashboardCard | ||
header={ | ||
<div className="teacher-course-page__course-title__container-small"> | ||
<h2 className="dashboard__title-h1 teacher-course-page__course-title "> | ||
<FormattedMessage {...messages.studentsListTitle} /> | ||
</h2> | ||
</div> | ||
} | ||
expandable={false} | ||
/> | ||
); | ||
}; | ||
export default StudentsSection; |
31 changes: 31 additions & 0 deletions
31
src/frontend/js/pages/TeacherCourseClassroomsDashboardLoader/TeachersSection/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { FormattedMessage, defineMessages } from 'react-intl'; | ||
import { DashboardCard } from 'widgets/Dashboard/components/DashboardCard'; | ||
|
||
const messages = defineMessages({ | ||
loading: { | ||
defaultMessage: 'Loading classrooms ...', | ||
description: 'Message displayed while loading a classrooms', | ||
id: 'components.TeacherCourseClassroomsDashboardLoader.StudentsSection.loading', | ||
}, | ||
teacherListTitle: { | ||
defaultMessage: 'Educational team', | ||
description: 'Message displayed in classrooms page as teacher section title', | ||
id: 'components.TeacherCourseClassroomsDashboardLoader.teacherListTitle', | ||
}, | ||
}); | ||
|
||
const StudentsSection = () => { | ||
return ( | ||
<DashboardCard | ||
header={ | ||
<div className="teacher-course-page__course-title__container-small"> | ||
<h2 className="dashboard__title-h1 teacher-course-page__course-title "> | ||
<FormattedMessage {...messages.teacherListTitle} /> | ||
</h2> | ||
</div> | ||
} | ||
expandable={false} | ||
/> | ||
); | ||
}; | ||
export default StudentsSection; |
Empty file.
71 changes: 71 additions & 0 deletions
71
src/frontend/js/pages/TeacherCourseClassroomsDashboardLoader/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { FormattedMessage, defineMessages } from 'react-intl'; | ||
import { useParams } from 'react-router-dom'; | ||
|
||
import { useMemo } from 'react'; | ||
import { DashboardLayout } from 'widgets/Dashboard/components/DashboardLayout'; | ||
import { TeacherCourseDashboardSidebar } from 'widgets/Dashboard/components/TeacherCourseDashboardSidebar'; | ||
import { useCourse } from 'hooks/useCourses'; | ||
import { Spinner } from 'components/Spinner'; | ||
import { CourseRun } from 'types/Joanie'; | ||
import CourseRunSection from './CourseRunSection'; | ||
import StudentsSection from './StudentsSection'; | ||
import TeachersSection from './TeachersSection'; | ||
|
||
const messages = defineMessages({ | ||
loading: { | ||
defaultMessage: 'Loading classrooms ...', | ||
description: 'Message displayed while loading a classrooms', | ||
id: 'components.TeacherCourseClassroomsDashboardLoader.loading', | ||
}, | ||
noCourseRun: { | ||
defaultMessage: "This course run does't exist", | ||
description: "Message displayed when requested classroom's course run doesn't exist", | ||
id: 'components.TeacherCourseClassroomsDashboardLoader.noCourseRun', | ||
}, | ||
}); | ||
|
||
export const TeacherCourseClassroomsDashboardLoader = () => { | ||
const { courseCode, courseRunId } = useParams<{ courseCode: string; courseRunId: string }>(); | ||
const { | ||
item: course, | ||
states: { fetching }, | ||
} = useCourse(courseCode!); | ||
const courseRun: CourseRun | undefined = useMemo( | ||
() => course?.course_runs.find((courseCourseRun) => courseCourseRun.id === courseRunId), | ||
[course, courseRunId], | ||
); | ||
|
||
return ( | ||
<DashboardLayout sidebar={<TeacherCourseDashboardSidebar />}> | ||
{fetching && ( | ||
<Spinner aria-labelledby="loading-teacher-course-classroom-data"> | ||
<span id="loading-teacher-course-classroom-data"> | ||
<FormattedMessage {...messages.loading} /> | ||
</span> | ||
</Spinner> | ||
)} | ||
|
||
{!fetching && courseRun === undefined && ( | ||
<p> | ||
<FormattedMessage {...messages.noCourseRun} /> | ||
</p> | ||
)} | ||
|
||
{!fetching && courseRun !== undefined && ( | ||
<div className="teacher-classroom-page"> | ||
<DashboardLayout.Section> | ||
<CourseRunSection course={course} courseRun={courseRun} /> | ||
</DashboardLayout.Section> | ||
|
||
<DashboardLayout.Section> | ||
<StudentsSection /> | ||
</DashboardLayout.Section> | ||
|
||
<DashboardLayout.Section> | ||
<TeachersSection /> | ||
</DashboardLayout.Section> | ||
</div> | ||
)} | ||
</DashboardLayout> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
src/frontend/js/pages/TeacherCourseDashboardLoader/CourseRunList/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 13 additions & 2 deletions
15
src/frontend/js/pages/TeacherCourseDashboardLoader/_styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,24 @@ | ||
.teacher-course-page { | ||
&__course-title { | ||
color: r-color(secondary-900); | ||
margin: rem-calc(17px) 0 rem-calc(22px); | ||
font-size: rem-calc(18px); | ||
font-weight: bold; | ||
display: flex; | ||
align-items: center; | ||
margin: 0; | ||
|
||
&__text { | ||
margin-left: rem-calc(8px); | ||
} | ||
|
||
&__container, | ||
&__container-small { | ||
margin: rem-calc(17px) 0 rem-calc(22px); | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
&__container-small { | ||
margin: rem-calc(9px) 0; | ||
} | ||
} | ||
} |
Oops, something went wrong.