Skip to content

Commit

Permalink
Merge pull request #309 from KTH/fix/KUI-1225/study-abroad-programme
Browse files Browse the repository at this point in the history
fix(KUI-1225): changed name of SAP course rounds
  • Loading branch information
vsdkth authored Mar 14, 2024
2 parents cdae8b2 + 122e911 commit 9c736fe
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 48 deletions.
1 change: 1 addition & 0 deletions i18n/messages.en.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ module.exports = {
ORD: 'programme students',
UPP: 'contract education',
PER: 'course for KTH staff',
SAP: 'Study Abroad Programme',
},
},
courseMainSubjects: {
Expand Down
1 change: 1 addition & 0 deletions i18n/messages.se.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ module.exports = {
ORD: 'programstuderande',
UPP: 'uppdragsutbildning',
PER: 'kurser för KTHs personal',
SAP: 'Study Abroad Programme',
},
},
courseImage: {
Expand Down
53 changes: 19 additions & 34 deletions public/js/app/components/DropdownRounds.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { INFORM_IF_IMPORTANT_INFO_IS_MISSING } from '../util/constants'
import { useWebContext } from '../context/WebContext'
import { createRoundLabel } from '../util/courseHeaderUtils'

const DropdownRounds = ({ courseRoundList, language = 0, label = '', translation }) => {
const [context, setWebContext] = useWebContext()
Expand Down Expand Up @@ -50,39 +50,24 @@ const DropdownRounds = ({ courseRoundList, language = 0, label = '', translation
{label.placeholder}
</option>
)
{courseRoundList.map(
(
{
round_short_name: roundShortName,
round_funding_type: fundingType,
round_category: roundCategory,
round_application_code: roundApplicationCode,
round_start_date: roundStartDate,
},
index
) => {
const isChosen = roundSelectedIndex - 1 === index
const optionLabel = `${
roundShortName !== INFORM_IF_IMPORTANT_INFO_IS_MISSING[language] ? `${roundShortName}` : ''
},${
fundingType === 'UPP' || fundingType === 'PER'
? translation.courseRoundInformation.round_type[fundingType]
: translation.courseRoundInformation.round_category[roundCategory]
}`
// Key must be unique, otherwise it will not update course rounds list for some courses, ex.FLH3000
const uniqueKey = `${optionLabel}${roundApplicationCode}${roundStartDate}`
return (
<option
key={uniqueKey}
id={dropdownID + '_' + index + '_0'}
defaultValue={isChosen}
value={optionLabel}
>
{optionLabel}
</option>
)
}
)}
{courseRoundList.map((round, index) => {
const isChosen = roundSelectedIndex - 1 === index
const optionLabel = createRoundLabel(language, round)

// Key must be unique, otherwise it will not update course rounds list for some courses, ex.FLH3000
const uniqueKey = `${optionLabel}${round.round_application_code}${round.round_start_date}`

return (
<option
key={uniqueKey}
id={dropdownID + '_' + index + '_0'}
defaultValue={isChosen}
value={optionLabel}
>
{optionLabel}
</option>
)
})}
</select>
</div>
</div>
Expand Down
21 changes: 7 additions & 14 deletions public/js/app/components/RoundInformationOneCol.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
import React from 'react'
import { Col } from 'reactstrap'
import { useWebContext } from '../context/WebContext'

import i18n from '../../../../i18n'
import { INFORM_IF_IMPORTANT_INFO_IS_MISSING } from '../util/constants'

import CourseFileLinks from './CourseFileLinks'
import InfoModal from './InfoModal'
import RoundApplicationInfo from './RoundApplicationInfo'
import { INFORM_IF_IMPORTANT_INFO_IS_MISSING } from '../util/constants'
import { createRoundHeader } from '../util/courseHeaderUtils'

const LABEL_MISSING_INFO = { en: INFORM_IF_IMPORTANT_INFO_IS_MISSING[0], sv: INFORM_IF_IMPORTANT_INFO_IS_MISSING[1] }

Expand All @@ -28,18 +27,12 @@ function RoundInformationOneCol({

const { roundSelectedIndex, activeSemester = '' } = context
const userLangIndex = language === 'en' ? 0 : 1
const { courseRoundInformation: translate, courseLabels: labels } = i18n.messages[userLangIndex]
const { courseRoundInformation: translate, courseLabels: labels, courseInformation } = i18n.messages[userLangIndex]

const roundHeader = translate.round_header
const selectedRoundHeader = `
${i18n.messages[userLangIndex].courseInformation.course_short_semester[round.round_course_term[1]]}
${round.round_course_term[0]}
${round.round_short_name !== LABEL_MISSING_INFO[language] ? round.round_short_name : ''}
${
round.round_funding_type === 'UPP' || round.round_funding_type === 'PER'
? translate.round_type[round.round_funding_type]
: translate.round_category[round.round_category]
}
`

const selectedRoundHeader = createRoundHeader(userLangIndex, round)

React.useEffect(() => {
const posibleTestEmployees = async () => {
if (testEmployees) {
Expand Down
27 changes: 27 additions & 0 deletions public/js/app/util/courseHeaderUtils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import i18n from '../../../../i18n'
import { INFORM_IF_IMPORTANT_INFO_IS_MISSING } from '../util/constants'

const LABEL_MISSING_INFO = { en: INFORM_IF_IMPORTANT_INFO_IS_MISSING[0], sv: INFORM_IF_IMPORTANT_INFO_IS_MISSING[1] }

export const createRoundLabel = (language, { round_short_name, round_funding_type, round_category }) => {
const translation = i18n.messages[language === 'en' ? 0 : 1]

let fundingType
if (round_funding_type === 'PER' || round_funding_type === 'UPP' || round_funding_type === 'SAP') {
fundingType = translation.courseRoundInformation.round_type[round_funding_type]
} else {
fundingType = translation.courseRoundInformation.round_category[round_category]
}
return ` ${round_short_name !== LABEL_MISSING_INFO[language] ? `${round_short_name}` : ''} ${fundingType}`
}

export const createRoundHeader = (
language,
{ round_short_name, round_funding_type, round_category, round_course_term },
courseInfo
// courseRoundInfo
) => {
const roundLabel = createRoundLabel(language, { round_short_name, round_funding_type, round_category })

return `${courseInfo?.course_short_semester[round_course_term[1]] ?? ''} ${round_course_term[0]}` + roundLabel
}

0 comments on commit 9c736fe

Please sign in to comment.