Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/hotwax/preorder into #237
Browse files Browse the repository at this point in the history
  • Loading branch information
ravilodhi committed Nov 19, 2024
2 parents 803126b + 3985614 commit 521620a
Show file tree
Hide file tree
Showing 13 changed files with 125 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ VUE_APP_POLL_TIME=10000
VUE_APP_ORDER_FILTERS=["orderTypeId: SALES_ORDER", "facilityId:PRE_ORDER_PARKING OR facilityId:BACKORDER_PARKING", "orderStatusId: ORDER_APPROVED", "!orderItemStatusId: ITEM_CANCELLED" ]
VUE_APP_BASE_URL=
VUE_APP_ORDER_IN_BRKRNG_FILTERS=["orderTypeId: SALES_ORDER", "facilityId: _NA_", "orderStatusId: ORDER_APPROVED", "!orderItemStatusId: ITEM_CANCELLED" ]
VUE_APP_PERMISSION_ID=
VUE_APP_PERMISSION_ID="PREORDER_APP_VIEW"
VUE_APP_ALIAS=
VUE_APP_CTGRY_AND_BRKRNG_JOB=["JOB_REL_PREODR_CAT", "JOB_BKR_ORD", "JOB_RLS_ORD_DTE"]
VUE_APP_DEFAULT_ALIAS=
Expand Down
90 changes: 68 additions & 22 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "preorder-app",
"version": "1.17.0",
"version": "1.19.0",
"private": true,
"description": "HotWax Commece Pre-order App",
"scripts": {
Expand All @@ -19,7 +19,7 @@
"@casl/ability": "^6.0.0",
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.2.6",
"@hotwax/dxp-components": "1.13.0",
"@hotwax/dxp-components": "^1.15.4",
"@hotwax/oms-api": "1.14.0",
"@ionic/core": "^7.6.0",
"@ionic/vue": "^7.6.0",
Expand Down
1 change: 1 addition & 0 deletions src/authorization/Actions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export default {
"APP_INV_CNFG_UPDT": "APP_INV_CNFG_UPDT",
"APP_COMMERCE_VIEW": "APP_COMMERCE_VIEW"
}
5 changes: 4 additions & 1 deletion src/authorization/Rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,8 @@ export default {
"APP_CATALOG_VIEW": "",
"APP_PRDT_DTLS_VIEW": "",
"APP_CTLG_PRDT_DTLS_VIEW": "",
"APP_INV_CNFG_UPDT": "COMMON_ADMIN"
"APP_COMMERCE_VIEW": "COMMERCEUSER_VIEW",
"MERCHANDISING_ADMIN": "MERCHANDISING_ADMIN",
"PREORDER_APP_VIEW": "PREORDER_APP_VIEW",
"APP_INV_CNFG_UPDT": "COMMON_ADMIN",
} as any
6 changes: 4 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import '@ionic/vue/css/display.css';
import './theme/variables.css';
import { dxpComponents } from '@hotwax/dxp-components'
import { login, logout, loader } from './user-utils';
import permissionPlugin from '@/authorization';
import permissionPlugin, { Actions, hasPermission } from '@/authorization';
import permissionRules from '@/authorization/Rules';
import permissionActions from '@/authorization/Actions';
import { setUserTimeZone, getAvailableTimeZones, setUserLocale} from '@/adapter'
Expand All @@ -49,6 +49,7 @@ const app = createApp(App)
actions: permissionActions
})
.use(dxpComponents, {
Actions,
defaultImgUrl: require("@/assets/images/defaultImage.png"),
login,
logout,
Expand All @@ -61,7 +62,8 @@ const app = createApp(App)
setUserTimeZone,
getAvailableTimeZones,
getProductIdentificationPref,
setProductIdentificationPref
setProductIdentificationPref,
hasPermission
});

// Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters
Expand Down
12 changes: 8 additions & 4 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@ const setUserPreference = async (payload: any): Promise<any> => {
});
}

const getEComStores = async (token: any, partyId: any): Promise<any> => {
const getEComStores = async (token: any, partyId: any, isAdminUser = false): Promise<any> => {
try {
const params = {
"inputFields": {
"storeName_op": "not-empty",
"partyId": partyId
"storeName_op": "not-empty"
},
"fieldList": ["productStoreId", "storeName"],
"entityName": "ProductStoreAndRole",
"distinct": "Y",
"noConditionFind": "Y"
"noConditionFind": "Y",
"filterByDate": 'Y'
} as any;

if(!isAdminUser) {
params.inputFields['partyId'] = partyId
}

const baseURL = store.getters['user/getBaseUrl'];
Expand Down
36 changes: 25 additions & 11 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,31 @@ const actions: ActionTree<UserState, RootState> = {
}
}

// Getting user profile
const userProfile = await UserService.getUserProfile(token);
userProfile.stores = await UserService.getEComStores(token, userProfile.partyId);

// Getting user preferred store
let preferredStore = userProfile.stores[0];
const preferredStoreId = await UserService.getPreferredStore(token);
if (preferredStoreId) {
const store = userProfile.stores.find((store: any) => store.productStoreId === preferredStoreId);
store && (preferredStore = store)
}
const isAdminUser = appPermissions.some((appPermission: any) => appPermission?.action === "MERCHANDISING_ADMIN");

// Getting user profile
const userProfile = await UserService.getUserProfile(token);
userProfile.stores = await UserService.getEComStores(token, userProfile.partyId, isAdminUser);

// Getting user preferred store
let preferredStore = userProfile.stores[0];
const preferredStoreId = await UserService.getPreferredStore(token);
if (preferredStoreId) {
const store = userProfile.stores.find((store: any) => store.productStoreId === preferredStoreId);
store && (preferredStore = store)
}

setPermissions(appPermissions);
if (userProfile.userTimeZone) {
Settings.defaultZone = userProfile.userTimeZone;
}

// TODO user single mutation
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, preferredStore);
commit(types.USER_INFO_UPDATED, userProfile);
commit(types.USER_TOKEN_CHANGED, { newToken: token });
commit(types.USER_PERMISSIONS_UPDATED, appPermissions);
updateToken(token);

// Get product identification from api using dxp-component
await useProductIdentificationStore().getIdentificationPref(preferredStoreId)
Expand Down
2 changes: 1 addition & 1 deletion src/views/order-popover.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default defineComponent({
orderId: item.orderId,
orderItemSeqId: item.orderItemSeqId,
changeReasonEnumId: "RELEASED",
toFacilityId: "_NA_" // TODO Make it configurable
toFacilityId: "RELEASED_ORD_PARKING" // TODO Make it configurable
})
},
async cancelItem (item: any) {
Expand Down
5 changes: 4 additions & 1 deletion src/views/orders.vue
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export default defineComponent({
selectedItemsCount: 'order/getSelectedItemsCount',
userProfile: 'user/getUserProfile',
query: 'order/getQuery',
currentEComStore: 'user/getCurrentEComStore',
}),
},
async ionViewWillEnter() {
Expand Down Expand Up @@ -319,13 +320,14 @@ export default defineComponent({
},
async releaseItems() {
emitter.emit("presentLoader")
const selectedItems = this.getSelectedItemsToRelease("_NA_", "RELEASED"); // TODO Make it configurable
const selectedItems = this.getSelectedItemsToRelease("RELEASED_ORD_PARKING", "RELEASED"); // TODO Make it configurable
const json = JSON.stringify(selectedItems);
const blob = new Blob([json], { type: 'application/json'});
const formData = new FormData();
const fileName = "ReleaseItems_" + Date.now() +".json";
formData.append("uploadedFile", blob, fileName);
formData.append("configId", "MDM_REL_ORD_ITM_JSON");
formData.append("param_productStoreId", this.currentEComStore.productStoreId);
this.deselectSelectedItems();
return this.store.dispatch("order/releaseItems", {
headers: {
Expand All @@ -346,6 +348,7 @@ export default defineComponent({
const fileName = "CancelItems_" + Date.now() +".json";
formData.append("uploadedFile", blob, fileName);
formData.append("configId", "MDM_CAN_ORD_ITM_JSON");
formData.append("param_productStoreId", this.currentEComStore.productStoreId);
this.deselectSelectedItems();
return this.store.dispatch("order/cancelItems", {
headers: {
Expand Down
5 changes: 4 additions & 1 deletion src/views/product-details.vue
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ export default defineComponent({
orderId: item.orderId,
orderItemSeqId: item.orderItemSeqId,
changeReasonEnumId: "RELEASED",
toFacilityId: "_NA_" // TODO Make it configurable
toFacilityId: "RELEASED_ORD_PARKING" // TODO Make it configurable
}
})
selectedItems = [...selectedItems, ...items];
Expand All @@ -447,6 +447,8 @@ export default defineComponent({
const fileName = "ReleaseItems_" + Date.now() +".json";
formData.append("uploadedFile", blob, fileName);
formData.append("configId", "MDM_REL_ORD_ITM_JSON");
formData.append("param_productStoreId", this.currentEComStore.productStoreId);
return this.store.dispatch("order/releaseItems", {
headers: {
'Content-Type': 'multipart/form-data;'
Expand Down Expand Up @@ -475,6 +477,7 @@ export default defineComponent({
const fileName = "CancelItems_" + Date.now() +".json";
formData.append("uploadedFile", blob, fileName);
formData.append("configId", "MDM_CAN_ORD_ITM_JSON");
formData.append("param_productStoreId", this.currentEComStore.productStoreId);
return this.store.dispatch("order/cancelItems", {
headers: {
'Content-Type': 'multipart/form-data;'
Expand Down
2 changes: 2 additions & 0 deletions src/views/promise-date-modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export default defineComponent({
...mapGetters({
jobTotal: 'job/getTotal',
getSelectedItemsToUpdatePromiseDate: 'order/getSelectedItemsToUpdatePromiseDate',
currentEComStore: 'user/getCurrentEComStore',
}),
disableUpdate(): boolean {
return this.promisedDatetime === '' || (this.item && this.item.promisedDatetime && DateTime.fromFormat(this.item.promisedDatetime, "yyyy-MM-dd hh:mm:ss.SSS").toFormat("yyyy-MM-dd") === this.promisedDatetime);
Expand Down Expand Up @@ -94,6 +95,7 @@ export default defineComponent({
const fileName = "UpdatePromiseDateItems_" + Date.now() +".json";
formData.append("uploadedFile", blob, fileName);
formData.append("configId", "MDM_UPD_ORD_ITM_JSON");
formData.append("param_productStoreId", this.currentEComStore.productStoreId);
return this.store.dispatch("order/updatePromiseDateItems", {
headers: {
'Content-Type': 'multipart/form-data;'
Expand Down
Loading

0 comments on commit 521620a

Please sign in to comment.