-
Notifications
You must be signed in to change notification settings - Fork 581
/
index.js
35 lines (31 loc) 路 1.22 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import React from 'react'
import { compose, withPropsOnChange } from 'recompose'
import withObservables from '@nozbe/with-observables'
import { withDatabase } from '@nozbe/watermelondb/DatabaseProvider'
import Comment from 'components/Comment'
import BackLink from 'components/BackLink'
import style from './style'
const ModerationQueue = ({ blog, nastyComments, hideMain, match }) => (
<React.Fragment>
<BackLink to={`/blog/${match.params.blogId}`} onClick={hideMain}>< Back</BackLink>
<div className={style.queueBlock}>
<span className={style.title}>Moderation queue for {blog.name}</span>
<span className={style.subtitle}>Nasty comments ({nastyComments.length})</span>
{nastyComments.map(comment => (
<Comment comment={comment} key={comment.id} />
))}
</div>
</React.Fragment>
)
const enhance = compose(
withPropsOnChange(['match'], ({ match }) => ({
blogId: match.params.blogId,
})),
withObservables(['id'], ({ blogId, database }) => ({
blog: database.collections.get('blogs').findAndObserve(blogId),
})),
withObservables(['blog'], ({ blog }) => ({
nastyComments: blog.nastyComments.observe(),
})),
)
export default withDatabase(enhance(ModerationQueue))