Feedback and test sender implement, minor fixes with links

This commit is contained in:
MrFry 2020-03-15 10:53:28 +01:00
parent 8a1149d223
commit c5d6518ceb
11 changed files with 154 additions and 89 deletions

View file

@ -1,35 +1,60 @@
// TODO: css remove unnecesarry stuff
// TODO: resizing
// TODO: fetch data only once?
// TODO: move manual to this module instead of api
// TODO: feedback tab
// TODO: motd
import Layout from '../components/layout'
// TODO: aludni
// TODO: fetch only once
import React, { useState, useEffect } from 'react'
import fetch from 'unfetch'
import links from '../data/links.json'
// import constants from '../constants.json'
import constants from '../constants.json'
export default function Index (props) {
return (
<Layout currPageName='index'>
const [motd, setMotd] = useState('loading...')
useEffect(() => {
console.info('Fetching data')
fetch(`${constants.serverUrl}motd`)
.then((resp) => {
return resp.text()
})
.then((data) => {
setMotd(data)
})
}, [])
const renderMotd = () => {
return (
<div>
{Object.keys(links).map((key) => {
let link = links[key]
return (
<div
className='link'
key={key}
>
<a
href={link.href}
>
{link.text}
</a>
</div>
)
})}
<div className='motdHeader'>
MOTD:
</div>
<div
className='motd'
dangerouslySetInnerHTML={{ __html: motd }}
/>
</div>
</Layout>
)
}
return (
<div>
{renderMotd()}
{Object.keys(links).map((key) => {
let link = links[key]
return (
<div
className='link'
key={key}
>
<a
href={constants.serverUrl + link.href}
>
{link.text}
</a>
</div>
)
})}
</div>
)
}