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 4 commits
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
268 changes: 121 additions & 147 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
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 / reusable_workflow_job (20.x)

'loadRemote' is defined but never used

export default defineComponent({
name: 'App',
Expand All @@ -41,7 +41,6 @@
instanceUrl: 'user/getInstanceUrl',
userProfile: 'user/getUserProfile',
locale: 'user/getLocale',
currentEComStore: 'user/getCurrentEComStore'
})
},
methods: {
Expand Down Expand Up @@ -138,11 +137,15 @@
Settings.defaultZone = this.userProfile.userTimeZone;
}

// need to discuss this case
// await useUserStore().getEComStoresByFacility('');
// 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
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
}
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
11 changes: 6 additions & 5 deletions src/components/TransferOrderFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import {
IonTitle,
IonToolbar
} from "@ionic/vue";
import { defineComponent, computed } 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';
Expand Down 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 @@ -125,8 +124,8 @@ export default defineComponent({
filters: {
'-orderStatusId': { value: 'ORDER_CREATED' },
orderTypeId: { value: 'TRANSFER_ORDER' },
facilityId: { value: escapeSolrSpecialChars(this.currentFacility?.facilityId) },
productStoreId: { value: this.currentEComStore.productStoreId }
facilityId: { value: escapeSolrSpecialChars(this.currentFacility.facilityId) },
productStoreId: { value: this.currentEComStore?.productStoreId }
},
facet: {
"shipmentMethodTypeIdFacet":{
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
10 changes: 0 additions & 10 deletions src/services/UtilService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,15 +449,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 @@ -652,7 +643,6 @@ export const UtilService = {
fetchGiftCardItemPriceInfo,
fetchPartyInformation,
fetchPicklistInformation,
fetchProductStores,
fetchRejectReasonEnumTypes,
fetchRejectReasons,
fetchShipmentGatewayConfigs,
Expand Down
8 changes: 4 additions & 4 deletions src/store/modules/carrier/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
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 { translate, useUserStore } from '@hotwax/dxp-components';
import { showToast, isValidCarrierCode, isValidDeliveryDays, getCurrentFacilityId, getProductStoreId } from '@/utils';


const actions: ActionTree<CarrierState, RootState> = {
Expand Down Expand Up @@ -184,7 +184,7 @@
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 @@ -251,7 +251,7 @@
commit(types.SHIPMENT_METHODS_UPDATED, shipmentMethods)
},

async fetchCarrierFacilities({ state, commit }, payload) {

Check warning on line 254 in src/store/modules/carrier/actions.ts

View workflow job for this annotation

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

'payload' is defined but never used

Check warning on line 254 in src/store/modules/carrier/actions.ts

View workflow job for this annotation

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

'payload' is defined but never used
let currentCarrier = JSON.parse(JSON.stringify(state.current))
let carrierFacilities = [] as any;
let viewIndex = 0, resp, docCount = 0;
Expand Down Expand Up @@ -355,7 +355,7 @@
}
},

async fetchFacilityCarriers({ state, commit }, payload) {

Check warning on line 358 in src/store/modules/carrier/actions.ts

View workflow job for this annotation

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

'state' is defined but never used

Check warning on line 358 in src/store/modules/carrier/actions.ts

View workflow job for this annotation

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

'payload' is defined but never used

Check warning on line 358 in src/store/modules/carrier/actions.ts

View workflow job for this annotation

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

'state' is defined but never used

Check warning on line 358 in src/store/modules/carrier/actions.ts

View workflow job for this annotation

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

'payload' is defined but never used
let facilityCarriers = [] as any;
let viewIndex = 0, resp, docCount = 0;

Expand Down Expand Up @@ -426,7 +426,7 @@

commit(types.CARRIER_FACILITY_CARRIERS_UPDATED, facilityCarriers)
},
async fetchProductStoreShipmentMeths({ state, commit }) {

Check warning on line 429 in src/store/modules/carrier/actions.ts

View workflow job for this annotation

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

'state' is defined but never used

Check warning on line 429 in src/store/modules/carrier/actions.ts

View workflow job for this annotation

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

'state' is defined but never used
let productStoreShipmentMethods = [] as any;
let viewIndex = 0, resp;

Expand All @@ -436,7 +436,7 @@
"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
Loading