mirror of
https://github.com/UniversityOfHelsinkiCS/oodikone.git
synced 2026-10-12 19:03:39 +03:00
[Frontend] Use same old/new programme filtering logic everywhere
This commit is contained in:
@@ -340,8 +340,6 @@ export const getSemesterCodeAt = (allSemesters?: SemestersData['semesters'], tar
|
||||
)?.semestercode
|
||||
}
|
||||
|
||||
export const isNewStudyProgramme = (programmeCode: string) => ['MH', 'KH', 'T9'].includes(programmeCode.slice(0, 2))
|
||||
|
||||
/**
|
||||
* Extracts items from a string separated by commas, semicolons, spaces, or newlines.
|
||||
* @param {string} input - The input string containing items.
|
||||
|
||||
@@ -6,7 +6,6 @@ import Switch from '@mui/material/Switch'
|
||||
import TextField from '@mui/material/TextField'
|
||||
import Typography from '@mui/material/Typography'
|
||||
|
||||
import { isNewStudyProgramme } from '@/common'
|
||||
import { ToggleablePin } from '@/components/common/toggle/ToggleablePin'
|
||||
import { InfoBox } from '@/components/InfoBox/InfoBoxWithTooltip'
|
||||
import { useLanguage } from '@/components/LanguagePicker/useLanguage'
|
||||
@@ -16,6 +15,7 @@ import { useGetProgrammesQuery } from '@/redux/populations'
|
||||
import { useGetStudyProgrammePinsQuery } from '@/redux/studyProgrammePins'
|
||||
import { PopulationSearchProgramme } from '@/types/populationSearch'
|
||||
import { createPinnedFirstComparator } from '@/util/comparator'
|
||||
import { isNewProgramme } from '@/util/studyProgramme'
|
||||
|
||||
type StudyProgrammeSelectorProps = {
|
||||
programme: PopulationSearchProgramme | null
|
||||
@@ -68,7 +68,7 @@ export const DegreeProgrammeSelector = ({
|
||||
|
||||
const programmeOptions: PopulationSearchProgramme[] = studyProgrammesAvailable
|
||||
? Object.values(degreeProgrammes)
|
||||
.filter(programme => !filterProgrammes || isNewStudyProgramme(programme.code))
|
||||
.filter(programme => !filterProgrammes || isNewProgramme(programme.code))
|
||||
.map(({ code, name }) => ({
|
||||
code,
|
||||
name: getTextIn(name),
|
||||
|
||||
@@ -17,6 +17,7 @@ import { useGetProgrammesQuery } from '@/redux/populations'
|
||||
import { useGetStudyProgrammePinsQuery } from '@/redux/studyProgrammePins'
|
||||
import { getCombinedProgrammeName } from '@/util/combinedProgramme'
|
||||
import { createLocaleComparator, createPinnedFirstComparator } from '@/util/comparator'
|
||||
import { isNewProgramme } from '@/util/studyProgramme'
|
||||
import { DegreeProgrammeType, Name, ProgrammeModuleWithRelevantAttributes } from '@oodikone/shared/types'
|
||||
import { StudyProgrammeFilter } from './StudyProgrammeFilter'
|
||||
import { StudyProgrammeTable } from './StudyProgrammeTable'
|
||||
@@ -96,7 +97,8 @@ export const StudyProgrammeSelector = () => {
|
||||
if (isDefaultServiceProvider() && programme.code.startsWith('2_')) {
|
||||
continue
|
||||
}
|
||||
if (!programme.curriculumPeriodIds.includes(currentCurriculumPeriod.id)) {
|
||||
|
||||
if (!isNewProgramme(programme.code)) {
|
||||
otherProgrammes.push(programme)
|
||||
} else if (programme.degreeProgrammeType === DegreeProgrammeType.BACHELOR) {
|
||||
bachelorProgrammes.push(programme)
|
||||
|
||||
@@ -16,7 +16,7 @@ import Typography from '@mui/material/Typography'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
|
||||
import { isDefaultServiceProvider, isNewStudyProgramme } from '@/common'
|
||||
import { isDefaultServiceProvider } from '@/common'
|
||||
import { userToolTips } from '@/common/InfoToolTips'
|
||||
import { FilterOldProgrammesToggle } from '@/components/common/FilterOldProgrammesToggle'
|
||||
import { InfoBox } from '@/components/InfoBox/InfoBoxWithTooltip'
|
||||
@@ -27,6 +27,7 @@ import { useAddUserUnitsMutation, useRemoveUserUnitsMutation } from '@/redux/use
|
||||
import { User } from '@/types/api/users'
|
||||
import { checkUserAccess } from '@/util/access'
|
||||
import { createLocaleComparator } from '@/util/comparator'
|
||||
import { isNewProgramme } from '@/util/studyProgramme'
|
||||
import { DetailedProgrammeRights } from '@oodikone/shared/types'
|
||||
import { CardHeader } from './CardHeader'
|
||||
import { EditButton } from './EditButton'
|
||||
@@ -76,7 +77,7 @@ export const StudyProgrammeRightsCard = ({ user }: { user: User }) => {
|
||||
.sort(createLocaleComparator('text'))
|
||||
|
||||
if (filterOldProgrammes) {
|
||||
options = options.filter(({ code }) => isNewStudyProgramme(code))
|
||||
options = options.filter(({ code }) => isNewProgramme(code))
|
||||
}
|
||||
|
||||
const currentRegularAccessRights = mapAndSortProgrammes(
|
||||
|
||||
Reference in New Issue
Block a user