sipp11
7 years ago
6 changed files with 93 additions and 3 deletions
@ -0,0 +1,22 @@
|
||||
|
||||
|
||||
import React, { Component } from 'react' |
||||
|
||||
class Link extends Component { |
||||
render() { |
||||
const { id, properties: { english, thai } } = this.props.node |
||||
return ( |
||||
<div> |
||||
<div> |
||||
{id} ({english} - {thai}) |
||||
</div> |
||||
</div> |
||||
) |
||||
} |
||||
|
||||
_voteForLink = async () => { |
||||
// ... you'll implement this in chapter 6
|
||||
} |
||||
} |
||||
|
||||
export default Link |
@ -0,0 +1,43 @@
|
||||
import React, { Component } from 'react' |
||||
import Link from './Link' |
||||
import { graphql } from 'react-apollo' |
||||
import gql from 'graphql-tag' |
||||
|
||||
class LinkList extends Component { |
||||
render() { |
||||
const { loading, theaters } = this.props.theaterQuery |
||||
console.log('theaters ---> ', theaters && theaters.edges.length) |
||||
console.log('theaters ---> ', theaters && theaters.edges.map(t => t.node.id )) |
||||
return ( |
||||
<div> |
||||
{ loading && 'loading' } |
||||
{ theaters && <p>{theaters.edges.length}</p> } |
||||
{ theaters && theaters.edges.map(t => <Link node={t.node} />) } |
||||
</div> |
||||
) |
||||
} |
||||
} |
||||
|
||||
const THEATER_QUERY = gql` |
||||
query { |
||||
theaters(english_Icontains: "terminal") { |
||||
edges { |
||||
node { |
||||
id |
||||
geometry { |
||||
type |
||||
coordinates |
||||
} |
||||
properties { |
||||
english |
||||
thai |
||||
code |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
` |
||||
|
||||
export default graphql(THEATER_QUERY, { name: 'theaterQuery' }) (LinkList) |
||||
// export default LinkList
|
@ -1,3 +1,5 @@
|
||||
|
||||
export const URL = process.env.API_URL || '//localhost:8000' |
||||
export const LOGIN = '/api-token-auth/' |
||||
|
||||
export const GRAPHQL_URI = process.env.GRAPHQL_URI || '//localhost:8000/graphql' |
Loading…
Reference in new issue