import {
  HIDE_FUNCTIONALITIES,
  RESET_FORM_DATA,
  UPDATE_FORM_DETAILS,
} from './signupActionType';

const initialState = {
  name: '',
  email: '',
  mobileNumber: '',
  mobilePrefix: '',
  password: '',
  confirmPassword: '',
  currentEmail: '',

  companyName: '',
  designation: '',
  businessPhonePrefix: "",
  businessPhone: "",
  emergencyBusinessPhone: "",
  emergencyBusinessPhonePrefix: "",
  businessFax: "",
  clinicLogo: '',
  practiceManagementSystem: '',
  practiceId: '',
  practiceName: '',
  pincode: '',
  state: '',
  locality: '',
  fullAddress: '',
  companyABNImageNumber: "",
  companyABNImage: "",
  termsAccepted: '',
  contract: '',
  businessEmail: '',
};
const updateFormDetails = (state, payload) => ({
  ...state,
  ...payload,
});
const resetFormData = (state) => ({
  ...initialState,
});

const hideAndShowFunctionality = (state, payload) => ({
  ...state,
  ...payload,
});

export default function (state = initialState, action) {
  switch (action.type) {
    case UPDATE_FORM_DETAILS:
      return updateFormDetails(state, action.payload);
    case RESET_FORM_DATA:
      return resetFormData(state);
    case HIDE_FUNCTIONALITIES:
      return hideAndShowFunctionality(state, action.payload);

    default:
      return state;
  }
}
