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 toGroupIds = (courseIds: string[]) => courseIds.map(id => options.idToGroupIdMap[id]).filter(Boolean)
|
||||||
|
|
||||||
const passedCourseGroupIds = toGroupIds(
|
const passedCourseGroupIds = toGroupIds(
|
||||||
courses
|
courses.filter(({ credittypecode }) => credittypecode !== CreditTypeCode.FAILED).map(({ course_id }) => course_id)
|
||||||
.filter(({ credittypecode }) => credittypecode !== CreditTypeCode.FAILED)
|
|
||||||
.map(({ course_id }) => course_id)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const courseGroupIds = toGroupIds(courses.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 foundAttainment = false
|
||||||
let foundEnrollment = false
|
let foundEnrollment = false
|
||||||
|
|
||||||
;[
|
;[[mainGroupId], ...(options.includeSubstitutions ? (options.substitutedBy?.[mainGroupId] ?? []) : [])].forEach(
|
||||||
[mainGroupId],
|
group => {
|
||||||
...(options.includeSubstitutions ? (options.substitutedBy?.[mainGroupId] ?? []) : []),
|
foundPassed = foundPassed ? true : group.every(groupId => passedCourseGroupIds.includes(groupId))
|
||||||
].forEach(group => {
|
foundAttainment = foundAttainment ? true : group.every(groupId => courseGroupIds.includes(groupId))
|
||||||
foundPassed = foundPassed ? true : group.every(groupId => passedCourseGroupIds.includes(groupId))
|
foundEnrollment = foundEnrollment ? true : group.every(groupId => enrollmentGroupIds.includes(groupId))
|
||||||
foundAttainment = foundAttainment ? true : group.every(groupId => courseGroupIds.includes(groupId))
|
}
|
||||||
foundEnrollment = foundEnrollment ? true : group.every(groupId => enrollmentGroupIds.includes(groupId))
|
)
|
||||||
})
|
|
||||||
|
|
||||||
switch (filterType) {
|
switch (filterType) {
|
||||||
case FilterType.ALL:
|
case FilterType.ALL:
|
||||||
@@ -160,7 +157,8 @@ export const courseFilter = createFilter<Options, Args, Precompute>({
|
|||||||
|
|
||||||
selectors: {
|
selectors: {
|
||||||
// NOTE: Remember FilterType.ALL === 0 when checking if courseFilters[course] exists
|
// 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,
|
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 { isCourseSelected, toggleCourseSelection } from '@/components/FilterView/filters/courses'
|
||||||
import { useFilters } from '@/components/FilterView/useFilters'
|
import { useFilters } from '@/components/FilterView/useFilters'
|
||||||
|
|
||||||
export const CourseFilterToggle = ({
|
export const CourseFilterToggle = ({ courseGroupId, courseName }: { courseGroupId: string; courseName: string }) => {
|
||||||
courseGroupId,
|
|
||||||
courseName,
|
|
||||||
}: {
|
|
||||||
courseGroupId: string
|
|
||||||
courseName: string
|
|
||||||
}) => {
|
|
||||||
const { useFilterSelector, useFilterDispatch: filterDispatch } = useFilters()
|
const { useFilterSelector, useFilterDispatch: filterDispatch } = useFilters()
|
||||||
|
|
||||||
const isActive = useFilterSelector(isCourseSelected(courseGroupId))
|
const isActive = useFilterSelector(isCourseSelected(courseGroupId))
|
||||||
@@ -24,10 +18,7 @@ export const CourseFilterToggle = ({
|
|||||||
return (
|
return (
|
||||||
<Tooltip arrow placement="top" title={title}>
|
<Tooltip arrow placement="top" title={title}>
|
||||||
<div>
|
<div>
|
||||||
<FilterToggleIcon
|
<FilterToggleIcon isActive={isActive} onClick={() => filterDispatch(toggleCourseSelection(courseGroupId))} />
|
||||||
isActive={isActive}
|
|
||||||
onClick={() => filterDispatch(toggleCourseSelection(courseGroupId))}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -296,9 +296,10 @@ export const filterCourses = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Array.from(coursestats.values()).map((course): FilteredCourse =>
|
return Array.from(coursestats.values()).map(
|
||||||
Object.assign(course, {
|
(course): FilteredCourse =>
|
||||||
stats: getFinalStats(course, filteredStudents.length),
|
Object.assign(course, {
|
||||||
})
|
stats: getFinalStats(course, filteredStudents.length),
|
||||||
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user