2019-09-02 19:26:34 +02:00
|
|
|
import * as React from 'react';
|
2022-06-06 20:20:03 +02:00
|
|
|
import ReactMarkdown from 'react-markdown';
|
2019-09-02 19:26:34 +02:00
|
|
|
|
2019-09-27 16:57:23 +02:00
|
|
|
import LikeButton from '../../containers/LikeButton';
|
2022-06-08 10:20:36 +02:00
|
|
|
import CommentsNumber from '../common/CommentsNumber';
|
|
|
|
|
import PostStatusLabel from '../common/PostStatusLabel';
|
2019-09-12 18:03:19 +02:00
|
|
|
|
2019-09-11 18:30:59 +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;
|
2024-04-05 18:23:31 +02:00
|
|
|
slug?: string;
|
2019-09-02 19:26:34 +02:00
|
|
|
description?: string;
|
2019-09-11 18:30:59 +02:00
|
|
|
postStatus: IPostStatus;
|
2023-02-05 11:55:38 +01:00
|
|
|
likeCount: number;
|
|
|
|
|
showLikeCount: boolean;
|
|
|
|
|
showLikeButtons: boolean;
|
2019-09-27 16:57:23 +02:00
|
|
|
liked: number;
|
2019-09-21 11:17:58 +02:00
|
|
|
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,
|
2024-04-05 18:23:31 +02:00
|
|
|
slug,
|
2019-09-27 16:57:23 +02:00
|
|
|
description,
|
|
|
|
|
postStatus,
|
2023-02-05 11:55:38 +01:00
|
|
|
likeCount,
|
|
|
|
|
showLikeCount,
|
|
|
|
|
showLikeButtons,
|
2019-09-27 16:57:23 +02:00
|
|
|
liked,
|
|
|
|
|
commentsCount,
|
|
|
|
|
|
|
|
|
|
isLoggedIn,
|
|
|
|
|
authenticityToken,
|
|
|
|
|
}: Props) => (
|
2024-04-05 18:23:31 +02:00
|
|
|
<div onClick={() => window.location.href = `/posts/${slug || id}`} className="postListItem">
|
2019-09-27 16:57:23 +02:00
|
|
|
<LikeButton
|
|
|
|
|
postId={id}
|
2023-02-05 11:55:38 +01:00
|
|
|
likeCount={likeCount}
|
|
|
|
|
showLikeCount={showLikeCount}
|
|
|
|
|
showLikeButton={showLikeButtons}
|
2019-09-27 16:57:23 +02:00
|
|
|
liked={liked}
|
|
|
|
|
isLoggedIn={isLoggedIn}
|
|
|
|
|
authenticityToken={authenticityToken}
|
|
|
|
|
/>
|
2024-04-05 18:23:31 +02:00
|
|
|
|
2019-09-27 18:19:13 +02:00
|
|
|
<div className="postContainer">
|
|
|
|
|
<span className="postTitle">{title}</span>
|
2022-06-06 20:20:03 +02:00
|
|
|
<ReactMarkdown className="descriptionText" allowedTypes={['text']} unwrapDisallowed>
|
2024-01-26 17:43:24 +01:00
|
|
|
{description}
|
2022-06-06 20:20:03 +02:00
|
|
|
</ReactMarkdown>
|
2019-09-27 18:19:13 +02:00
|
|
|
|
|
|
|
|
<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;
|