Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | import * as React from 'react'; import { Mutation } from 'react-apollo'; import { connect } from 'react-redux'; import { IArticle } from '../../../../shared'; import { createCommentPermissions } from '../../../../shared/permissions'; import { IState } from '../../../types'; import { selectHasPermission, selectUsername, selectUserSub, } from '../../auth/reducer'; import { CREATE_COMMENT } from '../mutations'; import { ARTICLE } from '../queries'; import CreateCommentForm from './CreateCommentForm'; interface IProps { article: IArticle; username: string; userSub: string; hasPermission: (groups: string[]) => boolean; } const CreateComment = ({ article, username, userSub, hasPermission, }: IProps) => { if (!hasPermission(createCommentPermissions)) { return null; } return ( <Mutation mutation={CREATE_COMMENT} refetchQueries={[{ query: ARTICLE, variables: { slug: article.slug } }]} > {(createComment, { loading }) => ( <CreateCommentForm createComment={createComment} loading={loading} article={article} username={username} userSub={userSub} /> )} </Mutation> ); }; export default connect( (state: IState) => ({ username: selectUsername(state), userSub: selectUserSub(state), hasPermission: selectHasPermission(state), }), {}, )(CreateComment); |