Skip to content

Commit

Permalink
Merge pull request #722 from R-Sourabh/product-store-selector
Browse files Browse the repository at this point in the history
Implemented: Added the support for using productStore selector from dxp-component
  • Loading branch information
ymaheshwari1 authored Dec 18, 2024
2 parents 92e48ed + 336113e commit 99f2f8c
Show file tree
Hide file tree
Showing 25 changed files with 77 additions and 168 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 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'
import { init, loadRemote } from '@module-federation/runtime';

Check warning on line 22 in src/App.vue

View workflow job for this annotation

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

'loadRemote' is defined but never used

Check warning on line 22 in src/App.vue

View workflow job for this annotation

GitHub Actions / call-workflow-in-another-repo / build_and_deploy

'loadRemote' is defined but never used

Check warning on line 22 in src/App.vue

View workflow job for this annotation

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

'loadRemote' is defined but never used
Expand All @@ -41,7 +41,6 @@ export default defineComponent({
instanceUrl: 'user/getInstanceUrl',
userProfile: 'user/getUserProfile',
locale: 'user/getLocale',
currentEComStore: 'user/getCurrentEComStore'
})
},
methods: {
Expand Down Expand Up @@ -138,11 +137,12 @@ export default defineComponent({
Settings.defaultZone = this.userProfile.userTimeZone;
}
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) {
if(this.userToken && currentEComStore?.productStoreId) {
// 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
5 changes: 3 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, fetchGoodIdentificationTypes, getUserFacilities, getUserPreference, hasError, initialise, logout, removeClientRegistrationToken, resetConfig, setProductIdentificationPref, setUserLocale, storeClientRegistrationToken,
subscribeTopic, unsubscribeTopic, updateInstanceUrl, updateToken, setUserTimeZone, setUserPreference, getAvailableTimeZones } from '@hotwax/oms-api'
subscribeTopic, unsubscribeTopic, updateInstanceUrl, updateToken, setUserTimeZone, setUserPreference, getAvailableTimeZones, getEComStoresByFacility } from '@hotwax/oms-api'

export {
api,
Expand All @@ -26,5 +26,6 @@ export {
updateToken,
setUserTimeZone,
setUserPreference,
getAvailableTimeZones
getAvailableTimeZones,
getEComStoresByFacility
}
5 changes: 3 additions & 2 deletions src/components/TransferOrderFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ export default defineComponent({
transferOrders: 'transferorder/getTransferOrders',
getStatusDesc: 'util/getStatusDesc',
getShipmentMethodDesc: 'util/getShipmentMethodDesc',
currentEComStore: 'user/getCurrentEComStore',
})
},
async mounted() {
Expand Down Expand Up @@ -173,7 +172,8 @@ export default defineComponent({
const store = useStore();
const userStore = useUserStore()
let currentFacility: any = computed(() => userStore.getCurrentFacility)
let currentEComStore: any = computed(() => userStore.getCurrentEComStore)
return {
albumsOutline,
banOutline,
Expand All @@ -182,6 +182,7 @@ export default defineComponent({
checkmarkDoneOutline,
closeOutline,
currentFacility,
currentEComStore,
filterOutline,
iceCreamOutline,
libraryOutline,
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import permissionRules from '@/authorization/Rules';
import permissionActions from '@/authorization/Actions';
import { dxpComponents } from '@hotwax/dxp-components';
import { login, logout, loader } from '@/utils/user';
import { getConfig, fetchGoodIdentificationTypes, getProductIdentificationPref, getUserFacilities, getUserPreference, initialise, setProductIdentificationPref, setUserLocale, getAvailableTimeZones, setUserTimeZone,
import { getConfig, fetchGoodIdentificationTypes, getEComStoresByFacility, getProductIdentificationPref, getUserFacilities, getUserPreference, initialise, setProductIdentificationPref, setUserLocale, getAvailableTimeZones, setUserTimeZone,
setUserPreference } from './adapter';
import localeMessages from '@/locales';
import { addNotification, storeClientRegistrationToken } from '@/utils/firebase';
Expand Down Expand Up @@ -62,6 +62,7 @@ const app = createApp(App)
appFirebaseVapidKey: process.env.VUE_APP_FIREBASE_VAPID_KEY,
getConfig,
fetchGoodIdentificationTypes,
getEComStoresByFacility,
getProductIdentificationPref,
initialise,
setProductIdentificationPref,
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import("./index")
import("./index")
44 changes: 0 additions & 44 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,49 +85,6 @@ const recycleOutstandingOrders = async(payload: any): Promise<any> => {
})
}

const getEComStores = async (token: any, facility: any): Promise<any> => {
try {
const params = {
"inputFields": {
"storeName_op": "not-empty",
facilityId: facility.facilityId
},
"fieldList": ["productStoreId", "storeName"],
"entityName": "ProductStoreFacilityDetail",
"distinct": "Y",
"noConditionFind": "Y",
"filterByDate": 'Y',
}
const baseURL = store.getters['user/getBaseUrl'];
const resp = await client({
url: "performFind",
method: "get",
baseURL,
params,
headers: {
Authorization: 'Bearer ' + token,
'Content-Type': 'application/json'
}
});
if (hasError(resp)) {
// Following promise reject pattern as OMS api, to show error message on the login page.
return Promise.reject({
code: 'error',
message: `Failed to fetch product stores for ${facility.facilityName} facility.`,
serverResponse: resp.data
})
} else {
return Promise.resolve(resp.data.docs);
}
} catch(error: any) {
return Promise.reject({
code: 'error',
message: 'Something went wrong',
serverResponse: error
})
}
}

const getPreferredStore = async (token: any): Promise<any> => {
const baseURL = store.getters['user/getBaseUrl'];
try {
Expand Down Expand Up @@ -416,7 +373,6 @@ export const UserService = {
getCollateralRejectionConfig,
getDisableShipNowConfig,
getDisableUnpackConfig,
getEComStores,
getFacilityDetails,
getFacilityOrderCount,
getFieldMappings,
Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/carrier/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as types from './mutation-types'
import logger from '@/logger'
import store from '@/store';
import { translate } from '@hotwax/dxp-components';
import { showToast, isValidCarrierCode, isValidDeliveryDays, getCurrentFacilityId } from '@/utils';
import { showToast, isValidCarrierCode, isValidDeliveryDays, getCurrentFacilityId, getProductStoreId } from '@/utils';


const actions: ActionTree<CarrierState, RootState> = {
Expand Down Expand Up @@ -437,7 +437,7 @@ const actions: ActionTree<CarrierState, RootState> = {
"entityName": "ProductStoreShipmentMethView",
"inputFields": {
"roleTypeId": "CARRIER",
"productStoreId": this.state.user.currentEComStore.productStoreId,
"productStoreId": getProductStoreId(),
"shipmentMethodTypeId": "STOREPICKUP",
"shipmentMethodTypeId_op": "notEqual"
},
Expand Down
14 changes: 7 additions & 7 deletions src/store/modules/order/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { escapeSolrSpecialChars, prepareOrderQuery } from '@/utils/solrHelper'
import { UtilService } from '@/services/UtilService'
import logger from '@/logger'
import { getOrderCategory, removeKitComponents } from '@/utils/order'
import { getCurrentFacilityId } from '@/utils'
import { getCurrentFacilityId, getProductStoreId } from '@/utils'

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

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

Expand Down Expand Up @@ -491,7 +491,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(getCurrentFacilityId()) },
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
productStoreId: { value: getProductStoreId() }
}
}

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

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

Expand Down
4 changes: 2 additions & 2 deletions src/store/modules/transferorder/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as types from './mutation-types'
import { escapeSolrSpecialChars, prepareOrderQuery } from '@/utils/solrHelper'
import logger from '@/logger'
import { getProductIdentificationValue, translate } from '@hotwax/dxp-components'
import { showToast, getCurrentFacilityId } from "@/utils";
import { showToast, getCurrentFacilityId, getProductStoreId } from "@/utils";
import { UtilService } from '@/services/UtilService'
import store from "@/store";

Expand All @@ -30,7 +30,7 @@ const actions: ActionTree<TransferOrderState, RootState> = {
filters: {
orderTypeId: { value: 'TRANSFER_ORDER' },
facilityId: { value: escapeSolrSpecialChars(getCurrentFacilityId()) },
productStoreId: { value: this.state.user.currentEComStore.productStoreId }
productStoreId: { value: getProductStoreId() }
}
}

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 @@ -4,7 +4,6 @@ export default interface UserState {
permissions: any;
pwaState: any;
instanceUrl: string;
currentEComStore: object;
preference: {
printShippingLabel: boolean,
printPackingSlip: boolean
Expand Down
Loading

0 comments on commit 99f2f8c

Please sign in to comment.