mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
67 lines
1.6 KiB
JavaScript
67 lines
1.6 KiB
JavaScript
import React from 'react'
|
|
|
|
import ReactButton from './reactButton.js'
|
|
import Comments from './comments.js'
|
|
|
|
import styles from './newsEntry.module.css'
|
|
|
|
export default function NewsEntry({
|
|
newsItem,
|
|
uid,
|
|
onCommentReact,
|
|
onNewsReact,
|
|
onComment,
|
|
onDelete,
|
|
onPostDelete,
|
|
}) {
|
|
const { reacts, title, content, user, comments, date, admin } = newsItem
|
|
|
|
return (
|
|
<div className={styles.newsRoot}>
|
|
<div className={`${styles.newsContainer} ${admin && styles.adminPost}`}>
|
|
<div className={styles.newsHeader}>
|
|
<div className={styles.newsTitle}>{title}</div>
|
|
<div className={styles.user}>
|
|
<div>User #{user}</div>
|
|
<div className={styles.newsDate}> @ {date}</div>
|
|
</div>
|
|
</div>
|
|
{admin ? (
|
|
<div
|
|
className={styles.newsBody}
|
|
dangerouslySetInnerHTML={{ __html: content }}
|
|
/>
|
|
) : (
|
|
<div className={styles.newsBody}>{content}</div>
|
|
)}
|
|
</div>
|
|
<div className={'actions'}>
|
|
{uid === user ? (
|
|
<span
|
|
onClick={() => {
|
|
onPostDelete()
|
|
}}
|
|
>
|
|
Törlés
|
|
</span>
|
|
) : null}
|
|
<ReactButton
|
|
existingReacts={reacts}
|
|
uid={uid}
|
|
onClick={(reaction, isDelete) => {
|
|
onNewsReact({ reaction, isDelete })
|
|
}}
|
|
/>
|
|
</div>
|
|
<Comments
|
|
uid={uid}
|
|
onReact={(path, reaction, isDelete) => {
|
|
onCommentReact({ path, reaction, isDelete })
|
|
}}
|
|
onComment={onComment}
|
|
onDelete={onDelete}
|
|
comments={comments}
|
|
/>
|
|
</div>
|
|
)
|
|
}
|