Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/hotwax/receiving into recei…
Browse files Browse the repository at this point in the history
…ving/#138
  • Loading branch information
amansinghbais committed Oct 6, 2023
2 parents cceb79f + 72d1f6a commit e14fcf9
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 27 deletions.
31 changes: 19 additions & 12 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": "receiving",
"version": "2.17.0",
"version": "2.18.0",
"private": true,
"description": "HotWax Commerce Receiving App",
"scripts": {
Expand All @@ -18,7 +18,7 @@
"@hotwax/app-version-info": "^1.0.0",
"@hotwax/apps-theme": "^1.1.0",
"@hotwax/dxp-components": "file:../dxp-components",
"@hotwax/oms-api": "^1.6.0",
"@hotwax/oms-api": "^1.9.0",
"@ionic/core": "6.7.5",
"@ionic/vue": "6.7.5",
"@ionic/vue-router": "6.7.5",
Expand Down
3 changes: 2 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ export default defineComponent({
}
},
async unauthorized() {
this.store.dispatch("user/logout");
// Mark the user as unauthorised, this will help in not making the logout api call in actions
this.store.dispatch("user/logout", { isUserUnauthorised: true });
const redirectUrl = window.location.origin + '/login';
window.location.href = `${process.env.VUE_APP_LOGIN_URL}?redirectUrl=${redirectUrl}`;
}
Expand Down
4 changes: 3 additions & 1 deletion src/adapter/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { api, client, initialise, resetConfig, updateInstanceUrl, updateToken } from '@hotwax/oms-api'
import { api, client, getConfig, initialise, logout, resetConfig, updateInstanceUrl, updateToken } from '@hotwax/oms-api'

export {
api,
client,
getConfig,
initialise,
logout,
resetConfig,
updateInstanceUrl,
updateToken
Expand Down
5 changes: 4 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import permissionRules from '@/authorization/Rules';
import permissionActions from '@/authorization/Actions';
import { dxpComponents } from '@hotwax/dxp-components'
import { login, logout, loader } from './user-utils';
import { getConfig, initialise } from '@/adapter'

const app = createApp(App)
.use(IonicVue, {
Expand All @@ -51,7 +52,9 @@ const app = createApp(App)
login,
logout,
loader,
appLoginUrl: process.env.VUE_APP_LOGIN_URL as string
appLoginUrl: process.env.VUE_APP_LOGIN_URL as string,
getConfig: getConfig,
initialise: initialise
});

// Filters are removed in Vue 3 and global filter introduced https://v3.vuejs.org/guide/migration/filters.html#global-filters
Expand Down
10 changes: 8 additions & 2 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as types from './mutation-types'
import { hasError, showToast } from '@/utils'
import { translate } from '@/i18n'
import { Settings } from 'luxon';
import { updateInstanceUrl, updateToken, resetConfig } from '@/adapter'
import { logout, updateInstanceUrl, updateToken, resetConfig } from '@/adapter'
import {
getServerPermissionsFromRules,
prepareAppPermissions,
Expand Down Expand Up @@ -103,7 +103,13 @@ const actions: ActionTree<UserState, RootState> = {
/**
* Logout user
*/
async logout ({ commit }) {
async logout ({ commit }, payload) {
// Calling the logout api to flag the user as logged out, only when user is authorised
// if the user is already unauthorised then not calling the logout api as it returns 401 again that results in a loop, thus there is no need to call logout api if the user is unauthorised
if(!payload?.isUserUnauthorised) {
await logout();
}

const authStore = useAuthStore()

// TODO add any other tasks if need
Expand Down
2 changes: 1 addition & 1 deletion src/user-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { loadingController } from '@ionic/vue'

const login = async (payload: any) => store.dispatch('user/login', payload);

const logout = async () => store.dispatch('user/logout');
const logout = async (payload: any) => store.dispatch('user/logout', payload);

const loader = {
value: null as any,
Expand Down
17 changes: 10 additions & 7 deletions src/views/Shipments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,14 @@ export default defineComponent({
"inputFields": {
"destinationFacilityId": this.user.facilityId,
"statusId": "PURCH_SHIP_SHIPPED",
"shipmentTypeId_fld0_value": "INCOMING_SHIPMENT",
"shipmentTypeId_fld0_op": "equals",
"shipmentTypeId_fld0_grp": "1",
"parentTypeId_fld0_value": "INCOMING_SHIPMENT",
"parentTypeId_fld0_op": "equals",
"parentTypeId_fld0_grp": "2",
"grp_op": "AND",
"shipmentTypeId_value": "INCOMING_SHIPMENT",
"shipmentTypeId_op": "equals",
"shipmentTypeId_grp": "1",
"parentTypeId_value": "INCOMING_SHIPMENT",
"parentTypeId_op": "equals",
"parentTypeId_grp": "1",
"grp_op_1": "OR"
},
"entityName": "ShipmentAndTypeAndItemCount",
"fieldList" : [ "shipmentId","primaryShipGroupSeqId","partyIdFrom","partyIdTo","estimatedArrivalDate","destinationFacilityId","statusId", "shipmentItemCount", "externalId", "externalOrderId", "shipmentTypeId" ],
Expand All @@ -121,11 +123,12 @@ export default defineComponent({
payload.inputFields["shipmentId_value"] = this.queryString
payload.inputFields["shipmentId_op"] = 'contains'
payload.inputFields["shipmentId_ic"] = 'Y'
payload.inputFields["shipmentId_grp"] = '1'
payload.inputFields["shipmentId_grp"] = '2'
payload.inputFields["externalOrderId_value"] = this.queryString
payload.inputFields["externalOrderId_op"] = 'contains'
payload.inputFields["externalOrderId_ic"] = 'Y'
payload.inputFields["externalOrderId_grp"] = '2'
payload.inputFields["grp_op_2"] = 'OR'
}
await this.store.dispatch("shipment/findShipment", payload);
this.fetchingShipments = false;
Expand Down

0 comments on commit e14fcf9

Please sign in to comment.