-
Notifications
You must be signed in to change notification settings - Fork 85
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
bc329b4
commit e340b88
Showing
18 changed files
with
251 additions
and
28 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
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={ | ||
<h2 className="teacher-course-page__course-title"> | ||
<FormattedMessage {...messages.teacherListTitle} /> | ||
</h2> | ||
} | ||
expandable={false} | ||
/> | ||
); | ||
}; | ||
export default StudentsSection; |
29 changes: 29 additions & 0 deletions
29
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,29 @@ | ||
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 TeachersSection = () => { | ||
return ( | ||
<DashboardCard | ||
header={ | ||
<h2 className="teacher-course-page__course-title"> | ||
<FormattedMessage {...messages.studentsListTitle} /> | ||
</h2> | ||
} | ||
expandable={false} | ||
/> | ||
); | ||
}; | ||
export default TeachersSection; |
99 changes: 99 additions & 0 deletions
99
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,99 @@ | ||
import { FormattedMessage, defineMessages, useIntl } from 'react-intl'; | ||
import { useParams } from 'react-router-dom'; | ||
|
||
import { capitalize } from 'lodash-es'; | ||
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 { DashboardCard } from 'widgets/Dashboard/components/DashboardCard'; | ||
import { Icon, IconTypeEnum } from 'components/Icon'; | ||
import { CourseRun } from 'types/Joanie'; | ||
import SyllabusLink from 'widgets/Dashboard/components/SyllabusLink'; | ||
import { getCourseUrl } from 'widgets/Dashboard/utils/course'; | ||
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', | ||
}, | ||
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', | ||
}, | ||
}); | ||
|
||
export const TeacherCourseClassroomsDashboardLoader = () => { | ||
const intl = useIntl(); | ||
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-courses-data"> | ||
<span id="loading-courses-data"> | ||
<FormattedMessage {...messages.loading} /> | ||
</span> | ||
</Spinner> | ||
) : ( | ||
<> | ||
<DashboardLayout.Section> | ||
<DashboardCard | ||
header={ | ||
<h2 className="teacher-course-page__course-title"> | ||
<span className="teacher-course-page__course-title__text"> | ||
{capitalize(course.title)} | ||
</span> | ||
|
||
<SyllabusLink href={getCourseUrl(course.code, intl)}> | ||
<FormattedMessage {...messages.syllabusLinkLabel} /> | ||
</SyllabusLink> | ||
</h2> | ||
} | ||
expandable={false} | ||
> | ||
{courseRun && ( | ||
<> | ||
<Icon name={IconTypeEnum.CAMERA} /> | ||
<FormattedMessage | ||
{...messages.classroomPeriod} | ||
values={{ | ||
from: intl.formatDate(new Date(courseRun.start)), | ||
to: intl.formatDate(new Date(courseRun.end)), | ||
}} | ||
/> | ||
</> | ||
)} | ||
</DashboardCard> | ||
</DashboardLayout.Section> | ||
|
||
<DashboardLayout.Section> | ||
<StudentsSection /> | ||
</DashboardLayout.Section> | ||
|
||
<DashboardLayout.Section> | ||
<TeachersSection /> | ||
</DashboardLayout.Section> | ||
</> | ||
)} | ||
</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
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
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
File renamed without changes.
15 changes: 15 additions & 0 deletions
15
src/frontend/js/widgets/Dashboard/components/SyllabusLink/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,15 @@ | ||
import { PropsWithChildren } from 'react'; | ||
import { Icon, IconTypeEnum } from 'components/Icon'; | ||
|
||
interface SyllabusLinkProps extends PropsWithChildren { | ||
href: string; | ||
} | ||
|
||
const SyllabusLink = ({ href, children }: SyllabusLinkProps) => ( | ||
<a className="syllabus-link" href={href}> | ||
<Icon name={IconTypeEnum.LOGOUT_SQUARE} /> | ||
<span>{children}</span> | ||
</a> | ||
); | ||
|
||
export default SyllabusLink; |
Oops, something went wrong.