1- import React , { Component } from 'react'
1+ import React from 'react'
22import { AUTH_TOKEN } from '../constants'
33import { timeDifferenceForDate } from '../utils'
44import { Mutation } from 'react-apollo'
@@ -23,21 +23,18 @@ const VOTE_MUTATION = gql`
2323 }
2424`
2525
26- export default props => {
26+ export default ( { link , index , updateStoreAfterVote } ) => {
2727 const authToken = localStorage . getItem ( AUTH_TOKEN )
28- const {
29- link : { id : linkId , description, url, votes, postedBy, createdAt } ,
30- } = props
3128 return (
3229 < div className = "flex mt2 items-start" >
3330 < div className = "flex items-center" >
34- < span className = "gray" > { props . index + 1 } .</ span >
31+ < span className = "gray" > { index + 1 } .</ span >
3532 { authToken && (
3633 < Mutation
3734 mutation = { VOTE_MUTATION }
38- variables = { { linkId } }
35+ variables = { { linkId : link . id } }
3936 update = { ( cache , { data : { vote } } ) =>
40- props . updateStoreAfterVote ( cache , vote , linkId )
37+ updateStoreAfterVote ( cache , vote , link . id )
4138 }
4239 >
4340 { voteMutation => (
@@ -50,11 +47,12 @@ export default props => {
5047 </ div >
5148 < div className = "ml1" >
5249 < div >
53- { description } ({ url } )
50+ { link . description } ({ link . url } )
5451 </ div >
5552 < div className = "f6 lh-copy gray" >
56- { votes . length } votes | by { postedBy ? postedBy . name : 'Unknown' }
57- { timeDifferenceForDate ( createdAt ) }
53+ { `${ link . votes . length } votes | by
54+ ${ link . postedBy ? link . postedBy . name : 'Unknown' }
55+ ${ timeDifferenceForDate ( link . createdAt ) } ` }
5856 </ div >
5957 </ div >
6058 </ div >
0 commit comments