@@ -15,13 +15,14 @@ import times from 'lodash/times'
1515import remove from 'lodash/remove'
1616import find from 'lodash/find'
1717import gql from 'graphql-tag'
18- import { graphql , compose } from 'react-apollo'
18+ import { graphql } from 'react-apollo'
19+ import compose from 'recompose/compose'
1920import { propType } from 'graphql-anywhere'
2021import Dialog , {
2122 DialogActions ,
2223 DialogContent ,
2324 DialogContentText ,
24- DialogTitle
25+ DialogTitle ,
2526} from 'material-ui/Dialog'
2627import Button from 'material-ui/Button'
2728import Modal from 'material-ui/Modal'
@@ -32,19 +33,23 @@ import { REVIEW_ENTRY, REVIEWS_QUERY } from '../graphql/Review'
3233
3334const StarRating = ( { rating } ) => (
3435 < div >
35- { times ( rating , i => < StarIcon key = { i } /> ) }
36- { times ( 5 - rating , i => < StarBorderIcon key = { i } /> ) }
36+ { times ( rating , ( i ) => (
37+ < StarIcon key = { i } />
38+ ) ) }
39+ { times ( 5 - rating , ( i ) => (
40+ < StarBorderIcon key = { i } />
41+ ) ) }
3742 </ div >
3843)
3944
4045class Review extends Component {
4146 state = {
4247 anchorEl : null ,
4348 deleteConfirmationOpen : false ,
44- editing : false
49+ editing : false ,
4550 }
4651
47- openMenu = event => {
52+ openMenu = ( event ) => {
4853 this . setState ( { anchorEl : event . currentTarget } )
4954 }
5055
@@ -72,7 +77,7 @@ class Review extends Component {
7277
7378 delete = ( ) => {
7479 this . closeDeleteConfirmation ( )
75- this . props . delete ( this . props . review . id ) . catch ( e => {
80+ this . props . delete ( this . props . review . id ) . catch ( ( e ) => {
7681 if ( find ( e . graphQLErrors , { message : 'unauthorized' } ) ) {
7782 alert ( '👮♀️✋ You can only delete your own reviews!' )
7883 }
@@ -81,18 +86,18 @@ class Review extends Component {
8186
8287 toggleFavorite = ( ) => {
8388 const {
84- review : { id, favorited }
89+ review : { id, favorited } ,
8590 } = this . props
8691 this . props . favorite ( id , ! favorited )
8792 }
8893
8994 render ( ) {
9095 const {
9196 review : { text, stars, createdAt, favorited, author } ,
92- user
97+ user,
9398 } = this . props
9499
95- const linkToProfile = child => (
100+ const linkToProfile = ( child ) => (
96101 < a
97102 href = { `https://github.com/${ author . username } ` }
98103 target = "_blank"
@@ -181,7 +186,7 @@ class Review extends Component {
181186Review . propTypes = {
182187 review : propType ( REVIEW_ENTRY ) . isRequired ,
183188 favorite : PropTypes . func . isRequired ,
184- user : PropTypes . object
189+ user : PropTypes . object ,
185190}
186191
187192const FAVORITE_REVIEW_MUTATION = gql `
@@ -213,10 +218,10 @@ const withFavoriteMutation = graphql(FAVORITE_REVIEW_MUTATION, {
213218 favoriteReview : {
214219 __typename : 'Review' ,
215220 id,
216- favorited : favorite
217- }
221+ favorited : favorite ,
222+ } ,
218223 } ,
219- update : store => {
224+ update : ( store ) => {
220225 const data = store . readQuery ( { query : READ_USER_FAVORITES } )
221226
222227 if ( favorite ) {
@@ -226,9 +231,9 @@ const withFavoriteMutation = graphql(FAVORITE_REVIEW_MUTATION, {
226231 }
227232
228233 store . writeQuery ( { query : READ_USER_FAVORITES , data } )
229- }
230- } )
231- } )
234+ } ,
235+ } ) ,
236+ } ) ,
232237} )
233238
234239const DELETE_REVIEW_MUTATION = gql `
@@ -239,16 +244,16 @@ const DELETE_REVIEW_MUTATION = gql`
239244
240245const withDeleteMutation = graphql ( DELETE_REVIEW_MUTATION , {
241246 props : ( { mutate } ) => ( {
242- delete : id =>
247+ delete : ( id ) =>
243248 mutate ( {
244249 variables : { id } ,
245250 optimisticResponse : {
246- removeReview : true
251+ removeReview : true ,
247252 } ,
248- update : store => {
253+ update : ( store ) => {
249254 const query = {
250255 query : REVIEWS_QUERY ,
251- variables : { limit : 10 , orderBy : 'createdAt_DESC' }
256+ variables : { limit : 10 , orderBy : 'createdAt_DESC' } ,
252257 }
253258
254259 let data = store . readQuery ( query )
@@ -266,9 +271,9 @@ const withDeleteMutation = graphql(DELETE_REVIEW_MUTATION, {
266271 data = store . readQuery ( { query : READ_USER_FAVORITES } )
267272 remove ( data . currentUser . favoriteReviews , { id } )
268273 store . writeQuery ( { query : READ_USER_FAVORITES , data } )
269- }
270- } )
271- } )
274+ } ,
275+ } ) ,
276+ } ) ,
272277} )
273278
274279export default compose ( withFavoriteMutation , withDeleteMutation ) ( Review )
0 commit comments