diff --git a/src/data/tabs.json b/src/data/tabs.json index 4634115..88d9350 100644 --- a/src/data/tabs.json +++ b/src/data/tabs.json @@ -18,9 +18,5 @@ "testSender": { "href": "/testSender", "text": "Test Sender" - }, - "userQuestions": { - "href": "/userQuestions", - "text": "User Questions" } } diff --git a/src/pages/index.js b/src/pages/index.js index 7a09144..93e8405 100644 --- a/src/pages/index.js +++ b/src/pages/index.js @@ -1,16 +1,29 @@ // TODO: css remove unnecesarry stuff -// TODO: resizing -// TODO: motd // TODO: aludni // TODO: fetch only once import React, { useState, useEffect } from 'react' import fetch from 'unfetch' + +import LoadingIndicator from '../components/LoadingIndicator' + import links from '../data/links.json' import constants from '../constants.json' export default function Index (props) { const [motd, setMotd] = useState('loading...') + const [news, setNews] = useState(null) + + useEffect(() => { + console.info('Fetching news.json') + fetch(`${constants.apiUrl}news.json`) // eslint-disable-line + .then((resp) => { + return resp.json() + }) + .then((data) => { + setNews(data) + }) + }, []) useEffect(() => { console.info('Fetching data') @@ -23,6 +36,39 @@ export default function Index (props) { }) }, []) + const renderNews = () => { + if (news) { + let questions = Object.keys(news).map((key, i) => { + let q = news[key] + return ( +