From 5382ed028c7ec554f760affa7f533b15421959c9 Mon Sep 17 00:00:00 2001 From: Renard Date: Wed, 11 Sep 2019 19:54:48 -0300 Subject: First commit --- src/Home.js | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 src/Home.js (limited to 'src/Home.js') diff --git a/src/Home.js b/src/Home.js new file mode 100644 index 0000000..2c555f6 --- /dev/null +++ b/src/Home.js @@ -0,0 +1,112 @@ +import React, { Component } from "react"; +import { List, Header, Segment, Icon, Loader } from "semantic-ui-react"; +import Moment from "react-moment"; +import "moment/locale/es"; + +import { Link } from "@reach/router"; + +class Home extends Component { + constructor() { + super(); + this.state = { + lastAgeThreads: [], + newThreadsList: [], + latestNews: [], + isLoaded: false + } + } + + componentDidMount() { + fetch("https://bienvenidoainternet.org/cgi/api/lastage?limit=10") + .then((response) => { return response.json() }) + .then((resource) => { + this.setState({ + lastAgeThreads: resource["threads"] + }) + }); + + fetch("https://bienvenidoainternet.org/cgi/api/newThreads?limit=10") + .then((response) => { return response.json() }) + .then((resource) => { + this.setState({ + newThreadsList: resource["threads"], + }); + }); + + fetch("https://bienvenidoainternet.org/cgi/api/blotter") + .then((response) => { return response.json() }) + .then((resource) => { + this.setState({ + latestNews: resource["news"], + isLoaded: true + }); + }); + } + + render() { + if (!this.state.isLoaded) { + return ( + + Cargando ... + + ) + } + + const { newThreadsList, lastAgeThreads, latestNews } = this.state; + + return ( + + + + +
Hilos activos
+ + {lastAgeThreads.map(thread => + + + + {thread.content} + {thread.board_fulln} ― + + + )} + +
+ + +
Nuevos hilos
+ + {newThreadsList.map(thread => + + + + {thread.content} + {thread.board_fulln} ― + + + )} + +
+ +
+ +
Blotter
+ + {latestNews.map(n => + + +
+ + + + + )} + + + + + ); + } +} + +export default Home; \ No newline at end of file -- cgit v1.2.1-18-gbd029