Skip to content

Commit

Permalink
Improved: formatting, indentation and removed facility related state …
Browse files Browse the repository at this point in the history
…as unused(#10)
  • Loading branch information
ymaheshwari1 committed Jan 18, 2024
1 parent 2bf1f95 commit 9f5a17e
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ const checkPermission = async (payload: any): Promise <any> => {
}

export const UserService = {
login,
checkPermission,
getAvailableTimeZones,
getEComStores,
getUserProfile,
login,
setUserTimeZone,
checkPermission
}
1 change: 0 additions & 1 deletion src/store/modules/user/UserState.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export default interface UserState {
token: string;
current: object | null;
currentFacility: object;
instanceUrl: string;
currentEComStore: object | null,
}
31 changes: 12 additions & 19 deletions src/store/modules/user/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import logger from "@/logger"
const actions: ActionTree<UserState, RootState> = {

/**
* Login user and return token
*/
* Login user and return token
*/
async login({ commit }, { username, password }) {
try {
// TODO: implement support for permission check
Expand All @@ -34,24 +34,17 @@ const actions: ActionTree<UserState, RootState> = {
},

/**
* Logout user
*/
async logout ({ commit }) {
* Logout user
*/
async logout({ commit }) {
// TODO add any other tasks if need
commit(types.USER_END_SESSION)
},

/**
* update current facility information
*/
async setFacility ({ commit }, payload) {
commit(types.USER_CURRENT_FACILITY_UPDATED, payload.facility);
},

/**
* Update user timeZone
*/
async setUserTimeZone ( { state, commit }, payload) {
* Update user timeZone
*/
async setUserTimeZone({ state, commit }, payload) {
const resp = await UserService.setUserTimeZone(payload)
if (resp.status === 200 && !hasError(resp)) {
const current: any = state.current;
Expand All @@ -62,9 +55,9 @@ const actions: ActionTree<UserState, RootState> = {
},

/**
* Set User Instance Url
*/
setUserInstanceUrl ({ commit }, payload){
* Set User Instance Url
*/
setUserInstanceUrl({ commit }, payload) {
commit(types.USER_INSTANCE_URL_UPDATED, payload)
},

Expand All @@ -74,7 +67,7 @@ const actions: ActionTree<UserState, RootState> = {
productStore = (state.current as any).stores.find((store: any) => store.productStoreId === payload.productStoreId);
}
commit(types.USER_CURRENT_ECOM_STORE_UPDATED, productStore);
},
}
}

export default actions;
3 changes: 0 additions & 3 deletions src/store/modules/user/getters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ const getters: GetterTree <UserState, RootState> = {
getUserProfile(state) {
return state.current
},
getCurrentFacility(state){
return state.currentFacility;
},
getInstanceUrl(state) {
const baseUrl = process.env.VUE_APP_BASE_URL;
return baseUrl ? baseUrl : state.instanceUrl;
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const userModule: Module<UserState, RootState> = {
state: {
token: "",
current: null,
currentFacility: {},
instanceUrl: "",
currentEComStore: {}
},
Expand Down
1 change: 0 additions & 1 deletion src/store/modules/user/mutation-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@ export const SN_USER = "user"
export const USER_TOKEN_CHANGED = SN_USER + "/TOKEN_CHANGED"
export const USER_END_SESSION = SN_USER + "/END_SESSION"
export const USER_INFO_UPDATED = SN_USER + "/INFO_UPDATED"
export const USER_CURRENT_FACILITY_UPDATED = SN_USER + "/CURRENT_FACILITY_UPDATED"
export const USER_INSTANCE_URL_UPDATED = SN_USER + "/INSTANCE_URL_UPDATED"
export const USER_CURRENT_ECOM_STORE_UPDATED = SN_USER + '/CURRENT_ECOM_STORE_UPDATED'
5 changes: 1 addition & 4 deletions src/store/modules/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ const mutations: MutationTree <UserState> = {
[types.USER_END_SESSION] (state) {
state.token = ""
state.current = null
state.currentFacility = {}
state.currentEComStore = {}
},
[types.USER_INFO_UPDATED] (state, payload) {
state.current = payload
},
[types.USER_CURRENT_FACILITY_UPDATED] (state, payload) {
state.currentFacility = payload;
},
[types.USER_INSTANCE_URL_UPDATED] (state, payload) {
state.instanceUrl = payload;
},
Expand Down

0 comments on commit 9f5a17e

Please sign in to comment.