summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post-listings.tsx
blob: 93b2f606f9dd1a3cec8e8e473f34a1c406b611e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Component } from 'inferno';
import { Link } from 'inferno-router';
import { Post } from '../interfaces';
import { PostListing } from './post-listing';

interface PostListingsProps {
  posts: Array<Post>;
  showCommunity?: boolean;
}

export class PostListings extends Component<PostListingsProps, any> {

  constructor(props: any, context: any) {
    super(props, context);
  }

  render() {
    return (
      <div>
        {this.props.posts.length > 0 ? this.props.posts.map(post => 
          <PostListing post={post} showCommunity={this.props.showCommunity} />) : 
          <div>No posts. {this.props.showCommunity !== undefined  && <span>Subscribe to some <Link to="/communities">communities</Link>.</span>}
        </div>
        }
      </div>
    )
  }
}