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 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
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 @@ -166,7 +165,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
Loading