import {createReducer} from 'redux-starter-kit';
import {
  setInstallActive,
  setInstallComplete,
  setMissingDependencies
} from '../actions/install_actions';

export const installReducer = createReducer({
  InstallActive: false,
  InstallResult: null,
  InstallType: null,
  MissingDependencies: [],
}, {
  [setInstallActive]: (state, action) => {
    return {
      ...state,
      InstallActive: true,
      InstallResult: null,
      InstallType: action.payload,
    };
  },
  [setInstallComplete]: (state, action) => {
    return {
      ...state,
      InstallActive: false,
      InstallResult: action.payload,
      InstallType: null,
    }
  },
  [setMissingDependencies]: (state, action) => {
    return {
      ...state,
      MissingDependencies: action.payload,
    }
  }
});