2019-09-02 14:32:57 +02:00
|
|
|
import * as React from 'react';
|
|
|
|
|
|
2019-09-02 19:26:34 +02:00
|
|
|
import PostListItem from './PostListItem';
|
|
|
|
|
import Spinner from '../shared/Spinner';
|
2019-09-02 14:32:57 +02:00
|
|
|
|
2019-09-02 19:26:34 +02:00
|
|
|
import IPost from '../../interfaces/IPost';
|
|
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
|
posts: Array<IPost>;
|
2019-09-03 12:58:44 +02:00
|
|
|
areLoading: boolean;
|
2019-09-02 19:26:34 +02:00
|
|
|
error: string;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-03 12:58:44 +02:00
|
|
|
const PostList = ({ posts, areLoading, error }: Props) => (
|
|
|
|
|
<div className="box postList">
|
|
|
|
|
{ areLoading ? <Spinner /> : null }
|
|
|
|
|
{ error ? <span className="error">{error}</span> : null }
|
|
|
|
|
{
|
|
|
|
|
posts.map((post, i) => (
|
|
|
|
|
<PostListItem
|
|
|
|
|
title={post.title}
|
|
|
|
|
description={post.description}
|
|
|
|
|
postStatus={post.postStatus}
|
|
|
|
|
|
|
|
|
|
key={i}
|
|
|
|
|
/>
|
|
|
|
|
))
|
2019-09-02 19:26:34 +02:00
|
|
|
}
|
2019-09-03 12:58:44 +02:00
|
|
|
</div>
|
|
|
|
|
);
|
2019-09-02 14:32:57 +02:00
|
|
|
|
|
|
|
|
export default PostList;
|