diff --git a/src/components/Archive/Archive.module.scss b/src/components/Archive/Archive.module.scss deleted file mode 100644 index c28df00b..00000000 --- a/src/components/Archive/Archive.module.scss +++ /dev/null @@ -1,25 +0,0 @@ -.archive { - margin-top: 5rem; - display: grid; - row-gap: 20px; -} - -.archiveRow { - display: grid; - grid-template-columns: 1fr auto; -} - -.eventName { - font-weight: bold; - font-style: italic; - text-transform: uppercase; - font-size: 16pt; -} - -.actions { - display: flex; - flex-direction: row; - align-items: center; - gap: 15px; - text-transform: uppercase; -} \ No newline at end of file diff --git a/src/components/Archive/Archive.module.scss.d.ts b/src/components/Archive/Archive.module.scss.d.ts deleted file mode 100644 index 833d7c87..00000000 --- a/src/components/Archive/Archive.module.scss.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -export type Styles = { - actions: string - archive: string - archiveRow: string - eventName: string -} - -export type ClassNames = keyof Styles - -declare const styles: Styles - -export default styles diff --git a/src/components/Archive/Archive.tsx b/src/components/Archive/Archive.tsx index 3b45c471..a91cdd35 100644 --- a/src/components/Archive/Archive.tsx +++ b/src/components/Archive/Archive.tsx @@ -1,3 +1,4 @@ +import {Stack, Typography} from '@mui/material' import {useQuery} from '@tanstack/react-query' import axios from 'axios' import {FC} from 'react' @@ -5,9 +6,8 @@ import {FC} from 'react' import {Event, Publication} from '@/types/api/competition' import {useSeminarInfo} from '@/utils/useSeminarInfo' -import {Link} from '../Clickable/Clickable' +import {Link} from '../Clickable/Link' import {Loading} from '../Loading/Loading' -import styles from './Archive.module.scss' // TODO: check whether we can safely assume presence of these and either update it on BE so it gets generated that way, or update it in our `types/api/competition` type MyPublication = Publication & { @@ -24,7 +24,7 @@ const PublicationButton: FC<{ publicationName: string }> = ({publicationId, publicationName}) => { return ( - + Časopis {publicationName} ) @@ -36,7 +36,11 @@ const ResultsButton: FC<{ }> = ({eventYear, eventSeason}) => { const season = eventSeason === 0 ? 'zima' : 'leto' const url = `../vysledky/${eventYear}/${season}` - return Výsledky + return ( + + Výsledky + + ) } const ProblemsButton: FC<{ @@ -45,7 +49,11 @@ const ProblemsButton: FC<{ }> = ({eventYear, eventSeason}) => { const season = eventSeason === 0 ? 'zima' : 'leto' const url = `../zadania/${eventYear}/${season}/1` - return Zadania + return ( + + Zadania + + ) } export const Archive: FC = () => { @@ -58,16 +66,16 @@ export const Archive: FC = () => { const eventList = eventListData?.data ?? [] return ( -
+ {eventListIsLoading && } {eventList.map((event) => ( -
- + + {event.year + '. ročník '} {event.season_code === 0 ? 'zimný' : 'letný'} {' semester'} - -
+ + {event.publication_set.map((publication) => ( @@ -77,9 +85,9 @@ export const Archive: FC = () => { publicationName={publication.name} /> ))} -
-
+
+ ))} -
+ ) } diff --git a/src/components/Clickable/Button.tsx b/src/components/Clickable/Button.tsx new file mode 100644 index 00000000..0102acfc --- /dev/null +++ b/src/components/Clickable/Button.tsx @@ -0,0 +1,27 @@ +import {Typography, TypographyProps} from '@mui/material' +import clsx from 'clsx' +import {ButtonHTMLAttributes, FC, ReactNode} from 'react' + +import styles from './Clickable.module.scss' + +type ButtonProps = { + onClick?: () => void + disabled?: boolean + children: ReactNode + variant?: TypographyProps['variant'] +} & Pick, 'type'> + +export const Button: FC = ({children, onClick, disabled, type, variant}) => { + return ( + + {children} + + ) +} diff --git a/src/components/Clickable/Clickable.tsx b/src/components/Clickable/Link.tsx similarity index 53% rename from src/components/Clickable/Clickable.tsx rename to src/components/Clickable/Link.tsx index 3ef98af9..b29f6fc2 100644 --- a/src/components/Clickable/Clickable.tsx +++ b/src/components/Clickable/Link.tsx @@ -1,42 +1,22 @@ -import {Typography} from '@mui/material' +import {Typography, TypographyProps} from '@mui/material' import clsx from 'clsx' import NextLink from 'next/link' -import {ButtonHTMLAttributes, ComponentProps, FC, ReactNode} from 'react' +import {ComponentProps, FC, ReactNode} from 'react' import styles from './Clickable.module.scss' -type ButtonProps = { - onClick?: () => void - disabled?: boolean - children: ReactNode -} & Pick, 'type'> - -export const Button: FC = ({children, onClick, disabled, type}) => { - return ( - - {children} - - ) -} - type LinkProps = { href?: string disabled?: boolean children: ReactNode + variant?: TypographyProps['variant'] } & Pick, 'target'> -export const Link: FC = ({children, href, disabled, target}) => { +export const Link: FC = ({children, href, disabled, target, variant}) => { // https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link return disabled ? ( = ({children, href, disabled, target}) => { ) : ( = ({ }) => { const {setBannerText} = BannerContainer.useContainer() - const startDate = upcoming_or_current_event ? formatDate(upcoming_or_current_event.start) : null - const endDate = upcoming_or_current_event ? formatDate(upcoming_or_current_event.end) : null + const startDate = upcoming_or_current_event ? formatDateTime(upcoming_or_current_event.start) : null + const endDate = upcoming_or_current_event ? formatDateTime(upcoming_or_current_event.end) : null setBannerText(startDate ? `${name} sa bude konať ${startDate}` : '') const router = useRouter() diff --git a/src/components/CompetitionPage/RulesPage.tsx b/src/components/CompetitionPage/RulesPage.tsx index 441f20fd..aa8676a5 100644 --- a/src/components/CompetitionPage/RulesPage.tsx +++ b/src/components/CompetitionPage/RulesPage.tsx @@ -3,14 +3,14 @@ import {FC} from 'react' import {Markdown} from '@/components/StaticSites/Markdown' import {Competition} from '@/types/api/generated/competition' import {BannerContainer} from '@/utils/BannerContainer' -import {formatDate} from '@/utils/formatDate' +import {formatDateTime} from '@/utils/formatDate' type RulesPageProps = Pick export const RulesPage: FC = ({name, rules, upcoming_or_current_event}) => { const {setBannerText} = BannerContainer.useContainer() - const startDate = formatDate(upcoming_or_current_event?.start) + const startDate = formatDateTime(upcoming_or_current_event?.start) setBannerText(upcoming_or_current_event ? `${name} sa bude konať ${startDate}` : '') return diff --git a/src/components/FormItems/Form.module.scss b/src/components/FormItems/Form.module.scss deleted file mode 100644 index b5a3f5eb..00000000 --- a/src/components/FormItems/Form.module.scss +++ /dev/null @@ -1,9 +0,0 @@ -.form { - display: grid; - gap: 1rem 0; - - >button { - font-size: 1.2rem; - justify-self: center; - } -} \ No newline at end of file diff --git a/src/components/FormItems/Form.module.scss.d.ts b/src/components/FormItems/Form.module.scss.d.ts deleted file mode 100644 index b3050633..00000000 --- a/src/components/FormItems/Form.module.scss.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export type Styles = { - form: string -} - -export type ClassNames = keyof Styles - -declare const styles: Styles - -export default styles diff --git a/src/components/Latex/Latex.tsx b/src/components/Latex/Latex.tsx index a62bc6fe..567ed67e 100644 --- a/src/components/Latex/Latex.tsx +++ b/src/components/Latex/Latex.tsx @@ -1,3 +1,4 @@ +import {Typography} from '@mui/material' import {MathComponentProps} from 'mathjax-react/dist/components/MathComponent' import dynamic from 'next/dynamic' import {FC, Fragment} from 'react' @@ -25,7 +26,7 @@ export const Latex: FC<{children: string}> = ({children}) => { const matches = Array.from(children.matchAll(re)) if (matches.length === 0) { - return <>{children} + return } const result = [] @@ -33,7 +34,7 @@ export const Latex: FC<{children: string}> = ({children}) => { for (const m of matches) { result.push( - , + , , ) @@ -42,7 +43,12 @@ export const Latex: FC<{children: string}> = ({children}) => { } } - result.push() + result.push( + , + ) return ( // nas globalny CSS reset nastavuje SVGcka na display:block, tak to tu resetneme nazad na inline diff --git a/src/components/Latex/LatexExample.tsx b/src/components/Latex/LatexExample.tsx index a6a4e949..0d43e359 100644 --- a/src/components/Latex/LatexExample.tsx +++ b/src/components/Latex/LatexExample.tsx @@ -1,6 +1,6 @@ import {ChangeEvent, FC, useState} from 'react' -import {Link} from '../Clickable/Clickable' +import {Link} from '../Clickable/Link' import {Latex} from './Latex' import styles from './LatexExample.module.scss' diff --git a/src/components/PageLayout/LoginForm/LoginForm.tsx b/src/components/PageLayout/LoginForm/LoginForm.tsx index c3af1884..0c6a14da 100644 --- a/src/components/PageLayout/LoginForm/LoginForm.tsx +++ b/src/components/PageLayout/LoginForm/LoginForm.tsx @@ -1,9 +1,9 @@ +import {Stack} from '@mui/material' import {useRouter} from 'next/router' import {FC} from 'react' import {SubmitHandler, useForm} from 'react-hook-form' -import {Button} from '@/components/Clickable/Clickable' -import styles from '@/components/FormItems/Form.module.scss' +import {Button} from '@/components/Clickable/Button' import {FormInput} from '@/components/FormItems/FormInput/FormInput' import {AuthContainer} from '@/utils/AuthContainer' @@ -41,21 +41,27 @@ export const LoginForm: FC = ({closeOverlay}) => { const requiredRule = {required: '* Toto pole nemôže byť prázdne.'} return ( -
- - - + + + + + + + + ) } diff --git a/src/components/Posts/Post.tsx b/src/components/Posts/Post.tsx index 185ec321..952a3b5b 100644 --- a/src/components/Posts/Post.tsx +++ b/src/components/Posts/Post.tsx @@ -1,9 +1,10 @@ import {Stack, Typography} from '@mui/material' import {FC} from 'react' +import {formatDate} from '@/utils/formatDate' import {useSeminarInfo} from '@/utils/useSeminarInfo' -import {Link} from '../Clickable/Clickable' +import {Link} from '../Clickable/Link' export interface IPost { id: number @@ -17,27 +18,31 @@ export interface IPost { sites: number[] } -export const Post: FC = ({id, caption, short_text, links, sites}) => { +export const Post: FC = ({id, caption, short_text, links, sites, added_at}) => { const {seminarId} = useSeminarInfo() if (!sites.includes(seminarId)) return null return ( -
  • - - {caption} - - + + {caption} + {short_text} - {/* alignItems so the links don't stretch */} - - {links.map(({id, url, caption}) => ( - - {caption} - - ))} + + {/* alignItems so the links don't stretch */} + + {links.map(({id, url, caption}) => ( + + {caption} + + ))} + + + + {formatDate(added_at)} + -
  • + ) } diff --git a/src/components/Posts/Posts.module.scss b/src/components/Posts/Posts.module.scss deleted file mode 100644 index 6ef7a842..00000000 --- a/src/components/Posts/Posts.module.scss +++ /dev/null @@ -1,7 +0,0 @@ -.postsList { - list-style: none; - padding-left: 0; - display: flex; - flex-direction: column; - gap: 40px; -} diff --git a/src/components/Posts/Posts.module.scss.d.ts b/src/components/Posts/Posts.module.scss.d.ts deleted file mode 100644 index 3578ddf8..00000000 --- a/src/components/Posts/Posts.module.scss.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -export type Styles = { - postsList: string -} - -export type ClassNames = keyof Styles - -declare const styles: Styles - -export default styles diff --git a/src/components/Posts/Posts.tsx b/src/components/Posts/Posts.tsx index f7a25dc3..dab23501 100644 --- a/src/components/Posts/Posts.tsx +++ b/src/components/Posts/Posts.tsx @@ -1,10 +1,10 @@ +import {Stack, Typography} from '@mui/material' import {useQuery} from '@tanstack/react-query' import axios from 'axios' import {FC} from 'react' import {Loading} from '../Loading/Loading' import {IPost, Post} from './Post' -import styles from './Posts.module.scss' export const Posts: FC = () => { const { @@ -17,15 +17,15 @@ export const Posts: FC = () => { }) const posts = postsData?.data ?? [] + if (postsIsLoading) return + + if (postsError) return {postsError.message} + return ( - <> - {postsIsLoading && } -
      - {posts.map((post) => ( - - ))} -
    - {postsError &&

    {postsError.message}

    } - + + {posts.map((post) => ( + + ))} + ) } diff --git a/src/components/ProblemAdministration/ProblemAdministration.tsx b/src/components/ProblemAdministration/ProblemAdministration.tsx index ad1d8d6f..025c6f70 100644 --- a/src/components/ProblemAdministration/ProblemAdministration.tsx +++ b/src/components/ProblemAdministration/ProblemAdministration.tsx @@ -9,7 +9,8 @@ import {DropzoneOptions, useDropzone} from 'react-dropzone' import {ProblemWithSolutions, SolutionAdministration} from '@/types/api/competition' import {useHasPermissions} from '@/utils/useHasPermissions' -import {Button, Link} from '../Clickable/Clickable' +import {Button} from '../Clickable/Button' +import {Link} from '../Clickable/Link' import {FileDropZone} from '../FileDropZone/FileDropZone' import {FileUploader} from '../FileUploader/FileUploader' import {Latex} from '../Latex/Latex' diff --git a/src/components/Problems/Discussion.module.scss b/src/components/Problems/Discussion.module.scss index 9c62ff19..17f1dbaa 100644 --- a/src/components/Problems/Discussion.module.scss +++ b/src/components/Problems/Discussion.module.scss @@ -1,74 +1,5 @@ -.container { - // lave a prave paddingy si poriesia children - margin-top: 8px; - margin-bottom: 8px; - flex-grow: 1; - display: flex; - flex-direction: column; - row-gap: 8px; - // potrebne, aby sa dodrzali parent hranice komponentu. overflow si div s komentarmi ohandli sam scrollbarom - overflow: hidden; - - >div.comments { - flex-grow: 1; - padding-left: 8px; - padding-right: 8px; - display: flex; - flex-direction: column; - row-gap: 4px; - // zobrazi scrollbar, ked ho treba - overflow-y: auto; - overscroll-behavior-y: contain; - } - >div.message { - padding-left: 8px; - padding-right: 8px; - color: gray; - } -} - -.inputContainer { - display: flex; - flex-direction: column; - row-gap: 8px; -} - -.submitInputContainer { - padding-left: 8px; - padding-right: 8px; - display: flex; - flex-direction: column; - row-gap: 8px; -} - .textArea { width: 100%; height: 60px; border: 3px solid black; -} - -.comment { - >div.title { - font-weight: bold; - font-style: italic; - text-transform: uppercase; - font-size: 1.2rem; - margin-top: 0px; - } - - .commentActions { - margin-top: 5px; - display: flex; - justify-content: flex-end; - column-gap: 8px; - } - - &.notPublished { - color: gray; - } -} - -.submitAction { - display: flex; - justify-content: flex-end; } \ No newline at end of file diff --git a/src/components/Problems/Discussion.module.scss.d.ts b/src/components/Problems/Discussion.module.scss.d.ts index 8ba48fb3..699c71a4 100644 --- a/src/components/Problems/Discussion.module.scss.d.ts +++ b/src/components/Problems/Discussion.module.scss.d.ts @@ -1,15 +1,5 @@ export type Styles = { - comment: string - commentActions: string - comments: string - container: string - inputContainer: string - message: string - notPublished: string - submitAction: string - submitInputContainer: string textArea: string - title: string } export type ClassNames = keyof Styles diff --git a/src/components/Problems/Discussion.tsx b/src/components/Problems/Discussion.tsx index aab0e5c1..d4390849 100644 --- a/src/components/Problems/Discussion.tsx +++ b/src/components/Problems/Discussion.tsx @@ -1,6 +1,6 @@ +import {Stack, Typography} from '@mui/material' import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' import axios from 'axios' -import clsx from 'clsx' import {FC, useState} from 'react' import {Comment, CommentState} from '@/types/api/competition' @@ -8,7 +8,7 @@ import {Profile} from '@/types/api/personal' import {AuthContainer} from '@/utils/AuthContainer' import {useHasPermissions} from '@/utils/useHasPermissions' -import {Button} from '../Clickable/Clickable' +import {Button} from '../Clickable/Button' import {Dialog} from '../Dialog/Dialog' import {Loading} from '../Loading/Loading' import styles from './Discussion.module.scss' @@ -109,78 +109,98 @@ export const Discussion: FC = ({problemId, problemNumber, close title="Vymazať komentár?" contentText="Komentár bude nenávratne vymazaný." actions={ - <> - - - + + + + } /> -
    -
    + + {commentsIsLoading && } {comments && comments.map((comment) => { const isPostedByMe = userId === comment.posted_by return ( -
    -
    -
    {comment.posted_by_name}
    -
    -
    {comment.text}
    + + + {comment.posted_by_name} + + {comment.text} {comment.hidden_response && ( - <> -
    -
    Vedúci:
    -
    -
    {comment.hidden_response}
    - + + + Vedúci: + + {comment.hidden_response} + + )} + {comment.state === CommentState.WaitingForReview && ( + * komentár čaká na schválenie + )} + {comment.state === CommentState.Hidden && ( + * tento komentár nie je verejný )} - {comment.state === CommentState.WaitingForReview &&
    * komentár čaká na schválenie
    } - {comment.state === CommentState.Hidden &&
    * tento komentár nie je verejný
    } {hiddenResponseDialogId === comment.id ? ( -
    +