1
0
Fork 0
mirror of https://gitlab.com/MrFry/qmining-page synced 2025-04-01 20:23:44 +02:00

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

@ -0,0 +1,22 @@
import React from 'react'
export default function ExternalLinkIcon({ size }) {
return (
<span style={{ margin: '4px', display: 'inline-block' }}>
<svg
width={size}
height={size}
viewBox={`0 0 24 24`}
fill="none"
stroke="currentColor"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
<polyline points="15 3 21 3 21 9"></polyline>
<line x1="10" y1="14" x2="21" y2="3"></line>
</svg>
</span>
)
}

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