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

Presun Diskusie do Dialogu #452

Merged
merged 10 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 0 additions & 10 deletions src/components/Problems/Discussion.module.scss

This file was deleted.

9 changes: 0 additions & 9 deletions src/components/Problems/Discussion.module.scss.d.ts

This file was deleted.

31 changes: 6 additions & 25 deletions src/components/Problems/Discussion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import {useHasPermissions} from '@/utils/useHasPermissions'

import {Button} from '../Clickable/Button'
import {CloseButton} from '../CloseButton/CloseButton'

Check warning on line 12 in src/components/Problems/Discussion.tsx

View workflow job for this annotation

GitHub Actions / branch-test

'CloseButton' is defined but never used
import {Dialog} from '../Dialog/Dialog'
import {Loading} from '../Loading/Loading'

Expand All @@ -20,14 +20,14 @@
invalidateSeriesQuery: () => Promise<void>
}

export const Discussion: FC<DiscussionProps> = ({problemId, problemNumber, closeDiscussion, invalidateSeriesQuery}) => {

Check warning on line 23 in src/components/Problems/Discussion.tsx

View workflow job for this annotation

GitHub Actions / branch-test

'problemNumber' is defined but never used. Allowed unused args must match /^_/u

Check warning on line 23 in src/components/Problems/Discussion.tsx

View workflow job for this annotation

GitHub Actions / branch-test

'closeDiscussion' is defined but never used. Allowed unused args must match /^_/u
const [commentText, setCommentText] = useState('')
const [hiddenResponseText, setHiddenResponseText] = useState('')
const [hiddenResponseDialogId, sethiddenResponseDialogId] = useState(-1)
const [deleteDialogId, setDeleteDialogId] = useState<number | undefined>()

const lg = useMediaQuery<Theme>((theme) => theme.breakpoints.up('lg'))
const iconSize = lg ? 24 : 14

Check warning on line 30 in src/components/Problems/Discussion.tsx

View workflow job for this annotation

GitHub Actions / branch-test

'iconSize' is assigned a value but never used

const queryKey = ['competition', 'problem', problemId, 'comments']
const {data: commentsData, isLoading: commentsIsLoading} = useQuery({
Expand Down Expand Up @@ -103,28 +103,7 @@
}

return (
<Stack
sx={{
border: '8px solid black',
backgroundColor: 'white',
overflow: 'hidden',
maxHeight: '100%',
}}
>
<Stack
direction="row"
sx={{
justifyContent: 'space-between',
alignItems: 'center',
px: 0.5,
pb: 1,
color: 'white',
backgroundColor: 'black',
}}
>
<Typography variant="h3">Diskusia - úloha {problemNumber}</Typography>
<CloseButton onClick={closeDiscussion} size={iconSize} />
</Stack>
<>
{/* delete comment dialog */}
<Dialog
open={deleteDialogId !== undefined}
Expand All @@ -142,7 +121,7 @@
</>
}
/>
<Stack my={1} mx={2} gap={1} sx={{overflow: 'hidden'}}>
<Stack gap={1} sx={{overflow: 'hidden'}}>
<Stack gap={1} sx={{overflowY: 'auto', overscrollBehaviorY: 'contain'}}>
{commentsIsLoading && <Loading />}
{comments &&
Expand All @@ -154,7 +133,9 @@
<Typography variant="h3" component="span">
{comment.posted_by_name}
</Typography>
<Typography variant="body1">{comment.text}</Typography>
<Typography variant="body1" style={{wordBreak: 'break-word'}}>
{comment.text}
</Typography>
{comment.hidden_response && (
<Stack ml={2}>
<Typography variant="h3" component="span">
Expand Down Expand Up @@ -228,6 +209,6 @@
)}
</Stack>
</Stack>
</Stack>
</>
)
}
21 changes: 13 additions & 8 deletions src/components/Problems/Problems.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {Stack, Typography} from '@mui/material'
import Grid from '@mui/material/Unstable_Grid2'

Check warning on line 2 in src/components/Problems/Problems.tsx

View workflow job for this annotation

GitHub Actions / branch-test

'Grid' is defined but never used
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
import axios from 'axios'
import {useRouter} from 'next/router'
Expand All @@ -18,8 +19,8 @@
import {Loading} from '../Loading/Loading'
import {LoginForm} from '../PageLayout/LoginForm/LoginForm'
import {Discussion} from './Discussion'
// import styles from './Discussion.module.scss'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dajaky bordel, a unused veci tu a hlavne aj v Discussion.tsx

import {Problem} from './Problem'
import styles from './Problems.module.scss'

export const Problems: FC = () => {
const {id, seminar, loading} = useDataFromURL()
Expand All @@ -37,7 +38,7 @@
const profile = data?.data

// used to display discussions
const [displaySideContent, setDisplaySideContent] = useState<{
const [displayDiscussion, setDisplayDiscussion] = useState<{
type: string
problemId: number
problemNumber: number
Expand Down Expand Up @@ -187,7 +188,7 @@
<Problem
key={problem.id}
problem={problem}
setDisplaySideContent={setDisplaySideContent}
setDisplaySideContent={setDisplayDiscussion}
registered={isRegistered}
canRegister={canRegister}
canSubmit={problem.submitted ? canResubmit : canSubmit}
Expand All @@ -198,14 +199,18 @@
/>
))}
</Stack>
{displaySideContent.type === 'discussion' && (
<Dialog
open={displayDiscussion.type === 'discussion'}
close={() => setDisplayDiscussion({type: '', problemId: -1, problemNumber: -1})}
title={`Diskusia - úloha ${displayDiscussion.problemNumber}`}
>
<Discussion
problemId={displaySideContent.problemId}
problemNumber={displaySideContent.problemNumber}
closeDiscussion={() => setDisplaySideContent({type: '', problemId: -1, problemNumber: -1})}
problemId={displayDiscussion.problemId}
problemNumber={displayDiscussion.problemNumber}
closeDiscussion={() => setDisplayDiscussion({type: '', problemId: -1, problemNumber: -1})}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

() => setDisplayDiscussion({type: '', problemId: -1, problemNumber: -1}) by som extrahoval, kedze je to pouzite dvakrat

invalidateSeriesQuery={invalidateSeriesQuery}
/>
)}
</Dialog>
</>
)
}
Loading