Compare commits

...

2 Commits

Author SHA1 Message Date
Primakov Alexandr Alexandrovich
ab9e5f6d19 3.6.3
All checks were successful
platform/bro-js/journal.pl/pipeline/head This commit looks good
2024-12-15 20:35:48 +03:00
Primakov Alexandr Alexandrovich
71d2f59750 teachers in Attendance 2024-12-15 20:35:39 +03:00
5 changed files with 45 additions and 3 deletions

4
package-lock.json generated
View File

@ -1,12 +1,12 @@
{ {
"name": "journal.pl", "name": "journal.pl",
"version": "3.6.2", "version": "3.6.3",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "journal.pl", "name": "journal.pl",
"version": "3.6.2", "version": "3.6.3",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@brojs/cli": "^0.0.4-beta.0", "@brojs/cli": "^0.0.4-beta.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "journal.pl", "name": "journal.pl",
"version": "3.6.2", "version": "3.6.3",
"description": "bro-js platform journal ui repo", "description": "bro-js platform journal ui repo",
"main": "./src/index.tsx", "main": "./src/index.tsx",
"scripts": { "scripts": {

View File

@ -53,10 +53,17 @@ export interface Lesson {
id: string; id: string;
name: string; name: string;
students: User[]; students: User[];
teachers: Teacher[];
date: string; date: string;
created: string; created: string;
} }
interface Teacher {
sub: string;
email_verified: boolean;
preferred_username: string;
}
export interface AccessCode { export interface AccessCode {
expires: string; expires: string;
lesson: Lesson; lesson: Lesson;

View File

@ -21,8 +21,15 @@ export const Attendance = () => {
if (!attendance) return null if (!attendance) return null
const studentsMap = new Map() const studentsMap = new Map()
const teachersMap = new Map()
attendance.forEach((lesson) => { attendance.forEach((lesson) => {
lesson.teachers?.map((teacher: any) => {
teachersMap.set(teacher.sub, { id: teacher.sub, ...teacher, value: teacher.value || (teacher.family_name && teacher.given_name
? `${teacher.family_name} ${teacher.given_name}`
: teacher.name || teacher.email || teacher.preferred_username || teacher.family_name || teacher.given_name), })
})
lesson.students.forEach((student) => { lesson.students.forEach((student) => {
const current = studentsMap.get(student.sub) || {} const current = studentsMap.get(student.sub) || {}
@ -39,11 +46,13 @@ export const Attendance = () => {
const compare = Intl.Collator('ru').compare const compare = Intl.Collator('ru').compare
const students = [...studentsMap.values()] const students = [...studentsMap.values()]
const taechers = [...teachersMap.values()]
students.sort(({ family_name: name }, { family_name: nname }) => students.sort(({ family_name: name }, { family_name: nname }) =>
compare(name, nname), compare(name, nname),
) )
return { return {
students, students,
taechers,
} }
}, [attendance]) }, [attendance])
@ -60,6 +69,9 @@ export const Attendance = () => {
<table> <table>
<thead> <thead>
<tr> <tr>
{data.taechers.map(teacher => (
<th id={teacher.id} key={teacher.id}>{teacher.value}</th>
))}
<th>Дата</th> <th>Дата</th>
<th>Название занятия</th> <th>Название занятия</th>
{data.students.map((student) => ( {data.students.map((student) => (
@ -70,6 +82,22 @@ export const Attendance = () => {
<tbody> <tbody>
{attendance.map((lesson, index) => ( {attendance.map((lesson, index) => (
<tr key={lesson.name}> <tr key={lesson.name}>
{data?.taechers?.map((teacher) => {
const wasThere = Boolean(lesson.teachers) &&
lesson?.teachers?.findIndex((u) => u.sub === teacher.sub) !== -1
return (
<td
style={{
textAlign: 'center',
backgroundColor: wasThere ? '#8ef78a' : '#e09797',
}}
key={teacher.sub}
>
{wasThere ? '+' : '-'}
</td>
)
})}
<td>{dayjs(lesson.date).format('DD.MM.YYYY')}</td> <td>{dayjs(lesson.date).format('DD.MM.YYYY')}</td>
<td>{<ShortText text={lesson.name} />}</td> <td>{<ShortText text={lesson.name} />}</td>

View File

@ -4,6 +4,13 @@
{ {
"_id": "65e2e5fbec37fec650f28489", "_id": "65e2e5fbec37fec650f28489",
"name": "ВВЕДЕНИЕ В ВЕБ-РАЗРАБОТКУ. ИНСТРУМЕНТАРИЙ, ОБЗОР ВЕБ-ТЕХНОЛОГИЙ", "name": "ВВЕДЕНИЕ В ВЕБ-РАЗРАБОТКУ. ИНСТРУМЕНТАРИЙ, ОБЗОР ВЕБ-ТЕХНОЛОГИЙ",
"teachers": [
{
"sub": "f62905b1-e223-40ca-910f-c8d84c6137c1",
"email_verified": true,
"preferred_username": "primakov"
}
],
"students": [ "students": [
{ {
"sub": "fcde3f22-d9ba-412a-a572-c59e515a290f", "sub": "fcde3f22-d9ba-412a-a572-c59e515a290f",