Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit 448d8ba

Browse files
committed
Merge branch 'master' of https://github.com/Shift3/react-technical-project into order-form
2 parents 2673ff7 + 6919b6d commit 448d8ba

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.view-order-container {
2+
font-family: "Optima", serif;
3+
min-height: 100px;
4+
border-bottom: solid 1px #999;
5+
}
6+
7+
.view-order-container p {
8+
margin: 0;
9+
}
10+
11+
.view-order-container button {
12+
margin-left: 20px;
13+
}
14+
15+
.view-order-left-col {
16+
display: flex;
17+
align-items: center;
18+
}
19+
20+
.view-order-middle-col {
21+
display: flex;
22+
flex-direction: column;
23+
align-items: center;
24+
justify-content: center;
25+
}
26+
27+
.view-order-right-col {
28+
display: flex;
29+
align-items: center;
30+
justify-content: flex-end;
31+
}
32+
33+
@media only screen and (max-width: 768px) {
34+
.view-order-left-col {
35+
justify-content: center;
36+
}
37+
38+
.view-order-middle-col {
39+
margin-bottom: 20px;
40+
}
41+
42+
.view-order-right-col {
43+
padding-bottom: 20px;
44+
justify-content: space-around;
45+
}
46+
47+
.view-order-container button {
48+
margin: 0;
49+
}
50+
}

application/src/components/view-orders/viewOrders.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,45 @@ import { Template } from '../../components';
33
import './viewOrders.css';
44

55
class ViewOrders extends Component {
6+
state = {
7+
orders: []
8+
}
9+
10+
componentDidMount() {
11+
fetch('http://localhost:4000/api/current-orders')
12+
.then(response => response.json())
13+
.then(response => {
14+
if(response.success) {
15+
this.setState({ orders: response.orders });
16+
} else {
17+
console.log('Error getting orders');
18+
}
19+
});
20+
}
21+
622
render() {
723
return (
824
<Template>
25+
<div className="container-fluid">
26+
{this.state.orders.map(order => {
27+
const createdDate = new Date(order.createdAt);
28+
return (
29+
<div className="row view-order-container" key={order._id}>
30+
<div className="col-md-4 view-order-left-col p-3">
31+
<h2>{order.order_item}</h2>
32+
</div>
33+
<div className="col-md-4 d-flex view-order-middle-col">
34+
<p>Order placed at {`${createdDate.getHours()}:${createdDate.getMinutes()}:${createdDate.getSeconds()}`}</p>
35+
<p>Quantity: {order.quantity}</p>
36+
</div>
37+
<div className="col-md-4 view-order-right-col">
38+
<button className="btn btn-success">Edit</button>
39+
<button className="btn btn-danger">Delete</button>
40+
</div>
41+
</div>
42+
);
43+
})}
44+
</div>
945
</Template>
1046
);
1147
}

0 commit comments

Comments
 (0)