diff --git a/src/api/getFullUserInfo.js b/src/api/getFullUserInfo.js index 53544eb..f84a23e 100644 --- a/src/api/getFullUserInfo.js +++ b/src/api/getFullUserInfo.js @@ -1,16 +1,15 @@ -import {API} from '../utils/globals'; +import { API } from '../utils/globals'; import KeyCloakService from '../services/KeyCloakService'; -const getFullUser = (setDataState, setLoadingState) => { - fetch(`${API}/full-user-info`, { - headers: {'Authorization': `Bearer ${KeyCloakService.getToken()}`} - }) - .then(response => response.json()) - .then(data => { - setDataState(data); - if (setLoadingState) - setLoadingState(false); - }); +const getFullUser = async (setDataState, setLoadingState) => { + fetch(`${API}/full-user-info`, { + headers: { Authorization: `Bearer ${KeyCloakService.getToken()}` }, + }) + .then((response) => response.json()) + .then((data) => { + setDataState(data); + if (setLoadingState) setLoadingState(false); + }); }; -export default getFullUser; \ No newline at end of file +export default getFullUser; diff --git a/src/pages/AllEntries/AllEntries.js b/src/pages/AllEntries/AllEntries.js index 19ef0b7..84ebad7 100644 --- a/src/pages/AllEntries/AllEntries.js +++ b/src/pages/AllEntries/AllEntries.js @@ -112,6 +112,8 @@ const AllEntries = (props) => { const n = (pageNr - 1) * (ELEMENTS_PER_PAGE * 2); let elements = entries.slice(n, n + ELEMENTS_PER_PAGE * 2); + console.log(CALC_PAGES(entries, 2)); + console.log(entries); return ( { } /> {elements.length > 0 && entries[0] && ( - //
- - // +
+
+ )} { const [userFullInfo, setUserFullInfo] = React.useState(null); const username = KeyCloakService.getUsername(); - React.useEffect(() => { - getFullUser(setUserFullInfo); - - if (!KeyCloakService.isLoggedIn()) { - props.popUpMessageHandler( - 'Please log in', - 'To see everything you must log in', - () => KeyCloakService.doLogin - ); - } + React.useMemo(async () => { + await getFullUser(setUserFullInfo); + setTimeout(() => { + if (!KeyCloakService.isLoggedIn()) { + props.popUpMessageHandler( + 'Please log in', + 'To see everything you must log in', + () => KeyCloakService.doLogin + ); + } + }, 1000); }, [props]); return ( diff --git a/src/pages/Leaderboard/Leaderboard.js b/src/pages/Leaderboard/Leaderboard.js index 6185662..e72b697 100644 --- a/src/pages/Leaderboard/Leaderboard.js +++ b/src/pages/Leaderboard/Leaderboard.js @@ -177,12 +177,14 @@ const Leaderboard = (props) => { } /> {elements.length > 0 && entries[0] && ( -
+
+
+ )} { } /> {elements.length > 0 && myEntries[0] && ( -
+
+
+ )}