diff --git a/src/components/layout.js b/src/components/layout.js
index 6c7c792..c6b1020 100644
--- a/src/components/layout.js
+++ b/src/components/layout.js
@@ -15,14 +15,19 @@ const renderSnow = () => {
return date.getMonth() === 11 && date.getDate() > 5
}
-export default function Layout(props) {
- let href = props.route
+export default function Layout({
+ children,
+ route,
+ globalData,
+ refetchGlobalData,
+}) {
+ let href = route
const [sidebarOpen, setSidebarOpen] = useState(true)
const [windowSize, setWindowSize] = useState([100, 200])
const [showMotdModal, setShowMotdModal] = useState(false)
- const userId = props.globalData.userId
- const userSpecificMotd = props.globalData.userSpecificMotd
+ const userId = globalData.userId
+ const userSpecificMotd = globalData.userSpecificMotd
if (href === '/' || href === '') {
href = 'index'
@@ -99,19 +104,39 @@ export default function Layout(props) {
- {userSpecificMotd ? (
-
{
- setShowMotdModal(true)
- }}
- style={{ cursor: 'pointer' }}
- title={"You've got Mail!"}
- >
- 📬
-
- ) : (
-
ðŸ“
- )}
+
{
+ setShowMotdModal(true)
+ if (userSpecificMotd && userSpecificMotd.seen) {
+ return
+ }
+ fetch(constants.apiUrl + 'infos', {
+ method: 'POST',
+ credentials: 'include',
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({
+ userSpecificMotdSeen: true,
+ }),
+ })
+ .then((resp) => {
+ return resp.json()
+ })
+ .then(() => {
+ refetchGlobalData()
+ })
+ }}
+ style={{ cursor: 'pointer' }}
+ title={
+ userSpecificMotd && !userSpecificMotd.seen
+ ? "You've got Mail!"
+ : ''
+ }
+ >
+ {userSpecificMotd && !userSpecificMotd.seen ? '📬' : 'ðŸ“'}
+
User ID: {userId || '...'}
{showMotdModal ? (
@@ -123,13 +148,13 @@ export default function Layout(props) {
Üzenet az oldal készÃtÅ‘jétÅ‘l:
- {userSpecificMotd}
+ {userSpecificMotd.msg}
) : null}
>
) : null}
- {props.children}
+ {children}
)
diff --git a/src/defaultStyles.css b/src/defaultStyles.css
index a0fc90c..4d22493 100644
--- a/src/defaultStyles.css
+++ b/src/defaultStyles.css
@@ -63,7 +63,7 @@ a {
}
.userStatus :first-child {
- font-size: 25px;
+ font-size: 45px;
}
.userStatus > div {
diff --git a/src/pages/_app.js b/src/pages/_app.js
index cdc51e7..dab7bf8 100644
--- a/src/pages/_app.js
+++ b/src/pages/_app.js
@@ -12,7 +12,7 @@ function MyApp({ Component, pageProps, router }) {
const [motd, setMotd] = useState()
const [userSpecificMotd, setUserSpecificMotd] = useState()
- useEffect(() => {
+ const getGlobalProps = () => {
fetch(`${constants.apiUrl}infos?motd=true`, {
credentials: 'include',
Accept: 'application/json',
@@ -26,6 +26,10 @@ function MyApp({ Component, pageProps, router }) {
setMotd(data.motd)
setUserSpecificMotd(data.userSpecificMotd)
})
+ }
+
+ useEffect(() => {
+ getGlobalProps()
}, [])
const globalData = {
@@ -35,8 +39,17 @@ function MyApp({ Component, pageProps, router }) {
}
return (
-
-
+
+
)
}
diff --git a/src/pages/index.js b/src/pages/index.js
index a71cead..8b4a116 100644
--- a/src/pages/index.js
+++ b/src/pages/index.js
@@ -140,7 +140,7 @@ export default function Index(props) {
{userSpecificMotd ? (
) : (
...