Skip to content

Commit

Permalink
Improved: actions to fetch product info for sinlge ordes
Browse files Browse the repository at this point in the history
  • Loading branch information
k2maan committed Oct 23, 2023
1 parent a3460d0 commit a4232a1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
1 change: 1 addition & 0 deletions src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const routes: Array<RouteRecordRaw> = [
name: 'OrderDetail',
component: OrderDetail,
beforeEnter: authGuard,
props: true,
meta: {
permissionId: "APP_ORDER_DETAIL_VIEW"
}
Expand Down
12 changes: 6 additions & 6 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ const actions: ActionTree<OrderState, RootState> = {
}
}

let resp, order = {};
let resp, order = {} as any;
emitter.emit('presentLoader');

const params = {
Expand Down Expand Up @@ -603,7 +603,7 @@ const actions: ActionTree<OrderState, RootState> = {
shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc,
reservedDatetime: orderItem.reservedDatetime
}
this.dispatch('product/getProductInformation', order)
await this.dispatch('product/fetchProducts', { productIds: order.items.map((item: any) => item.productId) })
} else {
throw resp.data
}
Expand Down Expand Up @@ -633,7 +633,7 @@ const actions: ActionTree<OrderState, RootState> = {
}
}
emitter.emit('presentLoader');
let resp, order = {};
let resp, order = {} as any;

try {
const params = {
Expand Down Expand Up @@ -669,7 +669,7 @@ const actions: ActionTree<OrderState, RootState> = {
shipmentMethodTypeId: orderItem.shipmentMethodTypeId,
shipmentMethodTypeDesc: orderItem.shipmentMethodTypeDesc,
}
this.dispatch('product/getProductInformation', order)
await this.dispatch('product/fetchProducts', { productIds: order.items.map((item: any) => item.productId) })
} else {
throw resp.data
}
Expand Down Expand Up @@ -698,7 +698,7 @@ const actions: ActionTree<OrderState, RootState> = {
}
}
emitter.emit('presentLoader');
let resp, order = {};
let resp, order = {} as any;

try {
const params = {
Expand Down Expand Up @@ -738,7 +738,7 @@ const actions: ActionTree<OrderState, RootState> = {
isGeneratingPackingSlip: false
}

this.dispatch('product/getProductInformation', order)
await this.dispatch('product/fetchProducts', { productIds: order.items.map((item: any) => item.productId) })
} else {
throw resp.data
}
Expand Down
15 changes: 5 additions & 10 deletions src/store/modules/product/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,13 @@ const actions: ActionTree<ProductState, RootState> = {
return resp;
},

async getProductInformation ({ dispatch }, payload) {
async getProductInformation({ dispatch }, { orders }) {
let productIds: any = new Set();
// checking if its a single order or multiple orders
Array.isArray(payload) ?
payload.forEach((list: any) => {
list.doclist.docs.forEach((order: any) => {
if (order.productId) productIds.add(order.productId)
})
}) :
payload.items.forEach((item: any) => {
if (item.productId) productIds.add(item.productId)
orders.forEach((list: any) => {
list.doclist.docs.forEach((order: any) => {
if (order.productId) productIds.add(order.productId)
})
})

productIds = [...productIds]
if (productIds.length) {
Expand Down
6 changes: 4 additions & 2 deletions src/views/OrderDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@
<ion-skeleton-text animated />
<ion-skeleton-text animated />
</div>
<div class="box-type desktop-only" v-else-if="order.shipmentPackages">
<ion-button :disabled="addingBoxForOrderIds.includes(order.orderId)" @click.stop="addShipmentBox(order)" fill="outline" shape="round" size="small"><ion-icon :icon="addOutline" />{{ translate("Add Box") }}</ion-button>
<div class="box-type desktop-only" v-else-if="order.shipmentPackages">
<ion-button :disabled="addingBoxForOrderIds.includes(order.orderId)" @click.stop="addShipmentBox(order)" fill="outline" shape="round" size="small"><ion-icon :icon="addOutline" />
{{ translate("Add Box") }}
</ion-button>
<ion-row>
<ion-chip v-for="shipmentPackage in order.shipmentPackages" :key="shipmentPackage.shipmentId" @click.stop="updateShipmentBoxType(shipmentPackage, order, $event)">
{{ `Box ${shipmentPackage?.packageName}` }} {{ shipmentPackage.shipmentBoxTypes.length ? `| ${boxTypeDesc(getShipmentPackageType(shipmentPackage))}` : '' }}
Expand Down

0 comments on commit a4232a1

Please sign in to comment.