submit tags request

This commit is contained in:
Mateusz Tylka 2023-05-19 10:38:18 +02:00
parent d32ce4a685
commit b75309f4af
4 changed files with 10 additions and 5 deletions

2
.env
View File

@ -3,3 +3,5 @@ REACT_APP_KC_REALM=gonito-dev
REACT_APP_KC_CLIENT_ID=gonito-dev-localhost REACT_APP_KC_CLIENT_ID=gonito-dev-localhost
REACT_APP_API=https://gonito-back-dev.csi.wmi.amu.edu.pl/api REACT_APP_API=https://gonito-back-dev.csi.wmi.amu.edu.pl/api
# https://gonito.net/api
# https://gonito-back-dev.csi.wmi.amu.edu.pl/api

View File

@ -10,9 +10,10 @@ const challengeSubmission = (
submissionTags, submissionTags,
dispatch dispatch
) => { ) => {
const tagNames = submissionTags.map((tag) => tag.name).join(',');
const details = { const details = {
f1: description, f1: description,
f2: submissionTags, f2: tagNames,
f3: repoUrl, f3: repoUrl,
f4: repoBranch, f4: repoBranch,
}; };
@ -20,6 +21,8 @@ const challengeSubmission = (
for (let property in details) { for (let property in details) {
let encodedKey = encodeURIComponent(property); let encodedKey = encodeURIComponent(property);
let encodedValue = encodeURIComponent(details[property]); let encodedValue = encodeURIComponent(details[property]);
if (property === 'f2')
encodedValue = encodedValue.replaceAll('%2C', '%2C+');
formBody.push(encodedKey + '=' + encodedValue); formBody.push(encodedKey + '=' + encodedValue);
} }
formBody = formBody.join('&'); formBody = formBody.join('&');
@ -33,7 +36,6 @@ const challengeSubmission = (
}) })
.then((resp) => resp.json()) .then((resp) => resp.json())
.then((data) => { .then((data) => {
console.log(data);
dispatch({ type: SUBMIT_ACTION.TOGGLE_SUBMISSION_LOADING }); dispatch({ type: SUBMIT_ACTION.TOGGLE_SUBMISSION_LOADING });
const processUrl = API.replace('/api', ''); const processUrl = API.replace('/api', '');
window.location.replace(`${processUrl}/open-view-progress/${data}#form`); window.location.replace(`${processUrl}/open-view-progress/${data}#form`);

View File

@ -11,7 +11,7 @@ import TagsChoose from './components/TagsChoose';
import SubmitReducer from './model/SubmitReducer'; import SubmitReducer from './model/SubmitReducer';
import SUBMIT_ACTION from './model/SubmitActionEnum'; import SUBMIT_ACTION from './model/SubmitActionEnum';
import SubmitStyle from './SubmitStyle'; import SubmitStyle from './SubmitStyle';
import SubmissionLoadingStyle from './components/SubmissionLoading/SubmissionLoadingStyle'; import SubmissionLoading from './components/SubmissionLoading/SubmissionLoading';
const Submit = (props) => { const Submit = (props) => {
const [state, dispatch] = React.useReducer(SubmitReducer, { const [state, dispatch] = React.useReducer(SubmitReducer, {
@ -93,7 +93,7 @@ const Submit = (props) => {
</SubmitStyle> </SubmitStyle>
); );
} else { } else {
return createPortal(<SubmissionLoadingStyle />, document.body); return createPortal(<SubmissionLoading />, document.body);
} }
}; };

View File

@ -0,0 +1 @@
export { default } from './SubmissionLoading';