Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Semester picker in administration #316

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.textarea {
width: 100%;
}

.semesterPicker {
display: flex;
justify-content: flex-end;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export type Styles = {
semesterPicker: string
textarea: string
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {FC, useState} from 'react'

import {Button} from '@/components/Clickable/Button'
import {Link} from '@/components/Clickable/Link'
import {SemesterPicker} from '@/components/SemesterPicker/SemesterPicker'
import {SemesterWithProblems} from '@/types/api/generated/competition'
import {formatDateTime} from '@/utils/formatDate'
import {useHasPermissions} from '@/utils/useHasPermissions'
Expand Down Expand Up @@ -95,6 +96,9 @@ export const SemesterAdministration: FC = () => {

return (
<>
<div className={styles.semesterPicker}>
<SemesterPicker page="admin/opravovanie" />
</div>
<Typography variant="h1">
{semester.year}. ročník ({semester.school_year}) - {semester.season_code === 0 ? 'zima' : 'leto'}
</Typography>
Expand Down
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
Loading