// composer.ts // Copyright (C) 2020 Dwayne Harris // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License // along with this program. If not, see . import { Reducer } from 'redux' import { ComposerActions } from '../actions/composer' import { ComposerState } from '../types' const initialState: ComposerState = { installations: [], selected: undefined, error: undefined, height: 100, } const reducer: Reducer = (state = initialState, action) => { switch (action.type) { case 'COMPOSER_SET_INSTALLATIONS': return { ...state, installations: action.payload, } case 'COMPOSER_SET_SELECTED_INSTALLATION': return { ...state, selected: action.payload, } case 'COMPOSER_SET_HEIGHT': return { ...state, height: action.payload, } case 'COMPOSER_SET_ERROR': return { ...state, error: action.payload, } default: return state } } export default reducer