mirror of
https://github.com/UniversityOfHelsinkiCS/oodikone.git
synced 2026-10-12 19:03:39 +03:00
[Format] Format fixes
This commit is contained in:
@@ -117,9 +117,7 @@ export const courseFilter = createFilter<Options, Args, Precompute>({
|
||||
const toGroupIds = (courseIds: string[]) => courseIds.map(id => options.idToGroupIdMap[id]).filter(Boolean)
|
||||
|
||||
const passedCourseGroupIds = toGroupIds(
|
||||
courses
|
||||
.filter(({ credittypecode }) => credittypecode !== CreditTypeCode.FAILED)
|
||||
.map(({ course_id }) => course_id)
|
||||
courses.filter(({ credittypecode }) => credittypecode !== CreditTypeCode.FAILED).map(({ course_id }) => course_id)
|
||||
)
|
||||
|
||||
const courseGroupIds = toGroupIds(courses.map(({ course_id }) => course_id))
|
||||
@@ -130,14 +128,13 @@ export const courseFilter = createFilter<Options, Args, Precompute>({
|
||||
let foundAttainment = false
|
||||
let foundEnrollment = false
|
||||
|
||||
;[
|
||||
[mainGroupId],
|
||||
...(options.includeSubstitutions ? (options.substitutedBy?.[mainGroupId] ?? []) : []),
|
||||
].forEach(group => {
|
||||
;[[mainGroupId], ...(options.includeSubstitutions ? (options.substitutedBy?.[mainGroupId] ?? []) : [])].forEach(
|
||||
group => {
|
||||
foundPassed = foundPassed ? true : group.every(groupId => passedCourseGroupIds.includes(groupId))
|
||||
foundAttainment = foundAttainment ? true : group.every(groupId => courseGroupIds.includes(groupId))
|
||||
foundEnrollment = foundEnrollment ? true : group.every(groupId => enrollmentGroupIds.includes(groupId))
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
switch (filterType) {
|
||||
case FilterType.ALL:
|
||||
@@ -160,7 +157,8 @@ export const courseFilter = createFilter<Options, Args, Precompute>({
|
||||
|
||||
selectors: {
|
||||
// NOTE: Remember FilterType.ALL === 0 when checking if courseFilters[course] exists
|
||||
isCourseSelected: ({ courseFilters }, courseGroupId) => Object.values(FilterType).includes(courseFilters[courseGroupId]),
|
||||
isCourseSelected: ({ courseFilters }, courseGroupId) =>
|
||||
Object.values(FilterType).includes(courseFilters[courseGroupId]),
|
||||
selectedCourseName: ({ courses }, courseGroupIds) => courses[courseGroupIds[0]]?.name,
|
||||
},
|
||||
|
||||
|
||||
@@ -4,13 +4,7 @@ import { FilterToggleIcon } from '@/components/common/FilterToggleIcon'
|
||||
import { isCourseSelected, toggleCourseSelection } from '@/components/FilterView/filters/courses'
|
||||
import { useFilters } from '@/components/FilterView/useFilters'
|
||||
|
||||
export const CourseFilterToggle = ({
|
||||
courseGroupId,
|
||||
courseName,
|
||||
}: {
|
||||
courseGroupId: string
|
||||
courseName: string
|
||||
}) => {
|
||||
export const CourseFilterToggle = ({ courseGroupId, courseName }: { courseGroupId: string; courseName: string }) => {
|
||||
const { useFilterSelector, useFilterDispatch: filterDispatch } = useFilters()
|
||||
|
||||
const isActive = useFilterSelector(isCourseSelected(courseGroupId))
|
||||
@@ -24,10 +18,7 @@ export const CourseFilterToggle = ({
|
||||
return (
|
||||
<Tooltip arrow placement="top" title={title}>
|
||||
<div>
|
||||
<FilterToggleIcon
|
||||
isActive={isActive}
|
||||
onClick={() => filterDispatch(toggleCourseSelection(courseGroupId))}
|
||||
/>
|
||||
<FilterToggleIcon isActive={isActive} onClick={() => filterDispatch(toggleCourseSelection(courseGroupId))} />
|
||||
</div>
|
||||
</Tooltip>
|
||||
)
|
||||
|
||||
@@ -296,7 +296,8 @@ export const filterCourses = (
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(coursestats.values()).map((course): FilteredCourse =>
|
||||
return Array.from(coursestats.values()).map(
|
||||
(course): FilteredCourse =>
|
||||
Object.assign(course, {
|
||||
stats: getFinalStats(course, filteredStudents.length),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user