From ef83dba4a83e23e38b67ee31b79e79c9e25a003d Mon Sep 17 00:00:00 2001
From: Jules Laplace <jules@okfoc.us>
Date: Fri, 21 Apr 2017 16:03:11 -0400
Subject: display orders per product, download as csv

---
 client/components/ProductList.jsx | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
 create mode 100644 client/components/ProductList.jsx

(limited to 'client/components/ProductList.jsx')

diff --git a/client/components/ProductList.jsx b/client/components/ProductList.jsx
new file mode 100644
index 0000000..ab00e9f
--- /dev/null
+++ b/client/components/ProductList.jsx
@@ -0,0 +1,31 @@
+import React from 'react'
+
+export default class ProductList extends React.Component {
+  constructor(props) {
+    super()
+    this.state = { value: -1 }
+    this.pick = this.pick.bind(this)
+  }
+  pick(event) {
+    const value = Number(event.target.value)
+    this.setState({ value: value })
+    if (value === -1) return
+    const product = this.props.products[value]
+    this.props.handleSelect(product)
+  }
+  render() {
+    const items = this.props.products.map((product, i) => {
+      return (
+        <option key={i} value={i}>
+          {product.product_name} ({product.product_merchant_product_id})
+        </option>
+      )
+    })
+    items.unshift(<option key={-1} value={-1}>Select a product...</option>)
+    return (
+      <select value={this.state.value} onChange={this.pick}>
+        {items}
+      </select>
+    )
+  }
+}
\ No newline at end of file
-- 
cgit v1.2.3-70-g09d2

