Multiple style fixes, added top bar to layout

This commit is contained in:
mrfry 2021-05-26 18:36:57 +02:00
parent 53d955808a
commit 3a67f2a1aa
11 changed files with 314 additions and 351 deletions

View file

@ -1,5 +1,3 @@
// import App from 'next/app'
import React, { useState, useEffect } from 'react'
import Layout from '../components/layout'
@ -10,7 +8,7 @@ import constants from '../constants.json'
function MyApp({ Component, pageProps, router }) {
const [userId, setUserId] = useState()
const [motd, setMotd] = useState()
const [userSpecificMotd, setUserSpecificMotd] = useState()
const [unreads, setUnreads] = useState()
const getGlobalProps = () => {
fetch(`${constants.apiUrl}infos?motd=true`, {
@ -22,9 +20,21 @@ function MyApp({ Component, pageProps, router }) {
return resp.json()
})
.then((data) => {
setUserId(data.uid)
setMotd(data.motd)
setUserSpecificMotd(data.userSpecificMotd)
fetch(`${constants.apiUrl}hasNewMsg?userid=${data.uid}`, {
credentials: 'include',
Accept: 'application/json',
'Content-Type': 'application/json',
})
.then((resp) => {
return resp.json()
})
.then((hasNewMsg) => {
const res = { ...data, ...hasNewMsg }
setUserId(res.uid)
setMotd(res.motd)
setUnreads(res.unreads)
})
})
}
@ -33,9 +43,9 @@ function MyApp({ Component, pageProps, router }) {
}, [])
const globalData = {
userId,
motd,
userSpecificMotd,
userId: userId,
motd: motd,
unreads: unreads,
}
return (