Files
astuto/app/javascript/components/Board/PostListItem.tsx

56 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-09-02 19:26:34 +02:00
import * as React from 'react';
2019-09-27 16:57:23 +02:00
import LikeButton from '../../containers/LikeButton';
import CommentsNumber from '../shared/CommentsNumber';
2019-09-12 18:03:19 +02:00
import PostStatusLabel from '../shared/PostStatusLabel';
import { DescriptionText } from '../shared/CustomTexts';
2019-09-12 18:03:19 +02:00
import IPostStatus from '../../interfaces/IPostStatus';
2019-09-02 19:26:34 +02:00
interface Props {
2019-09-12 15:51:45 +02:00
id: number;
2019-09-02 19:26:34 +02:00
title: string;
description?: string;
postStatus: IPostStatus;
2019-09-27 16:57:23 +02:00
likesCount: number;
liked: number;
commentsCount: number;
2019-09-27 16:57:23 +02:00
isLoggedIn: boolean;
authenticityToken: string;
2019-09-02 19:26:34 +02:00
}
2019-09-27 16:57:23 +02:00
const PostListItem = ({
id,
title,
description,
postStatus,
likesCount,
liked,
commentsCount,
isLoggedIn,
authenticityToken,
}: Props) => (
2019-09-27 18:19:13 +02:00
<div onClick={() => window.location.href = `/posts/${id}`} className="postListItem">
2019-09-27 16:57:23 +02:00
<LikeButton
postId={id}
likesCount={likesCount}
liked={liked}
isLoggedIn={isLoggedIn}
authenticityToken={authenticityToken}
/>
2019-09-27 18:19:13 +02:00
<div className="postContainer">
<span className="postTitle">{title}</span>
<DescriptionText limit={120}>{description}</DescriptionText>
<div className="postDetails">
<CommentsNumber number={commentsCount} />
{ postStatus ? <PostStatusLabel {...postStatus} /> : null }
2019-09-02 19:26:34 +02:00
</div>
2019-09-27 18:19:13 +02:00
</div>
</div>
2019-09-02 19:26:34 +02:00
);
export default PostListItem;