blob: 701e1400a3d959320206cace71826fb2edc14e22 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
import React, { Component } from 'react';
import { render } from "react-dom";
import { Router, Link, Match } from "@reach/router";
import 'fomantic-ui-css/semantic.css';
import "./App.css";
import { Dropdown, Menu, Icon, Loader, Container, Grid } from "semantic-ui-react";
import Home from "./Home";
import BBSThread from "./BBSThread";
import Board from "./Board";
import NotFound from "./NotFound"
class App extends Component {
constructor() {
super();
this.state = {
boardList: [],
isLoaded: false
}
}
componentDidMount() {
fetch("https://bienvenidoainternet.org/cgi/api/boards")
.then((response) => {
return response.json();
})
.then((resource) => {
this.setState({ boardList: resource["boards"], isLoaded: true });
})
.catch(console.error);
}
render() {
if (!this.state.isLoaded) {
if (!this.state.isLoaded) {
return (
<Loader active centered >
Cargando ...
</Loader>
)
}
}
const { boardList } = this.state;
const pathList = boardList.map(board => "/" + board.dir)
return (
<Container>
<Menu inverted>
<Menu.Item header>B.a.I</Menu.Item>
<Menu.Item as={Link} to="/"><Icon name='home' /> Home</Menu.Item>
<Dropdown text='BBS' className='link item'>
<Dropdown.Menu>
{boardList.map(board => board.board_type === 1 ? <Dropdown.Item as={Link} to={`/board/${board.dir}`}>/{board.dir}/ - {board.name}</Dropdown.Item> : null)}
</Dropdown.Menu>
</Dropdown>
<Dropdown text='Imageboard' className='link item'>
<Dropdown.Menu>
{boardList.map(board => board.board_type === 0 ? <Dropdown.Item as={Link} to={`/board/${board.dir}`}>/{board.dir}/ - {board.name}</Dropdown.Item> : null)}
</Dropdown.Menu>
</Dropdown>
</Menu>
<Router>
<Home boardList={this.state.boardList} path="/" />
<BBSThread path="/:dir/read/:id">
<BBSThread path=":active" />
</BBSThread>
<Board path="/board/:dir" />
<NotFound default />
</Router>
</Container >
);
}
}
render(<App />, document.getElementById("root"));
|