Created
October 3, 2017 16:03
-
-
Save feus4177/431228adeb2a3bda0b229a35335a0293 to your computer and use it in GitHub Desktop.
Example using a query fragment.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import PropTypes from 'prop-types'; | |
import {graphql, QueryRenderer} from 'react-relay'; | |
import environment from '@/environment'; | |
import PageBar from '@/components/PageBar'; | |
import Loading from '@/components/Loading'; | |
import OrderTableRelay from '@/components/OrderTableRelay'; | |
const manageOrdersQuery = graphql` | |
query ManageOrdersRelayQuery { | |
orders(first: 10){ | |
edges { | |
node { | |
...OrderTableRelay_order | |
} | |
} | |
} | |
} | |
`; | |
const ManageOrders = ({routes}) => ( | |
<div className="page-content"> | |
<PageBar routes={routes} /> | |
<h1 className="page-title">Manage Orders</h1> | |
<QueryRenderer | |
environment={environment} | |
query={manageOrdersQuery} | |
render={({error, props}) => { | |
if (error) { | |
return <div><h1>Error!</h1><br />{error}</div>; | |
} | |
if (props) { | |
return ( | |
<OrderTableRelay | |
{...props} | |
columns={[ | |
'id', | |
'creationTime', | |
'dueDate', | |
'poNumber', | |
'totalQuantity', | |
'status', | |
]} | |
/> | |
); | |
} | |
return <div><Loading /></div>; | |
}} | |
/> | |
</div> | |
); | |
ManageOrders.propTypes = { | |
routes: PageBar.propTypes.routes, | |
}; | |
export default ManageOrders; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment