From 4ffaf96d6a5cf3b6f6d650d2ef0503ad2bcb73fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vikt=C3=B3ria=20Brezinov=C3=A1?= Date: Sat, 13 Apr 2024 01:01:36 +0200 Subject: [PATCH 1/2] fix upload problem permission --- src/components/Problems/Problem.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/Problems/Problem.tsx b/src/components/Problems/Problem.tsx index fca9aefb..5d5d3dae 100644 --- a/src/components/Problems/Problem.tsx +++ b/src/components/Problems/Problem.tsx @@ -5,6 +5,7 @@ import {Dispatch, FC, SetStateAction, useState} from 'react' import {Button} from '@/components/Clickable/Button' import {Link} from '@/components/Clickable/Link' import {Problem as ProblemType} from '@/types/api/competition' +import {AuthContainer} from '@/utils/AuthContainer' import {Latex} from '../Latex/Latex' import styles from './Problem.module.scss' @@ -47,13 +48,14 @@ export const Problem: FC<{ } }) } + const {isAuthed} = AuthContainer.useContainer() const handleUploadClick = () => { - if (!registered && canRegister) { - displayRegisterDialog() - } else if (!registered && !canRegister) { + if (!isAuthed) { displayLoginDialog() - } else { + } else if (!registered && canRegister) { + displayRegisterDialog() + } else if (registered) { setDisplayProblemUploadForm((prevState) => !prevState) setDisplayActions(false) } @@ -119,7 +121,7 @@ export const Problem: FC<{ - From 39a63c24aab00bef4ab0113c4f333174d4d31b3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vikt=C3=B3ria=20Brezinov=C3=A1?= Date: Sat, 13 Apr 2024 10:14:27 +0200 Subject: [PATCH 2/2] fix disabled when not authed --- src/components/Problems/Problem.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Problems/Problem.tsx b/src/components/Problems/Problem.tsx index 5d5d3dae..3554cda1 100644 --- a/src/components/Problems/Problem.tsx +++ b/src/components/Problems/Problem.tsx @@ -53,9 +53,9 @@ export const Problem: FC<{ const handleUploadClick = () => { if (!isAuthed) { displayLoginDialog() - } else if (!registered && canRegister) { + } else if (!registered) { displayRegisterDialog() - } else if (registered) { + } else { setDisplayProblemUploadForm((prevState) => !prevState) setDisplayActions(false) } @@ -121,7 +121,7 @@ export const Problem: FC<{ -