Skip to content

Commit

Permalink
Presun Diskusie do Dialogu (#452)
Browse files Browse the repository at this point in the history
* unrelated: Remove unused component

* Move all styles into one file

* unrelated: Remove css file with one class

* Remove .textarea style

* Remove another css class

* Remove another css class

* Restyle discussion header

* F*ck it, it will be dialog

* fix yarn lint

* some code polishing
  • Loading branch information
Matushl authored Nov 22, 2024
1 parent 20c7f0f commit 1cce86f
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 172 deletions.
12 changes: 0 additions & 12 deletions src/components/Overlay/Overlay.module.scss

This file was deleted.

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

This file was deleted.

24 changes: 0 additions & 24 deletions src/components/Overlay/Overlay.tsx

This file was deleted.

5 changes: 0 additions & 5 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.

22 changes: 13 additions & 9 deletions src/components/Problems/Discussion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import {useHasPermissions} from '@/utils/useHasPermissions'
import {Button} from '../Clickable/Button'
import {Dialog} from '../Dialog/Dialog'
import {Loading} from '../Loading/Loading'
import styles from './Discussion.module.scss'
import {SideContainer} from './SideContainer'

interface DiscussionProps {
problemId: number
Expand All @@ -21,7 +19,7 @@ interface DiscussionProps {
invalidateSeriesQuery: () => Promise<void>
}

export const Discussion: FC<DiscussionProps> = ({problemId, problemNumber, closeDiscussion, invalidateSeriesQuery}) => {
export const Discussion: FC<DiscussionProps> = ({problemId, invalidateSeriesQuery}) => {
const [commentText, setCommentText] = useState('')
const [hiddenResponseText, setHiddenResponseText] = useState('')
const [hiddenResponseDialogId, sethiddenResponseDialogId] = useState(-1)
Expand Down Expand Up @@ -101,7 +99,7 @@ export const Discussion: FC<DiscussionProps> = ({problemId, problemNumber, close
}

return (
<SideContainer title={'Diskusia - úloha ' + problemNumber} onClose={closeDiscussion}>
<>
{/* delete comment dialog */}
<Dialog
open={deleteDialogId !== undefined}
Expand All @@ -119,7 +117,7 @@ export const Discussion: FC<DiscussionProps> = ({problemId, problemNumber, close
</>
}
/>
<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 @@ -131,7 +129,9 @@ export const Discussion: FC<DiscussionProps> = ({problemId, problemNumber, close
<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 All @@ -149,7 +149,7 @@ export const Discussion: FC<DiscussionProps> = ({problemId, problemNumber, close
{hiddenResponseDialogId === comment.id ? (
<Stack my={1} gap={1}>
<textarea
className={styles.textArea}
style={{width: '100%', height: '60px', border: '3px solid black'}}
value={hiddenResponseText}
onChange={handleHiddenResponseChange}
/>
Expand Down Expand Up @@ -187,7 +187,11 @@ export const Discussion: FC<DiscussionProps> = ({problemId, problemNumber, close
<Stack gap={1}>
{isAuthed ? (
<>
<textarea className={styles.textArea} value={commentText} onChange={handleCommentChange} />
<textarea
style={{width: '100%', height: '60px', border: '3px solid black'}}
value={commentText}
onChange={handleCommentChange}
/>
<Stack alignSelf="end">
<Button variant="button2" onClick={() => addComment()}>
Odoslať
Expand All @@ -201,6 +205,6 @@ export const Discussion: FC<DiscussionProps> = ({problemId, problemNumber, close
)}
</Stack>
</Stack>
</SideContainer>
</>
)
}
17 changes: 0 additions & 17 deletions src/components/Problems/Problems.module.scss

This file was deleted.

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

This file was deleted.

29 changes: 16 additions & 13 deletions src/components/Problems/Problems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {Loading} from '../Loading/Loading'
import {LoginForm} from '../PageLayout/LoginForm/LoginForm'
import {Discussion} from './Discussion'
import {Problem} from './Problem'
import styles from './Problems.module.scss'

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

// used to display discussions
const [displaySideContent, setDisplaySideContent] = useState<{
const [displayDiscussion, setDisplayDiscussion] = useState<{
type: string
problemId: number
problemNumber: number
problemSubmitted?: boolean
}>({type: '', problemId: -1, problemNumber: -1, problemSubmitted: false})

const closeDiscussion = () => setDisplayDiscussion({type: '', problemId: -1, problemNumber: -1})

const {data: seriesData, isLoading: seriesIsLoading} = useQuery({
queryKey: ['competition', 'series', id.seriesId],
queryFn: () => axios.get<SeriesWithProblems>(`/api/competition/series/${id.seriesId}`),
Expand Down Expand Up @@ -187,7 +188,7 @@ export const Problems: FC = () => {
<Problem
key={problem.id}
problem={problem}
setDisplaySideContent={setDisplaySideContent}
setDisplaySideContent={setDisplayDiscussion}
registered={isRegistered}
canRegister={canRegister}
canSubmit={problem.submitted ? canResubmit : canSubmit}
Expand All @@ -198,16 +199,18 @@ export const Problems: FC = () => {
/>
))}
</Stack>
<div className={styles.sideContainer}>
{displaySideContent.type === 'discussion' && (
<Discussion
problemId={displaySideContent.problemId}
problemNumber={displaySideContent.problemNumber}
closeDiscussion={() => setDisplaySideContent({type: '', problemId: -1, problemNumber: -1})}
invalidateSeriesQuery={invalidateSeriesQuery}
/>
)}
</div>
<Dialog
open={displayDiscussion.type === 'discussion'}
close={closeDiscussion}
title={`Diskusia - úloha ${displayDiscussion.problemNumber}`}
>
<Discussion
problemId={displayDiscussion.problemId}
problemNumber={displayDiscussion.problemNumber}
closeDiscussion={closeDiscussion}
invalidateSeriesQuery={invalidateSeriesQuery}
/>
</Dialog>
</>
)
}
19 changes: 0 additions & 19 deletions src/components/Problems/SideContainer.module.scss

This file was deleted.

10 changes: 0 additions & 10 deletions src/components/Problems/SideContainer.module.scss.d.ts

This file was deleted.

21 changes: 0 additions & 21 deletions src/components/Problems/SideContainer.tsx

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {useHasPermissions} from '@/utils/useHasPermissions'
import {Loading} from '../Loading/Loading'
import {PublicationUploader} from '../PublicationUploader/PublicationUploader'
import {Result} from '../Results/ResultsRow'
import styles from './SemesterAdministration.module.scss'

interface PostalCard {
code: number
Expand Down Expand Up @@ -167,7 +166,7 @@ export const SemesterAdministration: FC = () => {

{textareaContent && (
<Stack mt={5} gap={2} alignItems="end">
<textarea rows={10} value={textareaContent} readOnly className={styles.textarea} />
<textarea rows={10} value={textareaContent} readOnly style={{width: '100%'}} />
<Button variant="button2" onClick={() => navigator.clipboard.writeText(textareaContent)}>
kopírovať
</Button>
Expand Down

0 comments on commit 1cce86f

Please sign in to comment.