From 37854d43fcf2a8b583b12af07ce10b3afd6ffdd4 Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Mon, 31 Jan 2022 21:38:23 +0100 Subject: [PATCH] Fix build --- .../src/fm/reducers/app-common.reducer.ts | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/projects/common/src/fm/reducers/app-common.reducer.ts b/projects/common/src/fm/reducers/app-common.reducer.ts index ea881c3..33f8dde 100644 --- a/projects/common/src/fm/reducers/app-common.reducer.ts +++ b/projects/common/src/fm/reducers/app-common.reducer.ts @@ -8,7 +8,7 @@ import { createSelector, createFeatureSelector, ActionReducerMap } from '@ngrx/s import { MODULE_NAME } from '../module-name'; import { IItem } from '../models/item'; -import { userInfo } from 'os'; +import {getValidPackages, isValidPackage} from '../services/package.service'; export interface State { openedModalName: string, @@ -58,16 +58,16 @@ export function reducer(state = initialState, action: appCommonActions.Actions ) case appCommonActions.INITUSERSUCCESS: { let a = action as appCommonActions.InitUserSuccess; let claims = {} - Object.getOwnPropertyNames(a.userinfo.info).forEach((k) => { + Object.getOwnPropertyNames(a.userinfo).forEach((k) => { claims[k] = a.userinfo[k]; }); var user:IUser = { code:a.user.code, - email:a.user?.name?a.user.name : claims["email"], - name:a.user?.email?a.user.email : claims["name"], + email:a.userinfo["email"], + name:a.userinfo["name"], claims:claims, searchable: false - }; + }; return tassign(state, { user: user }); } case appCommonActions.INITROOTSUCCESS: { @@ -76,10 +76,10 @@ export function reducer(state = initialState, action: appCommonActions.Actions ) } case appCommonActions.OPENMODAL: { return tassign(state, { openedModalName: action.modalName }); - } + } case appCommonActions.CLOSEMODAL: { return tassign(state, { openedModalName: null }); - } + } case appCommonActions.LOADITEMTYPESSUCCESS: { let a = action as appCommonActions.LoadItemTypesSuccess; return tassign(state, { itemTypes: a.itemTypes }); @@ -132,7 +132,10 @@ export function reducer(state = initialState, action: appCommonActions.Actions ) a.items.forEach((item) => { item.data.dataDate = item.dataDate; item.data.dataEndDate = item.dataEndDate; - packages[item.data.id]=item.data; + if (!packages[item.data.id]) { + packages[item.data.id] = []; + } + packages[item.data.id].push(item.data); }); return tassign(state,{userPackages:packages}); @@ -204,6 +207,9 @@ export const selectGetRouteLoading = createSelector(selectAppCommonState, getRou export const SelectGetMenuVisible = createSelector(selectAppCommonState,getMenuVisible); export const SelectGetUser = createSelector(selectAppCommonState,getUser); export const SelectGetUserPackages = createSelector(selectAppCommonState,getUserPackages); +export const SelectGetValidUserPackages = createSelector(SelectGetUserPackages, (packageMap) => { + return getValidPackages(packageMap); +}); export const SelectGetUserSettingsRoot = createSelector(selectAppCommonState,getUserSettingsRoot); export const SelectGetAccountMenuVisible = createSelector(selectAppCommonState,getAccountMenuVisible); export const SelectGetAppMenuVisible = createSelector(selectAppCommonState,getAppMenuVisible); @@ -214,3 +220,4 @@ export const SelectgetUnreadNotifications = createSelector(selectAppCommonState, export const SelectGetIsOnline = createSelector(selectAppCommonState,getIsOnline); export const SelectGetIsPageMode = createSelector(selectAppCommonState,getIsPageMode); +