import * as React from 'react'; import I18n from 'i18n-js'; import InfiniteScroll from 'react-infinite-scroller'; import PostListItem from './PostListItem'; import Spinner from '../common/Spinner'; import { DangerText, CenteredMutedText, } from '../common/CustomTexts'; import IPost from '../../interfaces/IPost'; import IPostStatus from '../../interfaces/IPostStatus'; interface Props { posts: Array; showLikeCount: boolean; showLikeButtons: boolean; postStatuses: Array; areLoading: boolean; error: string; hasMore: boolean; handleLoadMore(): void; isLoggedIn: boolean; authenticityToken: string; } const PostList = ({ posts, showLikeCount, showLikeButtons, postStatuses, areLoading, error, hasMore, handleLoadMore, isLoggedIn, authenticityToken, }: Props) => (
{ error ? {error} : null } } useWindow={true} > { posts.length > 0 ? posts.map((post, i) => ( postStatus.id === post.postStatusId)} likeCount={post.likeCount} showLikeCount={showLikeCount} showLikeButtons={showLikeButtons} liked={post.liked} commentsCount={post.commentsCount} isLoggedIn={isLoggedIn} authenticityToken={authenticityToken} key={i} /> )) : areLoading ?

: {I18n.t('board.posts_list.empty')} }
); export default PostList;