Skip to content

Commit

Permalink
change semesterPicker to support admin/opravovanie
Browse files Browse the repository at this point in the history
  • Loading branch information
vikibrezinova committed Dec 10, 2023
1 parent 12a088a commit 67056c0
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/components/SemesterPicker/SemesterPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface SemesterListItem {
series_set: SeriesListItem[]
}

export const SemesterPicker: FC<{page: 'zadania' | 'vysledky'}> = ({page}) => {
export const SemesterPicker: FC<{page: 'zadania' | 'vysledky' | 'admin/opravovanie'}> = ({page}) => {
const {seminar} = useSeminarInfo()
const {setPageTitle} = PageTitleContainer.useContainer()

Expand All @@ -42,17 +42,27 @@ export const SemesterPicker: FC<{page: 'zadania' | 'vysledky'}> = ({page}) => {
let pageTitleToSet = ''
if (semester) {
const semesterTitle = `${semester?.year}. ročník - ${semester?.season_code === 0 ? 'zimný' : 'letný'} semester`
if (displayWholeSemesterOnResults) {
if (page === 'admin/opravovanie') {
pageTitleToSet = 'Opravovanie'
} else if (displayWholeSemesterOnResults) {
pageTitleToSet = semesterTitle
} else if (series) {
pageTitleToSet = `${semesterTitle}${series?.order ? ` - ${series?.order}. séria` : ''}`
}
}
setPageTitle(pageTitleToSet)
// `semester` a `series` su nami vytiahnute objekty, tak mozu triggerovat effekt kazdy render. nemalo by vadit
}, [displayWholeSemesterOnResults, semester, series, setPageTitle])
}, [displayWholeSemesterOnResults, semester, series, page, setPageTitle])

const dropdownSemesterList = semesterList.map((semester) => {
if (page === 'admin/opravovanie') {
return {
id: semester.id,
text: `${semester.year}. ročník - ${semester.season_code === 0 ? 'zimný' : 'letný'} semester`,
link: `/${seminar}/${page}/${semester.id}`,
selected: semester.id === selectedItem.semesterId,
}
}
return {
id: semester.id,
text: `${semester.year}. ročník - ${semester.season_code === 0 ? 'zimný' : 'letný'} semester`,
Expand Down Expand Up @@ -85,7 +95,7 @@ export const SemesterPicker: FC<{page: 'zadania' | 'vysledky'}> = ({page}) => {

return (
<div className={styles.menu}>
<Dropdown title={'Séria'} options={dropdownSeriesList} />
{page !== 'admin/opravovanie' && <Dropdown title={'Séria'} options={dropdownSeriesList} />}
<Dropdown title={'Semester'} options={dropdownSemesterList} />
</div>
)
Expand Down

0 comments on commit 67056c0

Please sign in to comment.