mirror of
https://github.com/astuto/astuto.git
synced 2025-12-15 11:17:49 +01:00
66 lines
1.5 KiB
TypeScript
66 lines
1.5 KiB
TypeScript
import * as React from 'react';
|
|
import ReactMarkdown from 'react-markdown';
|
|
|
|
import LikeButton from '../../containers/LikeButton';
|
|
import CommentsNumber from '../common/CommentsNumber';
|
|
import PostStatusLabel from '../common/PostStatusLabel';
|
|
|
|
import IPostStatus from '../../interfaces/IPostStatus';
|
|
|
|
interface Props {
|
|
id: number;
|
|
title: string;
|
|
slug?: string;
|
|
description?: string;
|
|
postStatus: IPostStatus;
|
|
likeCount: number;
|
|
showLikeCount: boolean;
|
|
showLikeButtons: boolean;
|
|
liked: number;
|
|
commentsCount: number;
|
|
|
|
isLoggedIn: boolean;
|
|
authenticityToken: string;
|
|
}
|
|
|
|
const PostListItem = ({
|
|
id,
|
|
title,
|
|
slug,
|
|
description,
|
|
postStatus,
|
|
likeCount,
|
|
showLikeCount,
|
|
showLikeButtons,
|
|
liked,
|
|
commentsCount,
|
|
|
|
isLoggedIn,
|
|
authenticityToken,
|
|
}: Props) => (
|
|
<div onClick={() => window.location.href = `/posts/${slug || id}`} className="postListItem">
|
|
<LikeButton
|
|
postId={id}
|
|
likeCount={likeCount}
|
|
showLikeCount={showLikeCount}
|
|
showLikeButton={showLikeButtons}
|
|
liked={liked}
|
|
isLoggedIn={isLoggedIn}
|
|
authenticityToken={authenticityToken}
|
|
/>
|
|
|
|
<div className="postContainer">
|
|
<span className="postTitle">{title}</span>
|
|
<ReactMarkdown className="descriptionText" allowedTypes={['text']} unwrapDisallowed>
|
|
{description}
|
|
</ReactMarkdown>
|
|
|
|
<div className="postDetails">
|
|
<CommentsNumber number={commentsCount} />
|
|
{ postStatus ? <PostStatusLabel {...postStatus} /> : null }
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
|
|
export default PostListItem; |