Skip to content

Commit

Permalink
Merge pull request #319 from hotwax/312_order_detail_shipping_info
Browse files Browse the repository at this point in the history
Implemented: Added shipping detail on order detail page (#312).
  • Loading branch information
ravilodhi authored Oct 20, 2023
2 parents 8c572fd + 9b403ed commit 8176ec3
Show file tree
Hide file tree
Showing 8 changed files with 208 additions and 5 deletions.
3 changes: 3 additions & 0 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"Dismiss": "Dismiss",
"Delete": "Delete",
"Delete mapping": "Delete mapping",
"Destination": "Destination",
"eCom Store": "eCom Store",
"ECom inventory status updated successfully": "ECom inventory status updated successfully",
"Edit packaging": "Edit packaging",
Expand Down Expand Up @@ -100,6 +101,7 @@
"Generate shipping label": "Generate shipping label",
"Go to OMS": "Go to OMS",
"Go to Launchpad": "Go to Launchpad",
"Handling Instructions": "Handling Instructions",
"is identified as unfulfillable. other containing this product will be unassigned from this store and sent to be rebrokered.": "{ productName } is identified as unfulfillable. { space } { orders } other { orderText } containing this product will be unassigned from this store and sent to be rebrokered.",
"is identified as unfulfillable. This order item will be unassigned from this store and sent to be rebrokered.": "{ productName } is identified as unfulfillable. { space } This order item will be unassigned from this store and sent to be rebrokered.",
"is identified as. This order item will be unassigned from the store and sent to be rebrokered.": "{ productName } is identified as { rejectReason }. This order item will be unassigned from the store and sent to be rebrokered.",
Expand Down Expand Up @@ -127,6 +129,7 @@
"Mismatch": "Mismatch",
"Next day": "Next day",
"New mapping": "New mapping",
"No carrier error": "No carrier error",
"No data available!": "No data available!",
"No data Found.": "No data Found.",
"No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. To add a fulfillment capacity to this facility, use the custom option.": "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. {space}To add a fulfillment capacity to this facility, use the custom option.",
Expand Down
3 changes: 3 additions & 0 deletions src/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"Dismiss": "Dismiss",
"Delete": "Delete",
"Delete mapping": "Delete mapping",
"Destination": "Destination",
"eCom Store": "Tienda eCom",
"ECom inventory status updated successfully": "ECom inventory status updated successfully",
"Edit packaging": "Editar empaque",
Expand Down Expand Up @@ -100,6 +101,7 @@
"Generate shipping label": "Generate shipping label",
"Go to OMS": "Go to OMS",
"Go to Launchpad": "Go to Launchpad",
"Handling Instructions": "Handling Instructions",
"is identified as unfulfillable. other containing this product will be unassigned from this store and sent to be rebrokered.": "{ productName } is identified as unfulfillable. { space } { orders } other { orderText } containing this product will be unassigned from this store and sent to be rebrokered.",
"is identified as unfulfillable. This order item will be unassigned from this store and sent to be rebrokered.": "{ productName } is identified as unfulfillable. { space } This order item will be unassigned from this store and sent to be rebrokered.",
"is identified as. This order item will be unassigned from the store and sent to be rebrokered.": "{ productName } is identified as { rejectReason }. This order item will be unassigned from the store and sent to be rebrokered.",
Expand Down Expand Up @@ -129,6 +131,7 @@
"Next day": "Día siguiente",
"No Capacity": "No Capacity",
"No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. To add a fulfillment capacity to this facility, use the custom option.": "No capacity sets the fulfillment capacity to 0, preventing any new orders from being allocated to this facility. Use the \"Reject all orders\" option in the fulfillment pages to clear your facilities fulfillment queue. {space}To add a fulfillment capacity to this facility, use the custom option.",
"No carrier error": "No carrier error",
"No data available!": "No data available!",
"No data Found.": "No data Found.",
"No new file upload. Please try again": "No se cargó ningún archivo nuevo. Por favor, inténtalo nuevamente.",
Expand Down
64 changes: 63 additions & 1 deletion src/services/OrderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,66 @@ const fetchShipmentLabelError = async (shipmentIds: Array<string>): Promise<any>
return shipmentLabelError;
}

const fetchOrderItemShipGroup = async (order: any): Promise<any> => {
let shipGroup = {};

const params = {
"entityName": "OrderItemShipGroup",
"inputFields": {
"orderId": order.orderId,
"shipGroupSeqId": order.items[0].shipGroupSeqId,
},
"fieldList": ["orderId", "shipGroupSeqId", "facilityId", "shipmentMethodTypeId", "contactMechId"],
"distinct": "Y"
}

try {
const resp = await api({
url: "performFind",
method: "get",
params
})

if (!hasError(resp)) {
shipGroup = resp?.data.docs[0];
} else if (!resp?.data.error || (resp.data.error && resp.data.error !== "No record found")) {
return Promise.reject(resp?.data.error);
}
} catch (err) {
logger.error('Failed to fetch shipments for orders', err)
}

return shipGroup;
}

const fetchShippingAddress = async (contactMechId: string): Promise<any> => {
let shippingAddress = {};

const params = {
"entityName": "PostalAddressAndGeo",
"inputFields": {
"contactMechId": contactMechId,
},
}

try {
const resp = await api({
url: "performFind",
method: "get",
params
})

if (!hasError(resp)) {
shippingAddress = resp?.data.docs[0];
} else if (!resp?.data.error || (resp.data.error && resp.data.error !== "No record found")) {
return Promise.reject(resp?.data.error);
}
} catch (err) {
logger.error('Failed to fetch shipments for orders', err)
}
return shippingAddress;
}

export const OrderService = {
addShipmentBox,
bulkShipOrders,
Expand All @@ -396,5 +456,7 @@ export const OrderService = {
shipOrder,
unpackOrder,
updateOrder,
fetchShipmentLabelError
fetchShipmentLabelError,
fetchOrderItemShipGroup,
fetchShippingAddress
}
2 changes: 1 addition & 1 deletion src/store/modules/order/OrderState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ export default interface OrderState {
queryString: string
}
},
current: Array<any>,
current: any,
}
29 changes: 27 additions & 2 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ const actions: ActionTree<OrderState, RootState> = {
picklistBinId: orderItem.picklistBinId,
items: order.doclist.docs,
shipmentMethodTypeId: orderItem.shipmentMethodTypeId,
shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc
shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc,
shippingInstructions: orderItem.shippingInstructions
}
})
} else {
Expand Down Expand Up @@ -366,6 +367,7 @@ const actions: ActionTree<OrderState, RootState> = {
items: order.doclist.docs,
shipmentMethodTypeId: orderItem.shipmentMethodTypeId,
shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc,
shippingInstructions: orderItem.shippingInstructions,
reservedDatetime: orderItem.reservedDatetime
}
})
Expand Down Expand Up @@ -451,6 +453,7 @@ const actions: ActionTree<OrderState, RootState> = {
shipmentId: orderItem.shipmentId,
shipmentMethodTypeId: orderItem.shipmentMethodTypeId,
shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc,
shippingInstructions: orderItem.shippingInstructions,
isGeneratingShippingLabel: false,
isGeneratingPackingSlip: false
}
Expand All @@ -469,6 +472,27 @@ const actions: ActionTree<OrderState, RootState> = {
emitter.emit('dismissLoader');
return resp;
},
async fetchShippingAddress ({ commit }, currentOrder) {
let resp;

try {
resp = await OrderService.fetchOrderItemShipGroup(currentOrder);
if (resp) {
const contactMechId = resp.contactMechId;

resp = await OrderService.fetchShippingAddress(contactMechId);
if (resp) {
currentOrder = {
...currentOrder,
shippingAddress: resp
}
}
}
} catch (err: any) {
logger.error("Error in setting current order", err);
}
commit(types.ORDER_CURRENT_UPDATED, { order: currentOrder })
},

async clearOrders ({ commit }) {
commit(types.ORDER_INPROGRESS_CLEARED)
Expand Down Expand Up @@ -518,8 +542,9 @@ const actions: ActionTree<OrderState, RootState> = {
},

// TODO clear current on logout
updateCurrent ({ commit }, payload) {
async updateCurrent ({ commit, dispatch }, payload) {
commit(types.ORDER_CURRENT_UPDATED, { order: payload })
await dispatch('fetchShippingAddress', payload);
},
}

Expand Down
2 changes: 1 addition & 1 deletion src/store/modules/order/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const orderModule: Module<OrderState, RootState> = {
queryString: ''
}
},
current: []
current: {}
},
getters,
actions,
Expand Down
3 changes: 3 additions & 0 deletions src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
</div>
</div>
</ion-card>
<ShippingDetails />
</ion-content>
</ion-page>
</template>
Expand Down Expand Up @@ -214,6 +215,7 @@ import AssignPickerModal from '@/views/AssignPickerModal.vue';
import ShipmentBoxTypePopover from '@/components/ShipmentBoxTypePopover.vue'
import ShipmentBoxPopover from '@/components/ShipmentBoxPopover.vue'
import ReportIssuePopover from '@/components/ReportIssuePopover.vue'
import ShippingDetails from '@/views/ShippingDetails.vue';
export default defineComponent({
name: "OrderDetail",
Expand All @@ -237,6 +239,7 @@ export default defineComponent({
IonTitle,
IonToolbar,
IonThumbnail,
ShippingDetails
},
computed: {
...mapGetters({
Expand Down
107 changes: 107 additions & 0 deletions src/views/ShippingDetails.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<template>
<ion-card>
<ion-card-content>
<h2>{{ translate('Destination') }}</h2>
<ion-item lines="none">
<ion-label>
<h3>{{ currentOrder?.shippingAddress?.toName }}</h3>
<p>{{ currentOrder?.shippingAddress?.address1 }}</p>
<p v-if="currentOrder?.shippingAddress?.address2">{{ currentOrder?.shippingAddress?.address2 }}</p>
<p>{{ currentOrder?.shippingAddress?.city ? currentOrder?.shippingAddress?.city + "," : "" }} {{ currentOrder.shippingAddress?.zipCode }}</p>
<p>{{ currentOrder?.shippingAddress?.stateName ? currentOrder?.shippingAddress?.stateName + "," : "" }} {{ currentOrder.shippingAddress?.countryName }}</p>
</ion-label>
</ion-item>
<ion-item lines="none">
<ion-label>
<h2>{{ translate('Handling Instructions') }}</h2>
<p>{{ currentOrder?.shippingInstructions ? currentOrder?.shippingInstructions : "-" }}</p>
</ion-label>
</ion-item>
<ion-item lines="none" v-if="currentOrder.trackingCode">
<ion-label>
<p>{{ currentOrder.trackingCode }}</p>
</ion-label>
<ion-button fill="clear" @click="printShippingLabel(currentOrder)">
<ion-icon :icon="openOutline" slot="end"></ion-icon>
</ion-button>
</ion-item>
<ion-item lines="none" v-if="!currentOrder.trackingCode && ['PICKITEM_PICKED', 'PICKITEM_COMPLETED'].includes(currentOrder?.items[0]?.picklistItemStatusId)">
<ion-label v-for="message, index in shipmentLabelErrorMessages" :key="index">
{{ message }}
</ion-label>
<ion-label v-if="!shipmentLabelErrorMessages.length">
<p>{{ translate('No carrier error') }}</p>
</ion-label>
<ion-button fill="clear" @click="retryShippingLabel(currentOrder)">
<ion-icon :icon="refreshSharp" slot="end" ></ion-icon>
</ion-button>
</ion-item>
</ion-card-content>
</ion-card>
</template>

<script lang="ts">
import {
IonLabel,
IonItem,
IonCard,
IonCardContent
} from "@ionic/vue";
import { defineComponent } from "vue";
import { openOutline, refreshSharp } from "ionicons/icons";
import { useStore, mapGetters } from "vuex";
import { showToast } from '@/utils';
import { translate } from '@hotwax/dxp-components'
import { OrderService } from '@/services/OrderService';
import { hasError } from '@/adapter'
export default defineComponent({
name: "CreateMappingModal",
components: {
IonLabel,
IonItem,
IonCard,
IonCardContent
},
data() {
return {
shipmentLabelErrorMessages: []
}
},
computed: {
...mapGetters({
currentOrder: 'order/getCurrent'
})
},
async ionViewWillEnter() {
// Fetching shipment label errors
const shipmentIds = this.currentOrder.shipments.map((shipment: any) => shipment.shipmentId);
this.shipmentLabelErrorMessages = await OrderService.fetchShipmentLabelError(shipmentIds);
},
methods: {
async printShippingLabel(order: any) {
const shipmentIds = order.shipments.map((shipment: any) => shipment.shipmentId)
await OrderService.printShippingLabel(shipmentIds)
},
async retryShippingLabel(order: any) {
const shipmentIds = order.shipmentPackages.map((shipmentPackage: any) => shipmentPackage.shipmentId);
const resp = await OrderService.retryShippingLabel(shipmentIds)
if (!hasError(resp)) {
showToast(translate("Shipping Label generated successfully"))
await this.printShippingLabel(order)
} else {
showToast(translate("Failed to generate shipping label"))
}
}
},
setup() {
const store = useStore();
return {
openOutline,
refreshSharp,
translate,
store
};
}
});
</script>

0 comments on commit 8176ec3

Please sign in to comment.