Added comments to news items

This commit is contained in:
mrfry 2021-03-04 21:31:32 +01:00
parent 64697efc96
commit 71911063b0
9 changed files with 357 additions and 22 deletions

View file

@ -1,29 +1,52 @@
import React from 'react'
import ReactButton from './reactButton.js'
import Comments from './comments.js'
import styles from './newsEntry.module.css'
export default function NewsEntry({ newsKey, newsItem, uid, onReact }) {
export default function NewsEntry({
newsKey,
newsItem,
uid,
onReact,
onComment,
onDelete,
}) {
const { reacts, title, body, comments } = newsItem
return (
<div>
<div className={styles.newsContainer}>
<div className={styles.itemNumber}>{newsKey} :</div>
<div
className={styles.newsTitle}
dangerouslySetInnerHTML={{ __html: newsItem.title }}
dangerouslySetInnerHTML={{ __html: title }}
/>
<div
className={styles.newsBody}
dangerouslySetInnerHTML={{ __html: newsItem.body }}
dangerouslySetInnerHTML={{ __html: body }}
/>
</div>
<ReactButton
existingReacts={newsItem.reacts}
existingReacts={reacts}
uid={uid}
onClick={onReact}
onClick={(reaction, isDelete) => {
onReact({ type: 'news', reaction, isDelete })
}}
/>
<hr />
<Comments
uid={uid}
onReact={(path, reaction, isDelete) => {
onReact({ type: 'comment', path, reaction, isDelete })
}}
onComment={onComment}
onDelete={onDelete}
comments={comments}
/>
<hr />
<hr />
</div>
)
}