summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post-listings.tsx
blob: d61316b5765ff46df4615f091ec412400599848e (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Component } from 'inferno';
import { Link } from 'inferno-router';
import { Post } from '../interfaces';
import { PostListing } from './post-listing';
import { i18n } from '../i18next';
import { T } from 'inferno-i18next';

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}
              />
              <hr class="d-md-none my-2" />
              <div class="d-none d-md-block my-2"></div>
            </>
          ))
        ) : (
          <>
            <h5>
              { i18n.t('no_posts') }
            </h5>
            {this.props.showCommunity !== undefined && (
              <div>
                <Link to="/communities">{ i18n.t('subscribe_to_communities') }</Link>
              </div>
            )}
          </>
        )}
      </div>
    );
  }
}