Skip to content
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

project done #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ahmed-username
Copy link

No description provided.

@dmitrigrabov
Copy link
Contributor

Would be great to see more frequent commits.

/////////////////////////////////////////////////////

function orders (){
let orders={};
Copy link
Contributor

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}`
Copy link
Contributor

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"
Copy link
Contributor

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};
Copy link
Contributor

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){
Copy link
Contributor

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";
Copy link
Contributor

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', {
Copy link
Contributor

@dmitrigrabov dmitrigrabov Jul 20, 2018

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>

Copy link
Contributor

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', {
Copy link
Contributor

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) {
Copy link
Contributor

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){
Copy link
Contributor

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`)
Copy link
Contributor

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(){
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants