import Actions from '@/types/Store/Actions';
import { ControllerResponse } from '@/api/shower';

export type ShowerState = {
  controllerConfigs: ControllerResponse;
};
const INITIAL_STATE = {
  controllerConfigs: {
    appointmentThresholdPrompt: '',
    balances: [],
    beanAmount: 0,
    defaultType: 0,
    money: 0,
    thresholdPrompt: '',
    thresholdValue: 0,
    useType: 0,
  },
};
export const updateShowerControlConfig = (
  entity: ControllerResponse,
): Actions => ({
  type: 'UPDATE_SHOWER_CONFIG',
  payload: entity,
});

export default function shower(
  state: ShowerState = INITIAL_STATE,
  actions: Actions,
): ShowerState {
  switch (actions.type) {
    case 'UPDATE_SHOWER_CONFIG':
      return {
        ...state,
        controllerConfigs: actions.payload,
      };
    default:
      return state;
  }
}
