-
Notifications
You must be signed in to change notification settings - Fork 38
project done #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
project done #6
Conversation
|
Would be great to see more frequent commits. |
| ///////////////////////////////////////////////////// | ||
|
|
||
| function orders (){ | ||
| let orders={}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
|
|
||
|
|
||
| app.post('/api/order/', function(req, res){ | ||
| let orderId= `Order${id}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might simpler to just use the id rather than append Order string to it
| } | ||
|
|
||
| showMenu(event){ | ||
| document.querySelector(".app_menu").style.display="block" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using DOM manipulation in React. It would be better to set a value in state and then based on that add a class during render
| class Menu extends React.Component { | ||
| constructor(){ | ||
| super(); | ||
| this.state={menu:[], order:{}, total:0, orderId:1}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code would slightly more readable if each key/value pair was on own line
| fetch(`http://localhost:8080/menu`) | ||
| .then(function(response){ | ||
| return response.json(); | ||
| }).then(function(jsonData){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you make this an arrow function, you don't need self
| this.setState({total: myTotal}); | ||
| this.setState({order : allOrders}); | ||
|
|
||
| document.querySelector(".charge").style.display="block"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid DOM manipulation in React
| const self=this; | ||
| this.setState({orderId:1}); | ||
|
|
||
| fetch('http://localhost:8080/api/order', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use relative url here /api/order otherwise code will break when deployed to another domain name
| <p> Total: £{this.state.total} <label className="charge"> + £{this.state.total/20} delivery charge </label> </p> | ||
| <button onClick={this.submitOrder}> Submit Order! </button> | ||
| </div> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indenation could be tidier
| orderAgain(event) | ||
| { | ||
| const self=this; | ||
| fetch('http://localhost:8080/api/order', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use relative url /api/order
| } | ||
| }).then(function(response) { | ||
| return response.json(); | ||
| }).then(function(data) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use arrow function to avoid self
| }); | ||
|
|
||
|
|
||
| app.delete('/api/delete/', function(req, res){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use the route /api/order the delete islready implied by the HTTP method delete. The HTTP method is the action we are performing and the route name represents the resource we are performing the action on. Also, it would be good to use the id as a route param to indicate which item from orders is being deleted.
| fetchOrders(){ | ||
|
|
||
| const self=this; | ||
| fetch(`http://localhost:8080/orders`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use relative URL
| import Order from './Order'; | ||
|
|
||
| class Orders extends React.Component { | ||
| constructor(){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could do with some indentation
No description provided.