Conversation
…k deleting items and form
…without intermediary array
| if (item) { | ||
| return res.json(menu); | ||
| } else { | ||
| return res.status(404).json({ error: "item not found" }); |
| }); | ||
|
|
||
| app.post("/api/order", function(req, res) { | ||
| const orderId = `order-${storage.id++}`; |
There was a problem hiding this comment.
might be simpler use just the id number rather than append to a string
| res.status(201).json(orderhistory); | ||
| }); | ||
|
|
||
| // Use when not on Heroku app |
There was a problem hiding this comment.
This code is no longer needed and can be deleted
| matchingOrder.quantity += order.quantity; | ||
| matchingOrder.price += order.price; | ||
|
|
||
| const ordersWithoutCurrentOrder = this.state.orders.filter( |
| } | ||
|
|
||
| handleClearHistory(key) { | ||
| // const tempOrderHistory = [...this.state.orderhistory]; |
|
|
||
| render(){ | ||
| render() { | ||
| console.log("set order hist:", this.state.orderhistory); |
There was a problem hiding this comment.
would be good remove console.logs from commit
| View Order History | ||
| </button> | ||
| <div className="main"> | ||
| {Object.keys(this.state.orderhistory).length === 0 || |
There was a problem hiding this comment.
This could be written slightly shorter as !Object.keys(this.state.orderhistory).length since if length is 0, it will be falsy
| closeWasClicked={this.closeWasClicked} | ||
| /> | ||
| )} | ||
| {Object.keys(this.state.orders).length === 0 ? null : ( |
| componentDidMount() { | ||
| const { orders } = this.props; | ||
| let prices = Array.from(orders).map(el => el.price); | ||
| let totalPrice = prices.reduce(function(acc, item) { |
| let totalPrice = prices.reduce(function(acc, item) { | ||
| return acc + item; | ||
| }, 0); | ||
| let priceWithDelivery = totalPrice + 2.95; |
There was a problem hiding this comment.
It would be good to extract th delivery charge into variable and use that. That way it will be clearer what 2.95 refers from the variable name. Also, the variable could be replaced in one place if it had to be changed
| let totalPrice = prices.reduce(function(acc, item) { | ||
| return acc + item; | ||
| }, 0); | ||
| let priceWithDelivery = totalPrice + 2.95; |
| @@ -0,0 +1,65 @@ | |||
| import React from "react"; | |||
|
|
|||
| class OrderFormItem extends React.Component { | |||
There was a problem hiding this comment.
this could be a stateless component, since it has no state. Also, commented out code should be removed
| @@ -0,0 +1,29 @@ | |||
| import React from "react"; | |||
|
|
|||
| class OrderHistoryCloseButton extends React.Component { | |||
There was a problem hiding this comment.
This can be a stateless component
| @@ -0,0 +1,58 @@ | |||
| exports.storage = { | |||
There was a problem hiding this comment.
This data object can be imported into the server. This would be quite nice as the data would be separate from code and keep server.js cleaner
No description provided.