blob: 2fd0ac8f128deb59aa1b9d74fe757555b6f223d7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
import { IActionHandler } from '../../../../framework/src/flux/action';
import {
AllAvailableLtpsLoadedAction,
LoadAllAvailableLtpsAction,
} from '../actions/ltpAction';
import { Ltp } from '../models/availableLtps';
export interface IAvailableLtpsState {
distinctLtps: Ltp[];
busy: boolean;
}
const connectedNetworkElementsStateInit: IAvailableLtpsState = {
distinctLtps: [],
busy: false
};
export const availableLtpsActionHandler: IActionHandler<IAvailableLtpsState> = (state = connectedNetworkElementsStateInit, action) => {
if (action instanceof LoadAllAvailableLtpsAction) {
state = {
...state,
busy: true
};
} else if (action instanceof AllAvailableLtpsLoadedAction) {
if (!action.error && action.availableLtps) {
state = {
...state,
distinctLtps: action.availableLtps,
busy: false
};
} else {
state = {
...state,
busy: false
};
}
}
return state;
};
|