Skip to content

Commit

Permalink
Merge pull request #111 from Viveckh/product-deletion-paid
Browse files Browse the repository at this point in the history
FIX #110: deleting product after being paid
  • Loading branch information
Viveckh authored May 3, 2020
2 parents f96bf1b + c0a24d3 commit 197c6b2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 22 deletions.
8 changes: 7 additions & 1 deletion shopping-server/services/orderService.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ export default {
// Converting mongoose order object to regular json object to send to email service
order = order.toObject({flattenMaps: true});
transformer.castValuesToString(order, ["_id", "tariff", "category"]);
emailService.emailOrderReceived(order)
emailService.emailOrderReceived(order);

const cartItemIds = _.map(checkout.cart.items, '_id');
await shoppingService.deleteFromCart(userObj, cartItemIds);

result = {
httpStatus: httpStatus.OK,
Expand Down Expand Up @@ -359,6 +362,9 @@ export default {
transformer.castValuesToString(order, ["_id", "tariff", "category"]);
emailService.emailOrderReceived(order)

const cartItemIds = _.map(checkout.cart.items, '_id');
await shoppingService.deleteFromCart(userObj, cartItemIds);

result = {
httpStatus: httpStatus.OK,
status: "successful",
Expand Down
39 changes: 18 additions & 21 deletions shopping-webclient/src/components/orders/SingleOrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,24 @@
</h4>

<b-card-group deck class="mb-3">
<b-card bg-variant="light" :header="getOrderDeet()">
<b-card bg-variant="light">
<template v-slot:header>
<div class="info">
<!-- Status goes here -->
Status:
<span
v-bind:class="{'green': order.overall_status != 'CANCELLED',
'red': order.overall_status === 'CANCELLED'}"
>
<strong>{{order.overall_status}}</strong>
</span><br>

<strong>Order #</strong>
{{order._id}}<br>
<strong>Order placed on</strong>
{{dateFormat(order.auditLog.createdOn)}}
</div>
</template>
<div class="card-text card-font">
<p>Total Weight: <strong>{{order.cart.totalWeight.quantity}} {{order.cart.totalWeight.unit}}</strong></p>
<p>Sub Total Price: <strong>$ {{order.cart.subTotalPrice.amount | formattedAmount}}</strong></p>
Expand Down Expand Up @@ -132,26 +149,6 @@ export default {
}
return '';
},
getOrderDeet() {
return `
<div class="info">
<!-- Status goes here -->
Status:
<span
v-bind:class="{'green': ${this.order.overall_status} != 'CANCELLED',
'red': ${this.order.overall_status} === 'CANCELLED'}"
>
<strong>${this.order.overall_status}</strong>
</span><br>
<strong>Order #</strong>
${this.order._id}<br>
<strong>Order placed on</strong>
${this.dateFormat(this.order.auditLog.createdOn)}
</div>
`;
},
},
computed: {
Expand Down

0 comments on commit 197c6b2

Please sign in to comment.