Changed lotsa stuff

This commit is contained in:
mrfry 2021-03-23 15:34:26 +01:00
parent 91eb5cd839
commit 7bb7b919ae
18 changed files with 457 additions and 447 deletions

View file

@ -15,6 +15,51 @@ const renderSnow = () => {
return date.getMonth() === 11 && date.getDate() > 5
}
function MessageButton({
userSpecificMotd,
setShowMotdModal,
refetchGlobalData,
}) {
return (
<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>
)
}
export default function Layout({
children,
route,
@ -25,6 +70,7 @@ export default function Layout({
const [sidebarOpen, setSidebarOpen] = useState(true)
const [windowSize, setWindowSize] = useState([100, 200])
const [showMotdModal, setShowMotdModal] = useState(false)
const [donateShowing, setDonateShowing] = useState(false)
const [showNewMsgModal, setShowNewMsgModal] = useState(true)
const userId = globalData.userId
@ -109,55 +155,22 @@ export default function Layout({
)
})}
<a
href={`/donate`}
className="donate"
onClick={closeSideBar}
target="_blank"
rel="noreferrer"
onClick={() => {
console.log('AAAAAAAAA')
closeSideBar()
setDonateShowing(true)
}}
>
Donate
</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>
<MessageButton
userSpecificMotd={userSpecificMotd}
setShowMotdModal={setShowMotdModal}
refetchGlobalData={refetchGlobalData}
/>
<div title="User ID">UID: {userId || '...'}</div>
<div
className="logout"
onClick={() => {
@ -175,21 +188,28 @@ export default function Layout({
Logout
</div>
</div>
{showMotdModal ? (
<Modal
closeClick={() => {
setShowMotdModal(false)
}}
>
<div style={{ textAlign: 'center' }}>Üzenet admintól:</div>
<div
dangerouslySetInnerHTML={{ __html: userSpecificMotd.msg }}
/>
</Modal>
) : null}
</>
) : null}
</div>
{donateShowing ? (
<Layout
closeClick={() => {
setDonateShowing(false)
}}
>
<div>hi</div>
</Layout>
) : null}
{showMotdModal ? (
<Modal
closeClick={() => {
setShowMotdModal(false)
}}
>
<div style={{ textAlign: 'center' }}>Üzenet admintól:</div>
<div dangerouslySetInnerHTML={{ __html: userSpecificMotd.msg }} />
</Modal>
) : null}
<div className="content">{children}</div>
{userSpecificMotd && !userSpecificMotd.seen && showNewMsgModal ? (
<Modal