Skip to content

Commit

Permalink
Fixed broken skill overview
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas345 committed Jan 25, 2024
1 parent 5baf17e commit 578b64c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class UsedSkillOverviewModule extends React.Component<UsedSkillOverviewProps

static mapStateToProps(state: ApplicationState, localProps: UsedSkillOverviewLocalProps): UsedSkillOverviewProps {
return {
usedSkillNames: [],
usedSkillNames: state.suggestionStore.allSkills,
skillUsageInfo: state.statisticsReducer.skillUsageInfo(),
skillHierarchies: state.skillReducer.categorieHierarchiesBySkillName()
};
Expand Down
3 changes: 2 additions & 1 deletion src/reducers/suggestions/SuggestionReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {ActionType} from '../ActionType';
import {SuggestionUpdateAction} from './actions/SuggestionUpdateAction';
import {SkillSuggestionUpdateAction} from './actions/SkillSuggestionUpdateAction';
import {AbstractAction} from '../BaseActions';
import {onlyUnique} from "../../utils/ObjectUtil";

export function reduceSuggestion(store: SuggestionStore = emptyStore, action: AbstractAction): SuggestionStore {
switch (action.type) {
Expand All @@ -22,5 +23,5 @@ function handleUpdateField(action: SuggestionUpdateAction, store: SuggestionStor
}

function handleUpdateSkills(action: SkillSuggestionUpdateAction, store: SuggestionStore): SuggestionStore {
return {...store, allSkills: action.payload};
return {...store, allSkills: action.payload.filter(onlyUnique)};
}
4 changes: 4 additions & 0 deletions src/utils/ObjectUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,7 @@ export function omitKeys(object: Object, ...keys: string[]): Object {
keys.forEach(key => delete copy[key]);
return copy;
}

export function onlyUnique<T>(value: T, index: number, self: T[]): boolean {
return self.indexOf(value) === index;
}

0 comments on commit 578b64c

Please sign in to comment.