mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 19:27:52 +01:00
Improve Roadmap and Board components
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user