From 4f6da92d7d0f954c520a4fe849b043e0a20fb4a1 Mon Sep 17 00:00:00 2001 From: Mateusz Tylka Date: Mon, 5 Dec 2022 11:36:08 +0100 Subject: [PATCH 1/3] challenge submit refactor --- .env | 2 +- src/api/challengeSubmissionPost.js | 9 +++++---- src/components/specific_challenge/Submit.js | 7 +++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.env b/.env index 2488d38..1009950 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ REACT_APP_KC_URL=https://auth-dev.csi.wmi.amu.edu.pl/ REACT_APP_KC_REALM=gonito-dev -REACT_APP_KC_CLIENT_ID=gonito-dev-heroku +REACT_APP_KC_CLIENT_ID=gonito-dev-localhost diff --git a/src/api/challengeSubmissionPost.js b/src/api/challengeSubmissionPost.js index d99bf0b..8ee69a6 100644 --- a/src/api/challengeSubmissionPost.js +++ b/src/api/challengeSubmissionPost.js @@ -1,7 +1,7 @@ import KeyCloakService from '../services/KeyCloakService'; import {API} from '../utils/globals'; -const challengeSubmission = (challengeName, repoUrl, repoBranch, description) => { +const challengeSubmission = (challengeName, repoUrl, repoBranch, description, setData) => { const details = { 'f1': description, 'f3': repoUrl, @@ -14,14 +14,15 @@ const challengeSubmission = (challengeName, repoUrl, repoBranch, description) => formBody.push(encodedKey + '=' + encodedValue); } formBody = formBody.join('&'); - return fetch(`${API}/challenge-submission/${challengeName}`, { + fetch(`${API}/challenge-submission/${challengeName}`, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8', 'Authorization': `Bearer ${KeyCloakService.getToken()}` }, body: formBody - }); + }).then((resp) => resp.json()) + .then((data) => setData(data)); }; -export default challengeSubmission; +export default challengeSubmission; \ No newline at end of file diff --git a/src/components/specific_challenge/Submit.js b/src/components/specific_challenge/Submit.js index d707a5c..be54cf1 100644 --- a/src/components/specific_challenge/Submit.js +++ b/src/components/specific_challenge/Submit.js @@ -10,6 +10,7 @@ const Submit = (props) => { const [description, setDescription] = React.useState(''); const [repoUrl, setRepoUrl] = React.useState(''); const [repoBranch, setRepoBranch] = React.useState(''); + const [responseNumber, setResponseNumber] = React.useState(0); const descriptionHandler = (e) => { setDescription(e.target.value); @@ -24,10 +25,8 @@ const Submit = (props) => { }; const challengeSubmissionSubmit = () => { - challengeSubmission(props.challengeName, repoUrl, repoBranch, description) - .then((response) => response.text()) - .then((data) => console.log(data)); - props.popUpMessageHandler('Submit success!', 'Check your entries.'); + challengeSubmission(props.challengeName, repoUrl, repoBranch, description, setResponseNumber); + console.log(responseNumber); }; return ( From b5b3989f1103aee9dde10f1c56ef0ddd6004ced6 Mon Sep 17 00:00:00 2001 From: Mateusz Tylka Date: Mon, 5 Dec 2022 12:46:57 +0100 Subject: [PATCH 2/3] submit response handle and font headers letter spacingg correction --- src/api/challengeSubmissionPost.js | 9 ++-- src/components/generic/Button.js | 4 ++ src/components/specific_challenge/Submit.js | 4 +- src/pages/Challenge.js | 57 ++++++++++++--------- src/utils/fonts.js | 1 + 5 files changed, 46 insertions(+), 29 deletions(-) diff --git a/src/api/challengeSubmissionPost.js b/src/api/challengeSubmissionPost.js index 8ee69a6..ca09d94 100644 --- a/src/api/challengeSubmissionPost.js +++ b/src/api/challengeSubmissionPost.js @@ -1,7 +1,7 @@ import KeyCloakService from '../services/KeyCloakService'; import {API} from '../utils/globals'; -const challengeSubmission = (challengeName, repoUrl, repoBranch, description, setData) => { +const challengeSubmission = (challengeName, repoUrl, repoBranch, description, setLoading) => { const details = { 'f1': description, 'f3': repoUrl, @@ -22,7 +22,10 @@ const challengeSubmission = (challengeName, repoUrl, repoBranch, description, se }, body: formBody }).then((resp) => resp.json()) - .then((data) => setData(data)); + .then((data) => { + setLoading(true); + window.location.replace(`https://gonito.net/view-progress/${data}#form`); + }); }; -export default challengeSubmission; \ No newline at end of file +export default challengeSubmission; diff --git a/src/components/generic/Button.js b/src/components/generic/Button.js index a385185..276f762 100644 --- a/src/components/generic/Button.js +++ b/src/components/generic/Button.js @@ -16,6 +16,10 @@ const ButtonStyle = styled(Medium)` cursor: pointer; transition: transform 0.3s ease-in-out; + * { + cursor: pointer; + } + &:hover { transform: scale(1.15); } diff --git a/src/components/specific_challenge/Submit.js b/src/components/specific_challenge/Submit.js index be54cf1..15410a3 100644 --- a/src/components/specific_challenge/Submit.js +++ b/src/components/specific_challenge/Submit.js @@ -10,7 +10,6 @@ const Submit = (props) => { const [description, setDescription] = React.useState(''); const [repoUrl, setRepoUrl] = React.useState(''); const [repoBranch, setRepoBranch] = React.useState(''); - const [responseNumber, setResponseNumber] = React.useState(0); const descriptionHandler = (e) => { setDescription(e.target.value); @@ -25,8 +24,7 @@ const Submit = (props) => { }; const challengeSubmissionSubmit = () => { - challengeSubmission(props.challengeName, repoUrl, repoBranch, description, setResponseNumber); - console.log(responseNumber); + challengeSubmission(props.challengeName, repoUrl, repoBranch, description, props.setLoading); }; return ( diff --git a/src/pages/Challenge.js b/src/pages/Challenge.js index 5739698..255fd5d 100644 --- a/src/pages/Challenge.js +++ b/src/pages/Challenge.js @@ -1,7 +1,7 @@ import React from 'react'; import {Container, FlexColumn, FlexRow, Svg} from '../utils/containers'; import {useParams} from 'react-router-dom'; -import {H1, Medium} from '../utils/fonts'; +import {H1, H2, Medium} from '../utils/fonts'; import theme from '../utils/theme'; import MobileChallengeMenu from '../components/specific_challenge/MobileChallengeMenu'; import Leaderboard from '../components/specific_challenge/Leaderboard/Leaderboard'; @@ -41,7 +41,7 @@ const Challenge = (props) => { case 3: return ; case 4: - return ; + return ; default: return ; } @@ -62,28 +62,39 @@ const Challenge = (props) => { }; const desktopRender = () => { - return ( - <> - - - - - -

- {challenge.title} -

- - {challenge.description} - -
- -
- - {sectionRender()} + if (!loading) { + return ( + <> + + + + +

+ {challenge.title} +

+ + {challenge.description} + +
+ +
+ + {sectionRender()} +
+ + ); + } + else { + return ( + +

+ Submission processing... +

+
- - ); + ); + } }; return ( diff --git a/src/utils/fonts.js b/src/utils/fonts.js index 513866d..3eeb080 100644 --- a/src/utils/fonts.js +++ b/src/utils/fonts.js @@ -7,6 +7,7 @@ const H1 = styled(Container)` font-weight: 400; font-size: 24px; line-height: 24px; + letter-spacing: 0.1px; @media (min-width: ${({theme}) => theme.overMobile}) { font-size: 48px; line-height: 52px; From 74317184a4444445fbb24717c223b785f4f9d24f Mon Sep 17 00:00:00 2001 From: Mateusz Tylka Date: Mon, 5 Dec 2022 12:49:36 +0100 Subject: [PATCH 3/3] restore env --- .env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env b/.env index 1009950..2488d38 100644 --- a/.env +++ b/.env @@ -1,3 +1,3 @@ REACT_APP_KC_URL=https://auth-dev.csi.wmi.amu.edu.pl/ REACT_APP_KC_REALM=gonito-dev -REACT_APP_KC_CLIENT_ID=gonito-dev-localhost +REACT_APP_KC_CLIENT_ID=gonito-dev-heroku