From 1b280259e53384e0333d10a93fa29c48dec0e79d Mon Sep 17 00:00:00 2001 From: Elsio Sanchez <45974454+elsiosanchez@users.noreply.github.com> Date: Tue, 9 Mar 2021 21:13:03 -0400 Subject: [PATCH] fix 404 (#652) * fix 404 * delete console.log Co-authored-by: Elsio Sanchez --- src/store/modules/permission.js | 2 -- src/store/modules/user.js | 26 +++++++++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/store/modules/permission.js b/src/store/modules/permission.js index c388625d..3419a645 100644 --- a/src/store/modules/permission.js +++ b/src/store/modules/permission.js @@ -31,13 +31,11 @@ const actions = { if (!isEmptyValue(organization)) { organizationUuid = organization.uuid } - const role = rootGetters['user/getRole'] let roleUuid if (!isEmptyValue(role)) { roleUuid = role.uuid } - const sessionUuid = getToken() loadMainMenu({ diff --git a/src/store/modules/user.js b/src/store/modules/user.js index c4d2b3a0..141ac08a 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -46,7 +46,8 @@ const state = { warehouse: {}, isSession: false, sessionInfo: {}, - corporateBrandingImage: '' + corporateBrandingImage: '', + currentOrganization: 0 } const mutations = { @@ -71,6 +72,9 @@ const mutations = { SET_ORGANIZATIONS_LIST: (state, payload) => { state.organizationsList = payload }, + SET_CURRENT_ORGANIZATIONS: (state, payload) => { + state.currentOrganization = payload + }, SET_ORGANIZATION: (state, organization) => { state.organization = organization if (organization) { @@ -174,6 +178,12 @@ const actions = { const { role } = sessionInfo commit('SET_ROLE', role) setCurrentRole(role.uuid) + const currentOrganizationSession = sessionInfo.defaultContext.find(context => { + if (context.key === '#AD_Org_ID') { + return context + } + }) + commit('SET_CURRENT_ORGANIZATIONS', currentOrganizationSession.value) // wait to establish the client and organization to generate the menu await dispatch('getOrganizationsListFromServer', role.uuid) @@ -221,7 +231,6 @@ const actions = { message: 'Verification failed, please Login again.' }) } - // if (isEmptyValue(state.role)) { // const role = responseGetInfo.rolesList.find(itemRole => { // return itemRole.uuid === getCurrentRole() @@ -333,7 +342,7 @@ const actions = { }) }, - getOrganizationsListFromServer({ commit, dispatch }, roleUuid) { + getOrganizationsListFromServer({ commit, dispatch, getters }, roleUuid) { if (isEmptyValue(roleUuid)) { roleUuid = getCurrentRole() } @@ -354,6 +363,14 @@ const actions = { } else { setCurrentOrganization(organization.uuid) } + const currentOrganization = getters.getCurrentOrg + if (!isEmptyValue(currentOrganization)) { + organization = response.organizationsList.find(item => { + if (item.id === currentOrganization) { + return item + } + }) + } commit('SET_ORGANIZATION', organization) commit('setPreferenceContext', { columnName: '#AD_Org_ID', @@ -579,6 +596,9 @@ const getters = { }, getIsPersonalLock: (state) => { return state.role.isPersonalLock + }, + getCurrentOrg: (state) => { + return state.currentOrganization } }