mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Globally storing some data, other minor fixes
This commit is contained in:
parent
820adec2d0
commit
0876761a0f
7 changed files with 111 additions and 61 deletions
|
@ -1,13 +1,42 @@
|
|||
// import App from 'next/app'
|
||||
|
||||
import React from 'react'
|
||||
import '../defaultStyles.css'
|
||||
import React, { useState, useEffect } from 'react'
|
||||
|
||||
import Layout from '../components/layout'
|
||||
|
||||
import '../defaultStyles.css'
|
||||
import constants from '../constants.json'
|
||||
|
||||
function MyApp({ Component, pageProps, router }) {
|
||||
const [userId, setUserId] = useState()
|
||||
const [motd, setMotd] = useState()
|
||||
const [userSpecificMotd, setUserSpecificMotd] = useState()
|
||||
|
||||
useEffect(() => {
|
||||
fetch(`${constants.apiUrl}infos?motd=true`, {
|
||||
credentials: 'include',
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
})
|
||||
.then((resp) => {
|
||||
return resp.json()
|
||||
})
|
||||
.then((data) => {
|
||||
setUserId(data.uid)
|
||||
setMotd(data.motd)
|
||||
setUserSpecificMotd(data.userSpecificMotd)
|
||||
})
|
||||
}, [])
|
||||
|
||||
const globalData = {
|
||||
userId,
|
||||
motd,
|
||||
userSpecificMotd,
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout route={router.route}>
|
||||
<Component {...pageProps} router={router} />
|
||||
<Layout route={router.route} globalData={globalData}>
|
||||
<Component {...pageProps} router={router} globalData={globalData} />
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue