Skip to content

Commit

Permalink
Merge branch 'master' into 192-password-reset-2
Browse files Browse the repository at this point in the history
  • Loading branch information
vgeffer authored Dec 9, 2023
2 parents dff8b38 + 646e8cf commit 7eaa4e3
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/components/PageLayout/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export const Footer: FC = () => {
isLoading: menuItemsIsLoading,
error: menuItemsError,
} = useQuery({
queryKey: ['cms', 'menu-item', 'on-site', seminarId],
queryFn: () => axios.get<MenuItemShort[]>(`/api/cms/menu-item/on-site/${seminarId}`),
queryKey: ['cms', 'menu-item', 'on-site', seminarId, '?footer'],
queryFn: () => axios.get<MenuItemShort[]>(`/api/cms/menu-item/on-site/${seminarId}?type=footer`),
})
const menuItems = menuItemsData?.data ?? []

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const LoginFormWrapper: FC<LoginFormWrapperProps> = ({closeOverlay}) => {
</Stack>
</Stack>
</>

Check failure on line 37 in src/components/PageLayout/LoginFormWrapper/LoginFormWrapper.tsx

View workflow job for this annotation

GitHub Actions / branch-test

Delete `⏎⏎`

)

return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/PageLayout/MenuMain/MenuMain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const MenuMain: FC = () => {
const toggleMenu = () => setIsVisible((currentIsVisible) => !currentIsVisible)

const {data: menuItemsData, isLoading: menuItemsIsLoading} = useQuery({
queryKey: ['cms', 'menu-item', 'on-site', seminarId],
queryFn: () => axios.get<MenuItemShort[]>(`/api/cms/menu-item/on-site/${seminarId}`),
queryKey: ['cms', 'menu-item', 'on-site', seminarId, '?menu'],
queryFn: () => axios.get<MenuItemShort[]>(`/api/cms/menu-item/on-site/${seminarId}?type=menu`),
})
const menuItems = menuItemsData?.data ?? []

Expand Down
13 changes: 8 additions & 5 deletions src/components/Problems/Problem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const Problem: FC<{
isAfterDeadline: boolean
invalidateSeriesQuery: () => Promise<void>
displayRegisterDialog: () => void
displayLoginDialog: () => void
}> = ({
problem,
registered,
Expand All @@ -35,6 +36,7 @@ export const Problem: FC<{
isAfterDeadline,
invalidateSeriesQuery,
displayRegisterDialog,
displayLoginDialog,
}) => {
const handleDiscussionButtonClick = () => {
setDisplaySideContent((prevState) => {
Expand All @@ -45,9 +47,12 @@ export const Problem: FC<{
}
})
}

const handleUploadClick = () => {
if (!registered && canRegister) {
displayRegisterDialog()
} else if (!registered && !canRegister) {
displayLoginDialog()
} else {
setDisplayProblemUploadForm((prevState) => !prevState)
setDisplayActions(false)
Expand Down Expand Up @@ -114,11 +119,9 @@ export const Problem: FC<{
<Button onClick={handleDiscussionButtonClick} variant="button2">
diskusia ({problem.num_comments}){' '}
</Button>
{(registered || canRegister) && (
<Button onClick={handleUploadClick} disabled={!canSubmit} variant="button2">
odovzdať
</Button>
)}
<Button onClick={handleUploadClick} disabled={!canSubmit} variant="button2">
odovzdať
</Button>
</Stack>
)}
</div>
Expand Down
15 changes: 15 additions & 0 deletions src/components/Problems/Problems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {useHasPermissions} from '@/utils/useHasPermissions'

import {Dialog} from '../Dialog/Dialog'
import {Loading} from '../Loading/Loading'
import {LoginFormWrapper} from '../PageLayout/LoginFormWrapper/LoginFormWrapper'
import {Discussion} from './Discussion'
import {Problem} from './Problem'
import styles from './Problems.module.scss'
Expand Down Expand Up @@ -117,6 +118,9 @@ export const Problems: FC = () => {
closeRegisterDialog()
}

const [displayLoginDialog, setDisplayLoginDialog] = useState<boolean>(false)
const closeLoginDialog = () => setDisplayLoginDialog(false)

return (
<>
<Dialog
Expand Down Expand Up @@ -154,6 +158,16 @@ export const Problems: FC = () => {
</Stack>
}
/>
<Dialog
open={displayLoginDialog}
close={closeLoginDialog}
contentText={
<Stack alignItems={'center'} gap={3}>
<Typography variant="body1">Pre odovzdanie sa prihlás.</Typography>
<LoginFormWrapper closeOverlay={closeLoginDialog} />
</Stack>
}
/>
<Stack gap={5}>
{(loading.semesterListIsLoading ||
loading.currentSeriesIsLoading ||
Expand All @@ -177,6 +191,7 @@ export const Problems: FC = () => {
isAfterDeadline={isAfterDeadline}
invalidateSeriesQuery={invalidateSeriesQuery}
displayRegisterDialog={() => setDisplayRegisterDialog(true)}
displayLoginDialog={() => setDisplayLoginDialog(true)}
/>
))}

Expand Down
2 changes: 2 additions & 0 deletions src/types/api/cms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export interface MenuItemShort {
id: number
caption: string
url: string
in_footer: boolean
in_menu: boolean
}

export interface PostLink {
Expand Down

0 comments on commit 7eaa4e3

Please sign in to comment.