Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented: Added the support for using productStore selector from dxp-component #722

Merged
merged 10 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improved: Added the support fro using productStore selector from dxp-…
…component
  • Loading branch information
R-Sourabh committed Sep 2, 2024
commit d25e2b341e9b67bf70092af0c5a8bd108d5a8795
454 changes: 95 additions & 359 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"@casl/ability": "^6.0.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.2.6",
"@hotwax/dxp-components": "^1.15.2",
"@hotwax/oms-api": "^1.14.0",
"@hotwax/dxp-components": "file:../dxp-components",
"@hotwax/oms-api": "file:../oms-api",
"@ionic/core": "^7.6.0",
"@ionic/vue": "^7.6.0",
"@ionic/vue-router": "^7.6.0",
Expand Down
10 changes: 7 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { mapGetters, useStore } from 'vuex';
import { initialise, resetConfig } from '@/adapter'
import { useRouter } from 'vue-router';
import { Settings } from 'luxon'
import { translate, useProductIdentificationStore } from '@hotwax/dxp-components';
import { translate, useProductIdentificationStore, useUserStore } from '@hotwax/dxp-components';
import logger from '@/logger'

export default defineComponent({
Expand All @@ -40,7 +40,7 @@ export default defineComponent({
instanceUrl: 'user/getInstanceUrl',
userProfile: 'user/getUserProfile',
locale: 'user/getLocale',
currentEComStore: 'user/getCurrentEComStore'
currentFacility: 'user/getCurrentFacility',
})
},
methods: {
Expand Down Expand Up @@ -127,11 +127,15 @@ export default defineComponent({
Settings.defaultZone = this.userProfile.userTimeZone;
}

// need to discuss this case
// await useUserStore().getEComStores('');
// await useUserStore().getPreferredStore('SELECTED_BRAND');
const currentEComStore: any = useUserStore().getCurrentEComStore;
// If fetching identifier without checking token then on login the app stucks in a loop, as the mounted hook runs before
// token is available which results in api failure as unauthenticated, thus making logout call and then login call again and so on.
if(this.userToken) {
// Get product identification from api using dxp-component
await useProductIdentificationStore().getIdentificationPref(this.currentEComStore?.productStoreId)
await useProductIdentificationStore().getIdentificationPref(currentEComStore.productStoreId)
.catch((error) => logger.error(error));
}
},
Expand Down
7 changes: 5 additions & 2 deletions src/adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import { api, client, getConfig, getNotificationEnumIds, getNotificationUserPrefTypeIds, getProductIdentificationPref, getUserFacilities, hasError, initialise, logout, removeClientRegistrationToken, resetConfig, setProductIdentificationPref, setUserLocale, storeClientRegistrationToken,
subscribeTopic, unsubscribeTopic, updateInstanceUrl, updateToken, setUserTimeZone, getAvailableTimeZones } from '@hotwax/oms-api'
subscribeTopic, unsubscribeTopic, updateInstanceUrl, updateToken, setUserTimeZone, getAvailableTimeZones, getUserPreference, setEComStore, getEComStores } from '@hotwax/oms-api'

export {
api,
Expand All @@ -23,5 +23,8 @@ export {
updateInstanceUrl,
updateToken,
setUserTimeZone,
getAvailableTimeZones
getAvailableTimeZones,
getUserPreference,
setEComStore,
getEComStores
}
1 change: 0 additions & 1 deletion src/components/ShippingLabelActionPopover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
...mapGetters({
facilityProductStores: 'facility/getFacilityProductStores',
getProductStore: 'util/getProductStore',
productStores: 'util/getProductStores',
shopifyShopIdForProductStore: 'util/getShopifyShopIdForProductStore',
current: 'facility/getCurrent'
})
Expand Down
12 changes: 7 additions & 5 deletions src/components/TransferOrderFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ import {
IonTitle,
IonToolbar
} from "@ionic/vue";
import { defineComponent } from "vue";
import { computed, defineComponent } from "vue";
import { albumsOutline, banOutline, barChartOutline, calendarNumberOutline, checkmarkDoneOutline, closeOutline, filterOutline, iceCreamOutline, libraryOutline, pulseOutline, settings, shirtOutline, ticketOutline } from "ionicons/icons";
import { mapGetters, useStore } from 'vuex'
import { escapeSolrSpecialChars, prepareOrderQuery } from '@/utils/solrHelper';
import { UtilService } from '@/services/UtilService';
import { hasError } from '@/adapter';
import logger from '@/logger';
import { translate } from '@hotwax/dxp-components';
import { translate, useUserStore } from '@hotwax/dxp-components';

export default defineComponent({
name: "TransferOrderFilters",
Expand Down Expand Up @@ -81,7 +81,6 @@ export default defineComponent({
transferOrders: 'transferorder/getTransferOrders',
getStatusDesc: 'util/getStatusDesc',
getShipmentMethodDesc: 'util/getShipmentMethodDesc',
currentEComStore: 'user/getCurrentEComStore',
})
},
async mounted() {
Expand Down Expand Up @@ -127,7 +126,7 @@ export default defineComponent({
'-orderStatusId': { value: 'ORDER_CREATED' },
orderTypeId: { value: 'TRANSFER_ORDER' },
facilityId: { value: escapeSolrSpecialChars(this.currentFacility.facilityId) },
productStoreId: { value: this.currentEComStore.productStoreId }
productStoreId: { value: this.currentEComStore.value?.productStoreId }
},
facet: {
"shipmentMethodTypeIdFacet":{
Expand Down Expand Up @@ -172,14 +171,17 @@ export default defineComponent({
},
setup() {
const store = useStore();

const userStore = useUserStore()
let currentEComStore: any = computed(() => userStore.getCurrentEComStore)

return {
albumsOutline,
banOutline,
barChartOutline,
calendarNumberOutline,
checkmarkDoneOutline,
closeOutline,
currentEComStore,
filterOutline,
iceCreamOutline,
libraryOutline,
Expand Down
7 changes: 5 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import permissionActions from '@/authorization/Actions';
import { dxpComponents } from '@hotwax/dxp-components';
import { login, logout, loader } from '@/utils/user';
import { getConfig, getProductIdentificationPref, initialise, setProductIdentificationPref, setUserLocale, setUserTimeZone,
getAvailableTimeZones } from './adapter';
getAvailableTimeZones, getUserPreference, setEComStore, getEComStores } from './adapter';
import localeMessages from '@/locales';
import { addNotification, storeClientRegistrationToken } from '@/utils/firebase';

Expand Down Expand Up @@ -67,7 +67,10 @@ const app = createApp(App)
setUserLocale,
setUserTimeZone,
storeClientRegistrationToken,
getAvailableTimeZones
getAvailableTimeZones,
getUserPreference,
setEComStore,
getEComStores
});

router.isReady().then(() => {
Expand Down
10 changes: 0 additions & 10 deletions src/services/UtilService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,6 @@ const fetchEnumeration = async (query: any): Promise <any> => {
})
}

const fetchProductStores = async (payload: any): Promise<any> => {
return api({
url: "performFind",
method: "POST",
data: payload,
cache: true
})
}

const fetchFacilities = async (payload: any): Promise<any> => {
return api({
url: "performFind",
Expand Down Expand Up @@ -485,7 +476,6 @@ export const UtilService = {
fetchFacilityTypeInformation,
fetchPartyInformation,
fetchPicklistInformation,
fetchProductStores,
fetchRejectReasonEnumTypes,
fetchRejectReasons,
fetchShipmentGatewayConfigs,
Expand Down
7 changes: 4 additions & 3 deletions src/store/modules/carrier/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { hasError } from '@/adapter'
import * as types from './mutation-types'
import logger from '@/logger'
import store from '@/store';
import { translate } from '@hotwax/dxp-components';
import { translate, useUserStore } from '@hotwax/dxp-components';
import { showToast, isValidCarrierCode, isValidDeliveryDays } from '@/utils';


Expand Down Expand Up @@ -184,7 +184,7 @@ const actions: ActionTree<CarrierState, RootState> = {
const currentCarrier = state.current;
const carrierShipmentMethods = currentCarrier.shipmentMethods
const carrierProductStoreShipmentMethods = currentCarrier.productStoreShipmentMethods
const productStores = store.getters['util/getProductStores'];
const productStores = useUserStore().getProductStores;
const carrierShipmentMethodsByProductStore = {} as any;
const productStoreShipmentMethodFields = ["description", "productStoreId", "isTrackingRequired", "shipmentGatewayConfigId", "productStoreShipMethId"]

Expand Down Expand Up @@ -427,6 +427,7 @@ const actions: ActionTree<CarrierState, RootState> = {
commit(types.CARRIER_FACILITY_CARRIERS_UPDATED, facilityCarriers)
},
async fetchProductStoreShipmentMeths({ state, commit }) {
const currentEComStore: any = useUserStore().getCurrentEComStore;
let productStoreShipmentMethods = [] as any;
let viewIndex = 0, resp;

Expand All @@ -436,7 +437,7 @@ const actions: ActionTree<CarrierState, RootState> = {
"entityName": "ProductStoreShipmentMethView",
"inputFields": {
"roleTypeId": "CARRIER",
"productStoreId": this.state.user.currentEComStore.productStoreId,
"productStoreId": currentEComStore.productStoreId,
},
"fieldList": ["productStoreShipMethId", "productStoreId", "partyId", "roleTypeId", "shipmentMethodTypeId", "shipmentGatewayConfigId", "isTrackingRequired", "sequenceNumber", "description", "fromDate"],
"noConditionFind": "Y",
Expand Down
18 changes: 12 additions & 6 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import { escapeSolrSpecialChars, prepareOrderQuery } from '@/utils/solrHelper'
import { UtilService } from '@/services/UtilService'
import logger from '@/logger'
import { getOrderCategory, removeKitComponents } from '@/utils/order'
import { useUserStore } from '@hotwax/dxp-components'

const getProductStoreId = () => {
const currentEComStore: any = useUserStore().getCurrentEComStore;
return currentEComStore.productStoreId
};

const actions: ActionTree<OrderState, RootState> = {
async fetchInProgressOrdersAdditionalInformation({ commit, state }, payload = { viewIndex: 0 }) {
Expand Down Expand Up @@ -257,7 +263,7 @@ const actions: ActionTree<OrderState, RootState> = {
'-fulfillmentStatus': { value: ['Rejected', 'Cancelled'] },
'-shipmentMethodTypeId': { value: 'STOREPICKUP' },
facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) },
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
productStoreId: { value: getProductStoreId() }
}
}

Expand Down Expand Up @@ -351,7 +357,7 @@ const actions: ActionTree<OrderState, RootState> = {
orderStatusId: { value: 'ORDER_APPROVED' },
orderTypeId: { value: 'SALES_ORDER' },
facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) },
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
productStoreId: { value: getProductStoreId() }
}
}

Expand Down Expand Up @@ -422,7 +428,7 @@ const actions: ActionTree<OrderState, RootState> = {
picklistItemStatusId: { value: '(PICKITEM_PICKED OR (PICKITEM_COMPLETED AND itemShippedDate: [NOW/DAY TO NOW/DAY+1DAY]))' },
'-shipmentMethodTypeId': { value: 'STOREPICKUP' },
facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) },
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
productStoreId: { value: getProductStoreId() }
}
}

Expand Down Expand Up @@ -696,7 +702,7 @@ const actions: ActionTree<OrderState, RootState> = {
orderStatusId: { value: 'ORDER_APPROVED' },
orderTypeId: { value: 'SALES_ORDER' },
facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) },
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
productStoreId: { value: getProductStoreId() }
}
}
const orderQueryPayload = prepareOrderQuery(params)
Expand Down Expand Up @@ -765,7 +771,7 @@ const actions: ActionTree<OrderState, RootState> = {
'-fulfillmentStatus': { value: ['Cancelled', 'Rejected']},
'-shipmentMethodTypeId': { value: 'STOREPICKUP' },
facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) },
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
productStoreId: { value: getProductStoreId() }
}
}

Expand Down Expand Up @@ -832,7 +838,7 @@ const actions: ActionTree<OrderState, RootState> = {
'-shipmentMethodTypeId': { value: 'STOREPICKUP' },
shipGroupSeqId: { value: payload.shipGroupSeqId },
facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) },
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
productStoreId: { value: getProductStoreId() }
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/store/modules/transferorder/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import { hasError } from '@/adapter'
import * as types from './mutation-types'
import { escapeSolrSpecialChars, prepareOrderQuery } from '@/utils/solrHelper'
import logger from '@/logger'
import { shopifyImgContext, translate } from '@hotwax/dxp-components'
import { shopifyImgContext, translate, useUserStore } from '@hotwax/dxp-components'
import { showToast } from "@/utils";
import { UtilService } from '@/services/UtilService'

const actions: ActionTree<TransferOrderState, RootState> = {

async findTransferOrders ({ commit, state }, payload = {}) {
const currentEComStore: any = useUserStore().getCurrentEComStore;
emitter.emit('presentLoader');
let resp;
const transferOrderQuery = JSON.parse(JSON.stringify(state.transferOrder.query))
Expand All @@ -29,7 +30,7 @@ const actions: ActionTree<TransferOrderState, RootState> = {
filters: {
orderTypeId: { value: 'TRANSFER_ORDER' },
facilityId: { value: escapeSolrSpecialChars(this.state.user.currentFacility.facilityId) },
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
productStoreId: { value: currentEComStore.productStoreId }
}
}

Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export default interface UserState {
pwaState: any;
currentFacility: object;
instanceUrl: string;
currentEComStore: object;
preference: {
printShippingLabel: boolean,
printPackingSlip: boolean
Expand Down
Loading
Loading