You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { createReducer, on } from '@ngrx/store';
|
|
import { initRootState } from './rtl.state';
|
|
|
|
import { resetRootStore, setNodeData, setApplicationSettings, setSelectedNode, updateRootAPICallStatus } from './rtl.actions';
|
|
import { ServicesEnum } from '../shared/services/consts-enums-functions';
|
|
import { ConfigSettingsNode } from '../shared/models/RTLconfig';
|
|
|
|
export const RootReducer = createReducer(initRootState,
|
|
on(updateRootAPICallStatus, (state, { payload }) => {
|
|
const updatedApisCallStatus = JSON.parse(JSON.stringify(state.apisCallStatus));
|
|
if (payload.action) {
|
|
updatedApisCallStatus[payload.action] = {
|
|
status: payload.status,
|
|
statusCode: payload.statusCode,
|
|
message: payload.message,
|
|
URL: payload.URL,
|
|
filePath: payload.filePath
|
|
};
|
|
}
|
|
return {
|
|
...state,
|
|
apisCallStatus: updatedApisCallStatus
|
|
};
|
|
}),
|
|
on(resetRootStore, (state, { payload }) => ({
|
|
...initRootState,
|
|
apisCallStatus: state.apisCallStatus,
|
|
appConfig: state.appConfig,
|
|
selNode: payload
|
|
})),
|
|
on(setSelectedNode, (state, { payload }) => ({
|
|
...state,
|
|
selNode: payload.currentLnNode
|
|
})),
|
|
on(setNodeData, (state, { payload }) => ({
|
|
...state,
|
|
nodeData: payload
|
|
})),
|
|
on(setApplicationSettings, (state, { payload }) => ({
|
|
...state,
|
|
appConfig: payload
|
|
}))
|
|
);
|