Skip to content

Commit

Permalink
Improved: logic by using ternary operator instead for nested if state…
Browse files Browse the repository at this point in the history
…ment
  • Loading branch information
Ritika-Patel08 committed Feb 13, 2024
1 parent 62d33f8 commit 998d4d1
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/store/modules/shipment/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@hotwax/dxp-components'
import emitter from '@/event-bus'
import { Item } from "@ionic/core/dist/types/components/item/item";

Check warning on line 9 in src/store/modules/shipment/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (18.x)

'Item' is defined but never used

Check warning on line 9 in src/store/modules/shipment/actions.ts

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / reusable_workflow_job (20.x)

'Item' is defined but never used

const actions: ActionTree<ShipmentState, RootState> = {
async findShipment ({ commit, state }, payload) {
Expand Down Expand Up @@ -34,13 +35,9 @@ const actions: ActionTree<ShipmentState, RootState> = {
},

async updateShipmentProductCount ({ commit, state }, payload) {
const findItem = state.current.items.find((item:any) => item.sku === payload);

if (findItem ) {
if (findItem.quantityAccepted === "") {
findItem.quantityAccepted = 0;
}
findItem.quantityAccepted = parseInt(findItem.quantityAccepted) + 1;
const item = state.current.items.find((item: any)=> item.sku === payload);
if (item) {
item.quantityAccepted = item.quantityAccepted ? parseInt(item.quantityAccepted) + 1 : parseInt("0") + 1;
} else {
showToast(translate("Product not found"));
}
Expand Down

0 comments on commit 998d4d1

Please sign in to comment.