1234567891011121314151617181920212223 |
- import { Query } from 'react-apollo'
- import Instrument, { INSTRUMENT_QUERY } from '../components/Instrument'
- import InstrumentList from '../components/InstrumentList'
- const InstrumentsPage = props =>
- props.query && props.query.id ? (
- <Query query={INSTRUMENT_QUERY} variables={{ id: props.query.id }}>
- {({ data, loading, error }) => {
- if (loading) return <p>Loading instrument...</p>
- if (error) return <p>Error loading instrument: {error.message}</p>
- const { instrument } = data
- return <Instrument instrument={instrument} />
- }}
- </Query>
- ) : (
- <InstrumentList />
- )
- InstrumentsPage.getInitialProps = ({ query }) => {
- return { query }
- }
- export default InstrumentsPage
|