11import React , { Component } from 'react' ;
2- import { ScrollView , Text , View , StyleSheet } from 'react-native'
2+ import { ScrollView , Text , View } from 'react-native' ;
33import { GET_REVIEWS } from '../graphql/queries' ;
44import { Query } from "react-apollo" ;
5- import { fontSize , margin } from '../styles/theme' ;
5+ import { FontSize , Margin } from '../styles/theme' ;
6+ import { Loader } from '../components/loader' ;
7+ import { Error } from '../components/error' ;
68
79
810export default class Review extends Component {
11+ static navigationOptions = ( { navigation } ) => ( {
12+ title : `${ navigation . state . params . name } `
13+ } ) ;
914
1015 getReviews = ( business ) => {
1116 return (
1217 < Query query = { GET_REVIEWS } variables = { { business } } >
1318 { ( { loading, data : { reviews } , error } ) => {
1419
1520 if ( loading ) {
16- return < Text > Loading... </ Text >
21+ return < Loader / >
1722 }
1823 if ( reviews ) {
1924 const result = reviews . review . map ( ( i , index ) => {
2025 return (
21- < View key = { index } style = { margin . marginBottomS } >
26+ < View key = { index } style = { Margin . marginBottomS } >
2227 < Text > { index + 1 + ". " + i . text } </ Text >
23- </ View > )
28+ </ View >
29+ )
2430 } )
2531 return result ;
2632 }
2733 if ( error )
28- return < Text > { error . message } </ Text >
34+ return < Error errorCode = { error . message } / >
2935
3036 return (
3137 < Text > No result</ Text >
@@ -38,13 +44,13 @@ export default class Review extends Component {
3844 render ( ) {
3945 const { navigation } = this . props ;
4046 const business = navigation . getParam ( 'business' , 'no-business' ) ;
41- const name = navigation . getParam ( 'name' , 'no-business ' ) ;
42- console . log ( business )
47+ const name = navigation . getParam ( 'name' , 'no-name ' ) ;
48+
4349 return (
4450 < ScrollView >
45- < View style = { margin . marginM } >
46- < Text style = { fontSize . fontL } > { name } </ Text >
47- { this . getReviews ( business ) }
51+ < View style = { Margin . marginM } >
52+ < Text style = { FontSize . fontL } > Reviews </ Text >
53+ { this . getReviews ( business ) }
4854 </ View >
4955 </ ScrollView >
5056 )
0 commit comments