2023-02-04 22:10:54 +01:00
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
import { Link } from 'react-router-dom';
|
2023-02-05 18:44:16 +01:00
|
|
|
import { Container, NavBar, Header, Break, PostForm, TopBar } from './styled/Board.styled';
|
2023-02-04 22:10:54 +01:00
|
|
|
import { useFeed } from '@plebbit/plebbit-react-hooks';
|
2023-01-31 23:08:57 +01:00
|
|
|
|
2023-02-05 18:44:16 +01:00
|
|
|
const ImageBanner = () => {
|
|
|
|
|
const [currentImage, setCurrentImage] = useState(1);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
setCurrentImage(Math.floor(Math.random() * 5) + 1);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<img id="banner-img" src={`banner-${currentImage}.jpg`} alt="banner" />
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
2023-02-02 21:58:02 +01:00
|
|
|
const Board = () => {
|
2023-02-04 22:10:54 +01:00
|
|
|
// eslint-disable-next-line
|
|
|
|
|
const { feed, hasMore, loadMore } = useFeed(['news.eth'], 'new');
|
|
|
|
|
const [defaultSubplebbits, setDefaultSubplebbits] = useState([]);
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
let didCancel = false;
|
|
|
|
|
fetch(
|
|
|
|
|
"https://raw.githubusercontent.com/plebbit/temporary-default-subplebbits/master/subplebbits.json",
|
|
|
|
|
{ cache: "no-cache" }
|
|
|
|
|
)
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
.then(res => {
|
|
|
|
|
if (!didCancel) {
|
|
|
|
|
setDefaultSubplebbits(res);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
return () => {
|
|
|
|
|
didCancel = true;
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
2023-02-02 21:58:02 +01:00
|
|
|
return (
|
2023-02-04 22:10:54 +01:00
|
|
|
<Container>
|
|
|
|
|
<NavBar>
|
|
|
|
|
<>
|
|
|
|
|
{defaultSubplebbits.map(subplebbit => (
|
2023-02-05 18:44:16 +01:00
|
|
|
<span className="boardList" key={subplebbit.address}>[
|
|
|
|
|
<a href="/board">{subplebbit.title}</a>
|
2023-02-04 22:10:54 +01:00
|
|
|
]
|
|
|
|
|
</span>
|
|
|
|
|
))}
|
|
|
|
|
<span className="nav">[
|
|
|
|
|
<Link to="/">Home</Link>]
|
|
|
|
|
</span>
|
|
|
|
|
</>
|
|
|
|
|
</NavBar>
|
|
|
|
|
<Header>
|
|
|
|
|
<>
|
|
|
|
|
<div className="banner">
|
2023-02-05 18:44:16 +01:00
|
|
|
<ImageBanner />
|
2023-02-04 22:10:54 +01:00
|
|
|
</div>
|
|
|
|
|
<div className="board-title">Plebs Helping Plebs</div>
|
|
|
|
|
<div className="board-address">p/plebshelpingplebs.eth</div>
|
|
|
|
|
</>
|
|
|
|
|
</Header>
|
|
|
|
|
<Break />
|
2023-02-05 18:44:16 +01:00
|
|
|
<PostForm name="post" action="" method="post" enctype="multipart/form-data">
|
|
|
|
|
<div id="post-form-link">
|
2023-02-04 22:10:54 +01:00
|
|
|
[
|
|
|
|
|
<a href="#">Start a New Thread</a>
|
|
|
|
|
]
|
|
|
|
|
</div>
|
2023-02-05 18:44:16 +01:00
|
|
|
<table id="post-form"></table>
|
2023-02-04 22:10:54 +01:00
|
|
|
</PostForm>
|
2023-02-05 18:44:16 +01:00
|
|
|
<TopBar>
|
|
|
|
|
<hr />
|
|
|
|
|
<input id="search-box" type="text" placeholder="Search OPs…" />
|
|
|
|
|
[
|
|
|
|
|
<a href="./catalog">Catalog</a>
|
|
|
|
|
]
|
|
|
|
|
<hr />
|
|
|
|
|
</TopBar>
|
2023-02-04 22:10:54 +01:00
|
|
|
</Container>
|
2023-02-02 21:58:02 +01:00
|
|
|
)
|
2023-01-31 23:08:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Board;
|