import {
  SUBMIT_CHECKOUT,
  BILLING_ERROR
} from 'actions/billing';
import Immutable from 'immutable';

const Billing = new Immutable.Record({
  error: null,
  isLoading: false
});

export default function billingReducer(state = new Billing(), action) {
  switch (action.type) {
  case SUBMIT_CHECKOUT:
    return new Billing({
      isLoading: true
    });
  case BILLING_ERROR:
    return new Billing({
      error: action.error
    });
  default:
    return state;
  }
}
