Skip to content

Commit

Permalink
updated user dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
byohannes committed Nov 5, 2020
1 parent 6b5c55e commit c59b591
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions client/src/user/UserDashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Dashboard = () => {

const init = (userId, token) => {
getPurchaseHistory(userId, token).then((data) => {
if (data.error) {
if (data && data.error) {
console.log(data.error);
} else {
setHistory(data);
Expand Down Expand Up @@ -68,22 +68,25 @@ const Dashboard = () => {
<h3 className="card-header">Purchase history</h3>
<ul className="list-group">
<li className="list-group-item">
{history.map((h, i) => {
return (
<div>
<hr />
{h.products.map((p, i) => {
return (
<div key={i}>
<h6>Product name: {p.name}</h6>
<h6>Product price: ${p.price}</h6>
<h6>Purchased date: {moment(p.createdAt).fromNow()}</h6>
</div>
);
})}
</div>
);
})}
{history &&
history.map((h, i) => {
return (
<div>
<hr />
{h.products.map((p, i) => {
return (
<div key={i}>
<h6>Product name: {p.name}</h6>
<h6>Product price: ${p.price}</h6>
<h6>
Purchased date: {moment(p.createdAt).fromNow()}
</h6>
</div>
);
})}
</div>
);
})}
</li>
</ul>
</div>
Expand Down

0 comments on commit c59b591

Please sign in to comment.