summaryrefslogtreecommitdiff
path: root/client/components/App.jsx
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2017-04-21 16:03:11 -0400
committerJules Laplace <jules@okfoc.us>2017-04-21 16:03:11 -0400
commitef83dba4a83e23e38b67ee31b79e79c9e25a003d (patch)
treebe0e65ee556d215796f6c64e3df7d8adb5c51554 /client/components/App.jsx
parent5028ad81845308f3b1954dcc1fde664077fa0fa9 (diff)
display orders per product, download as csv
Diffstat (limited to 'client/components/App.jsx')
-rw-r--r--client/components/App.jsx44
1 files changed, 41 insertions, 3 deletions
diff --git a/client/components/App.jsx b/client/components/App.jsx
index 26af681..1b58e24 100644
--- a/client/components/App.jsx
+++ b/client/components/App.jsx
@@ -1,12 +1,50 @@
import React from 'react'
+import ProductList from './ProductList.jsx'
+import OrderList from './OrderList.jsx'
+import client from '../client'
export default class App extends React.Component {
constructor() {
super()
+ this.state = {
+ ready: false,
+ products: null,
+ product: null,
+ orders: null,
+ }
+ this.load = this.load.bind(this)
+ this.pick = this.pick.bind(this)
+ client.fetch('/api/products').then(this.load)
+ }
+ load(products) {
+ this.setState({
+ ready: true,
+ products: products,
+ })
+ }
+ pick(product) {
+ this.setState({
+ product: product,
+ orders: null
+ })
+ client.fetch('/api/orders', {id: product.product_merchant_product_id}).then((orders) => this.setState({ orders: orders }))
}
render() {
- return (
- <div>Loading...</div>
- )
+ if (! this.state.ready) {
+ return (
+ <div className='loading'>Loading...</div>
+ )
+ }
+ else {
+ const products = this.state.products
+ const product = this.state.product
+ const orders = this.state.orders
+ return (
+ <div>
+ <ProductList products={products} handleSelect={(product) => this.pick(product)} />
+ <OrderList product={product} orders={orders} />
+ </div>
+ )
+ }
}
} \ No newline at end of file