mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Added logout button
This commit is contained in:
parent
ca12511e6d
commit
0e59785c3c
2 changed files with 80 additions and 46 deletions
|
@ -115,43 +115,61 @@ export default function Layout({
|
|||
</a>
|
||||
</div>
|
||||
<div className="userStatus">
|
||||
<div className="msgs">
|
||||
<div
|
||||
onClick={() => {
|
||||
if (!userSpecificMotd) {
|
||||
return
|
||||
}
|
||||
setShowMotdModal(true)
|
||||
if (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: userSpecificMotd ? 'pointer' : 'default' }}
|
||||
title={
|
||||
userSpecificMotd && !userSpecificMotd.seen
|
||||
? "You've got Mail!"
|
||||
: ''
|
||||
}
|
||||
>
|
||||
{userSpecificMotd && !userSpecificMotd.seen ? '📬' : '📭'}
|
||||
</div>
|
||||
<div title="User ID">UID: {userId || '...'}</div>
|
||||
</div>
|
||||
<div
|
||||
className="logout"
|
||||
onClick={() => {
|
||||
if (!userSpecificMotd) {
|
||||
return
|
||||
}
|
||||
setShowMotdModal(true)
|
||||
if (userSpecificMotd.seen) {
|
||||
return
|
||||
}
|
||||
fetch(constants.apiUrl + 'infos', {
|
||||
method: 'POST',
|
||||
fetch(constants.apiUrl + 'logout', {
|
||||
method: 'GET',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
userSpecificMotdSeen: true,
|
||||
}),
|
||||
})
|
||||
.then((resp) => {
|
||||
return resp.json()
|
||||
})
|
||||
.then(() => {
|
||||
refetchGlobalData()
|
||||
})
|
||||
location.reload()
|
||||
}}
|
||||
style={{ cursor: userSpecificMotd ? 'pointer' : 'default' }}
|
||||
title={
|
||||
userSpecificMotd && !userSpecificMotd.seen
|
||||
? "You've got Mail!"
|
||||
: ''
|
||||
}
|
||||
>
|
||||
{userSpecificMotd && !userSpecificMotd.seen ? '📬' : '📭'}
|
||||
Logout
|
||||
</div>
|
||||
<div>User ID: {userId || '...'}</div>
|
||||
</div>
|
||||
{showMotdModal ? (
|
||||
<Modal
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue