Passed
Push — task/job-get-classification ( edd1e4...41ede6 )
by
unknown
05:56 queued 11s
created

resources/assets/js/store/Classification/classificationSelector.ts   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 19
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 17
c 0
b 0
f 0
dl 0
loc 19
rs 10
mnd 1
bc 1
fnc 0
bpm 0
cpm 0
noi 0
1
import { createSelector } from "reselect";
2
import { RootState } from "../store";
3
import { Classification } from "../../models/types";
4
import { hasKey } from "../../helpers/queries";
5
6
export const getClassificationState = (state: RootState): { [key: string]: Classification } =>
7
 state.classification.byId;
8
9
export const getClassifications = createSelector(
10
  getClassificationState,
11
  (ClassificationState): Classification[] => Object.values(ClassificationState),
12
);
13
14
export const getClassificationById = (
15
  state: RootState,
16
  id: number,
17
): Classification | null =>
18
  hasKey(getClassificationState(state), id) ? getClassificationState(state)[id] : null;
19
20