Skip to content

Commit

Permalink
Корректное отображении ситуации, когда у студентов не прописаны группы
Browse files Browse the repository at this point in the history
  • Loading branch information
disturm committed May 4, 2024
1 parent 543a68d commit 373992b
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions src/components/work/GoogleTableFetch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,30 +105,43 @@ class GoogleTableFetch extends React.Component<Props, State> {
spreadsheetData: SpreadsheetData
): { allMissed: boolean; missedCount: number; disciplines: NestedItem[] } {
const actualGroups = Array.from(
new Set(
filterNull(
spreadsheetData.actualStudents.map((s) => s.groupName)
).filter((it) => it.length > 0)
)
new Set(spreadsheetData.actualStudents.map((s) => s.groupName || ""))
);
const availableGroups = Array.from(
new Set(availableDisciplines.map((s) => s.group))
);

let missedCount = 0;
const nestedItems: NestedItem[] = actualGroups.map((group) => {
const normalizedGroup = normalizeString(group);
const availableForActual = availableGroups.filter((it) =>
normalizeString(it).startsWith(normalizedGroup)
);

if (availableForActual.length === 0) {
missedCount++;
return [{ title: group, colored: true }];
} else {
return availableForActual.map((it) => ({ title: it, colored: false }));
}
}).flat();
const nestedItems: NestedItem[] = actualGroups
.map((group) => {
if (group.length > 0) {
const normalizedGroup = normalizeString(group);
const availableForActual = availableGroups.filter((it) =>
normalizeString(it).startsWith(normalizedGroup)
);

if (availableForActual.length === 0) {
missedCount++;
return [{ title: group, colored: true }];
} else {
return availableForActual.map((it) => ({
title: it,
colored: false,
}));
}
} else {
if (availableGroups.length === 0) {
missedCount++;
return [{ title: 'Автоопределение → нет вариантов', colored: true }];
} else {
return availableGroups.map((it) => ({
title: `Автоопределение → ${it}`,
colored: false,
}));
}
}
})
.flat();

const disciplineConfig = spreadsheetData.disciplineConfig;
const disciplineTime =
Expand Down

0 comments on commit 373992b

Please sign in to comment.