diff --git a/src/components/PageLayout/MenuMain/MenuMain.tsx b/src/components/PageLayout/MenuMain/MenuMain.tsx
index fac0abe9..deb6369d 100644
--- a/src/components/PageLayout/MenuMain/MenuMain.tsx
+++ b/src/components/PageLayout/MenuMain/MenuMain.tsx
@@ -10,7 +10,6 @@ import {CloseButton} from '@/components/CloseButton/CloseButton'
import {Loading} from '@/components/Loading/Loading'
import Menu from '@/svg/menu.svg'
import {MenuItemShort} from '@/types/api/cms'
-import {useDataFromURL} from '@/utils/useDataFromURL'
import {useHasPermissions} from '@/utils/useHasPermissions'
import {useSeminarInfo} from '@/utils/useSeminarInfo'
@@ -19,7 +18,6 @@ import styles from './MenuMain.module.scss'
export const MenuMain: FC = () => {
const {seminar, seminarId} = useSeminarInfo()
- const {id} = useDataFromURL()
const {hasPermissions} = useHasPermissions()
@@ -74,7 +72,7 @@ export const MenuMain: FC = () => {
{hasPermissions && (
-
+
)}
diff --git a/src/components/PageLayout/TopGrid/TopGrid.tsx b/src/components/PageLayout/TopGrid/TopGrid.tsx
index 6ed9e9e5..c7588de5 100644
--- a/src/components/PageLayout/TopGrid/TopGrid.tsx
+++ b/src/components/PageLayout/TopGrid/TopGrid.tsx
@@ -2,7 +2,7 @@ import {Stack, Typography} from '@mui/material'
import clsx from 'clsx'
import Link from 'next/link'
import {useRouter} from 'next/router'
-import {FC} from 'react'
+import {FC, useMemo} from 'react'
import {SemesterPicker} from '@/components/SemesterPicker/SemesterPicker'
import {PageTitleContainer} from '@/utils/PageTitleContainer'
@@ -15,7 +15,17 @@ export const TopGrid: FC = () => {
const {seminar} = useSeminarInfo()
// z napr. `/matik/zadania(/*)` vytiahne `zadania`
- const page = useRouter().pathname.split('/')[2]
+ const pathname = useRouter().pathname.split('/')
+
+ const semesterPickerPage = useMemo(() => {
+ if (pathname[2] === 'zadania' || pathname[2] === 'vysledky') {
+ return pathname[2]
+ }
+ if (pathname[2] === 'admin' && pathname[3] === 'opravovanie') {
+ return 'admin/opravovanie'
+ }
+ return undefined
+ }, [pathname])
const {pageTitle} = PageTitleContainer.useContainer()
@@ -42,9 +52,9 @@ export const TopGrid: FC = () => {
{pageTitle}
- {(page === 'zadania' || page === 'vysledky') && (
+ {semesterPickerPage && (
-
+
)}
diff --git a/src/components/ProblemAdministration/ProblemAdministration.module.scss b/src/components/ProblemAdministration/ProblemAdministration.module.scss
index 5ee195ec..95f6bbdc 100644
--- a/src/components/ProblemAdministration/ProblemAdministration.module.scss
+++ b/src/components/ProblemAdministration/ProblemAdministration.module.scss
@@ -1,16 +1,3 @@
-
-
-.container {
- display: flex;
- flex-direction: column;
- row-gap: 12px;
-}
-
-.rightButton{
- display: flex;
- justify-content: flex-end;
-}
-
.icon {
color: black;
}
diff --git a/src/components/ProblemAdministration/ProblemAdministration.module.scss.d.ts b/src/components/ProblemAdministration/ProblemAdministration.module.scss.d.ts
index b4e10a26..5886d69a 100644
--- a/src/components/ProblemAdministration/ProblemAdministration.module.scss.d.ts
+++ b/src/components/ProblemAdministration/ProblemAdministration.module.scss.d.ts
@@ -1,10 +1,8 @@
export type Styles = {
centerCell: string
- container: string
icon: string
iconDisabled: string
input: string
- rightButton: string
row: string
table: string
tableBody: string
diff --git a/src/components/ProblemAdministration/ProblemAdministration.tsx b/src/components/ProblemAdministration/ProblemAdministration.tsx
index fb58c232..fd34e535 100644
--- a/src/components/ProblemAdministration/ProblemAdministration.tsx
+++ b/src/components/ProblemAdministration/ProblemAdministration.tsx
@@ -1,12 +1,13 @@
import {FormatAlignJustify, Grading} from '@mui/icons-material'
-import {Typography} from '@mui/material'
+import {Stack, Typography} from '@mui/material'
import {useMutation, useQuery} from '@tanstack/react-query'
import axios from 'axios'
import {useRouter} from 'next/router'
import React, {FC, useCallback, useEffect, useState} from 'react'
import {DropzoneOptions, useDropzone} from 'react-dropzone'
-import {ProblemWithSolutions, SolutionAdministration} from '@/types/api/competition'
+import {ProblemWithSolutions, SemesterWithProblems, SolutionAdministration} from '@/types/api/competition'
+import {PageTitleContainer} from '@/utils/PageTitleContainer'
import {useHasPermissions} from '@/utils/useHasPermissions'
import {Button} from '../Clickable/Button'
@@ -20,6 +21,7 @@ import styles from './ProblemAdministration.module.scss'
export const ProblemAdministration: FC = () => {
const router = useRouter()
const {params} = router.query
+ const {setPageTitle} = PageTitleContainer.useContainer()
const problemId = params && params[0]
@@ -35,6 +37,21 @@ export const ProblemAdministration: FC = () => {
})
const problem = problemData?.data
+ const semesterId = problem?.series.semester
+ const {data: semesterData, isLoading: semesterIsLoading} = useQuery({
+ queryKey: ['competition', 'semester', semesterId],
+ queryFn: () => axios.get(`/api/competition/semester/${semesterId}`),
+ // router.query.params su v prvom renderi undefined, tak pustime query az so spravnym semesterId
+ enabled: semesterId !== undefined,
+ })
+ const semester = semesterData?.data
+ const semesterName = semester?.season_code === 0 ? 'zima' : 'leto'
+ const semesterUrl = `${semester?.year}/${semesterName}`
+
+ useEffect(() => {
+ !!problem && !!semester && setPageTitle(`${problem?.order}. úloha - ${semesterUrl} (${semester?.school_year})`)
+ }, [problem, semester, semesterUrl, setPageTitle])
+
const {hasPermissions, permissionsIsLoading} = useHasPermissions()
const [solutions, setSolutions] = useState()
@@ -91,7 +108,7 @@ export const ProblemAdministration: FC = () => {
},
})
- if (permissionsIsLoading || problemIsLoading) return
+ if (permissionsIsLoading || problemIsLoading || semesterIsLoading) return
if (!hasPermissions) return Nemáš oprávnenie na zobrazenie tejto stránky.
if (problemId === undefined || !problem)
return Nevalidné číslo úlohy (problemId) v URL alebo ju proste nevieme fetchnúť z BE.
@@ -99,14 +116,14 @@ export const ProblemAdministration: FC = () => {
const handleSavePoints = () => uploadPoints(problemId)
return (
-
-
Opravovanie {problem.order}. úlohy
+
+
+ Opravovanie {problem.order}. úlohy
-
-
+
Späť na semester
-
+
{problem.text ?? 'Načítavam...'}
@@ -129,11 +146,11 @@ export const ProblemAdministration: FC = () => {
/>
-
+
Stiahnuť riešenia
-
+
{
text="Vlož opravené riešenia vo formáte zip"
/>
-