Improve Roadmap and Board components

This commit is contained in:
riggraz
2019-09-06 14:36:26 +02:00
parent 5b8b36afd9
commit 25d7d9a5af
8 changed files with 52 additions and 28 deletions

View File

@@ -102,10 +102,16 @@ class NewPost extends React.Component<Props, State> {
});
this.setState({isLoading: false});
if (res.status === 204) this.setState({success: 'Your post has been published!'});
else {
if (res.status === 204) {
this.setState({
success: 'Your post has been published!',
title: '',
description: '',
});
} else {
let data = await res.json();
this.setState({error: data.message});
this.setState({error: data.error});
}
} catch (e) {

View File

@@ -28,15 +28,20 @@ const PostList = ({ posts, areLoading, error, handleLoadMore, page, hasMore }: P
loader={<Spinner key={0} />}
useWindow={true}
>
{posts.map((post, i) => (
<PostListItem
title={post.title}
description={post.description}
postStatus={post.postStatus}
{
posts.length > 0 ?
posts.map((post, i) => (
<PostListItem
title={post.title}
description={post.description}
postStatus={post.postStatus}
key={i}
/>
))}
key={i}
/>
))
:
!areLoading ? <span className="infoText text-muted">There are no posts.</span> : null
}
</InfiniteScroll>
</div>
);

View File

@@ -9,7 +9,7 @@ const SearchFilter = ({ searchQuery, handleChange }: Props) => (
<div className="box sidebar-box">
<label htmlFor="searchPostInput" className="smallTitle">Search:</label>
<input
type="text"
type="search"
onChange={e => handleChange(e.target.value)}
id="searchPostInput"
className="form-control"

View File

@@ -9,8 +9,6 @@ import IBoard from '../../interfaces/IBoard';
import IPost from '../../interfaces/IPost';
import IPostStatus from '../../interfaces/IPostStatus';
import debounce from '../../helpers/debounce.js';
import '../../stylesheets/components/Board.scss';
interface Props {
@@ -40,6 +38,8 @@ interface State {
}
class Board extends React.Component<Props, State> {
searchFilterTimeoutId: number;
constructor(props) {
super(props);
@@ -145,11 +145,13 @@ class Board extends React.Component<Props, State> {
}
setSearchFilter(searchQuery: string) {
debounce(() => (
if (this.searchFilterTimeoutId) clearInterval(this.searchFilterTimeoutId);
this.searchFilterTimeoutId = setTimeout(() => (
this.setState({
filters: { ...this.state.filters, searchQuery },
}, this.requestPosts)
), 1000)();
), 500);
}
setPostStatusFilter(postStatusId: number) {

View File

@@ -12,14 +12,19 @@ interface Props {
const PostList = ({ posts, boards }: Props) => (
<div className="postList">
{posts.map((post, i) => (
<PostListItem
title={post.title}
boardName={boards.find(board => board.id === post.board_id).name}
{
posts.length > 0 ?
posts.map((post, i) => (
<PostListItem
title={post.title}
boardName={boards.find(board => board.id === post.board_id).name}
key={i}
/>
))}
key={i}
/>
))
:
<span className="infoText text-muted">There are no posts that have this status.</span>
}
</div>
);