my entries request work
This commit is contained in:
parent
9184847120
commit
41fc6e4503
17
src/api/getMyEntries.js
Normal file
17
src/api/getMyEntries.js
Normal file
@ -0,0 +1,17 @@
|
||||
import {API} from '../utils/globals';
|
||||
import KeyCloakService from '../services/KeyCloakService';
|
||||
|
||||
const getMyEntries = (challengeName, setDataState, setLoadingState) => {
|
||||
fetch(`${API}/challenge-my-submissions/${challengeName}`, {
|
||||
headers: {'Authorization': `Bearer ${KeyCloakService.getToken()}`}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
setDataState(data);
|
||||
if (setLoadingState)
|
||||
setLoadingState(false);
|
||||
});
|
||||
};
|
||||
|
||||
export default getMyEntries;
|
@ -1,13 +1,33 @@
|
||||
import React from 'react';
|
||||
import {FlexColumn} from '../../utils/containers';
|
||||
import {H2} from '../../utils/fonts';
|
||||
import getMyEntries from '../../api/getMyEntries';
|
||||
|
||||
const MyEntries = (props) => {
|
||||
/* eslint-disable */
|
||||
const [myEntriesFromAPI, setMyEntriesFromAPI] = React.useState([]);
|
||||
/* eslint-disable */
|
||||
const [myEntries, setMyEntries] = React.useState([]);
|
||||
/* eslint-disable */
|
||||
const [loading, setLoading] = React.useState(true);
|
||||
|
||||
React.useEffect(() => {
|
||||
challengesRequest();
|
||||
}, []);
|
||||
|
||||
const challengesRequest = () => {
|
||||
getMyEntries(props.challengeName, setMyEntriesFromAPI);
|
||||
getMyEntries(props.challengeName, setMyEntries, setLoading);
|
||||
};
|
||||
|
||||
const MyEntries = () => {
|
||||
return (
|
||||
<FlexColumn padding='24px' as='section'>
|
||||
<H2 as='h2'>
|
||||
My entries
|
||||
</H2>
|
||||
{/*{myEntries.map((entry, index) => {*/}
|
||||
{/* */}
|
||||
{/*})}*/}
|
||||
</FlexColumn>
|
||||
);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user