Adding a path and components for a show page

This commit is contained in:
Nikola Bjelo committed 2018-10-30 08:14:05 +01:00
1 parent 2e4f3c253a
commit 323835834c
3 files changed
+47

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
import React from 'react'
import { Query } from 'react-apollo'
import Typography from '@material-ui/core/Typography'
import { withStyles } from '@material-ui/core/styles'
import styles from './styles'
import { showEventCalls } from '../../../GraphQL/Calls/index'
class Show extends React.Component {
render () {
return (
<React.Fragment>
<Typography
variant='display1'
align='center'
color='textPrimary'
gutterBottom
>
Enroll in an competition {this.props.match.params.slug}
</Typography>
<Query
query={showEventCalls.HOSTS_EVENT}
variables={{ designator: this.props.match.params.slug }}
>
{({ loading, error, data }) => {
if (loading) return 'Loading...'
if (error) return `Error! ${error.message}`
return (
<p>
{data.hosts_Event.description}
</p>
)
}}
</Query>
</React.Fragment>
)
}
}
export default withStyles(styles)(Show)
@@ -0,0 +1,4 @@
const styles = theme => ({
})
export default styles
+1
View File
@@ -43,6 +43,7 @@ class App extends Component {
<Switch>
<Route exact path='/' component={Search} />
<Route path='/event/:slug/edit' component={EditEvent} />
<Route path='/event/:slug' component={EditEvent} />
<Route path='/hosted-events' component={HostedEvents} />
</Switch>
</div>