Skip to content

Commit

Permalink
Improved: the api endpoints for performing operations on order(#73)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymaheshwari1 committed Jun 10, 2024
1 parent 6f4c893 commit cd3f227
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/i18n/locales/en.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"Add address": "Add address",
"Are you sure you want to save the changes?": "Are you sure you want to save the changes?",
"Are you sure you want to cancel the order items?": "Are you sure you want to cancel the order items?",
"Cancel": "Cancel",
"Cancel items": "Cancel items",
"Change Store": "Change Store",
"Changes saved": "Changes saved",
"City": "City",
"Confirm": "Confirm",
"Click the backdrop to dismiss.": "Click the backdrop to dismiss.",
Expand All @@ -15,6 +17,7 @@
"Fetching order details.": "Fetching order details.",
"Fetching stores.": "Fetching stores.",
"First name": "First name",
"Failed to cancel the order": "Failed to cancel the order",
"Failed to update the pickup store": "Failed to update the pickup store",
"Failed to update the shipping addess": "Failed to update the shipping addess",
"Last name": "Last name",
Expand Down
19 changes: 11 additions & 8 deletions src/services/OrderService.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
import { api } from '@/adapter';

const getOrder = async (): Promise <any> => {
const getOrder = async (token: string): Promise <any> => {
return api({
url: "orders",
method: "get",
url: "getRerouteOrder",
method: "POST",
data: {
token
}
});
}

const updateShippingAddress = async (payload: any): Promise <any> => {
return api({
url: "service/updateShippingInformationOfShipGroup",
url: "updateShippingAddressRerouteOrder",
method: "post",
data: payload,
data: payload
});
}

const updatePickupFacility = async (payload: any): Promise <any> => {
return api({
url: "service/updateOrderItemShipGroup",
url: "updatePickupFacility",
method: "post",
data: payload,
data: payload
});
}

const cancelOrderItem = async (payload: any): Promise <any> => {
return api({
url: 'cancelOrderItem',
url: "cancelRerouteOrderItem",
method: "post",
data: payload
});
Expand Down
21 changes: 15 additions & 6 deletions src/views/Order.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ export default defineComponent({
name: 'Shipping',
value: 'STANDARD'
}
]
],
token: ""
}
},
computed: {
Expand All @@ -162,6 +163,7 @@ export default defineComponent({
// invalid request
return;
}
this.token = this.$route.query.token as any
initialise({
token: this.$route.query.token,
instanceUrl: `${this.$route.query.oms}/api/`,
Expand Down Expand Up @@ -194,10 +196,14 @@ export default defineComponent({
await this.presentLoader()
let resp;
let order
if(!this.token) {
return;
}
try {
resp = await OrderService.getOrder();
if (!hasError(resp)) {
order = resp.data;
resp = await OrderService.getOrder(this.token);
if (!hasError(resp) && resp.data.order) {
order = resp.data.order;
const productIds: any = new Set();
order.shipGroup = order.shipGroup.filter((group: any) => {
if(group.facilityId === '_NA_') {
Expand Down Expand Up @@ -260,7 +266,8 @@ export default defineComponent({
"city": shipGroup.updatedAddress.city,
"stateProvinceGeoId": shipGroup.updatedAddress.stateProvinceGeoId,
"postalCode": shipGroup.updatedAddress.postalCode,
"countryGeoId": shipGroup.updatedAddress.countryGeoId
"countryGeoId": shipGroup.updatedAddress.countryGeoId,
"token": this.token
} as any
if (shipGroup.selectedShipmentMethodTypeId === shipGroup.shipmentMethodTypeId) {
Expand Down Expand Up @@ -294,6 +301,7 @@ export default defineComponent({
"shipmentMethod": "STOREPICKUP@_NA_@CARRIER", // TODO Check why CARRIER is needed
"contactMechPurposeTypeId": "SHIPPING_LOCATION",
"facilityId": shipGroup.selectedFacility.facilityId,
"token": this.token
}
try {
Expand Down Expand Up @@ -386,7 +394,8 @@ export default defineComponent({
const payload = {
"orderId": this.order.id,
"shipGroupSeqId": shipGroup.shipGroupSeqId,
"itemReasonMap": itemReasonMap
"itemReasonMap": itemReasonMap,
"token": this.token
} as any
try {
Expand Down

0 comments on commit cd3f227

Please sign in to comment.