blob: 0a39a20a7e734c85be97130c6fe63487d4ff7793 [file] [log] [blame]
/********************************************************************************
* Copyright (c) 2020 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
********************************************************************************/
import {Action, createReducer, on} from "@ngrx/store";
import {addNewStatementAction, clearNewStatementFormAction, setNewStatementProgressAction} from "../actions";
import {INewStatementStoreState} from "../model";
export const newStatementReducer = createReducer<INewStatementStoreState, Action>(
{},
on(addNewStatementAction, (state, payload): INewStatementStoreState => {
return {
...state,
form: {...payload.form}
};
}),
on(clearNewStatementFormAction, (state): INewStatementStoreState => {
return {
...state,
form: undefined
};
}),
on(setNewStatementProgressAction, (state, payload): INewStatementStoreState => {
return {...state, isLoading: payload?.isLoading, error: payload?.error};
})
);