From 5382ed028c7ec554f760affa7f533b15421959c9 Mon Sep 17 00:00:00 2001
From: Renard
Date: Wed, 11 Sep 2019 19:54:48 -0300
Subject: First commit
---
src/BBSThread.js | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 94 insertions(+)
create mode 100644 src/BBSThread.js
(limited to 'src/BBSThread.js')
diff --git a/src/BBSThread.js b/src/BBSThread.js
new file mode 100644
index 0000000..b65236e
--- /dev/null
+++ b/src/BBSThread.js
@@ -0,0 +1,94 @@
+import React, { Component } from "react";
+import { Header, Icon, Loader, Message, Segment } from "semantic-ui-react";
+import Moment from "react-moment";
+import "moment/locale/es";
+
+class BBSThread extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ isLoading: true,
+ thread: [],
+ error: null
+ }
+ }
+
+ componentDidMount() {
+
+ let apiURl;
+ if (this.props.id > 1000000) {
+ apiURl = `https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&ts=${this.props.id}`;
+ } else {
+ apiURl = `https://bienvenidoainternet.org/cgi/api/thread?dir=${this.props.dir}&id=${this.props.id}`;
+ }
+ console.log(apiURl);
+ fetch(apiURl)
+ .then((response) => { return response.json() })
+ .then((resource => {
+ if (resource["state"] == "error") {
+ console.log("API Error:" + resource["message"]);
+ this.setState({ error: resource });
+ }
+ this.setState({ isLoading: false, thread: resource });
+ }))
+ .catch(console.error);
+ }
+ render() {
+ const { isLoading, error } = this.state;
+
+ if (isLoading) {
+ return (
+
{error.message}
+