import { formActionTypes } from '../action-types/form-action.types';

const initialState = {
  allForms: {},
  allFolders: {},
  formId: '',
  coverImage: '',
  savingForm: false,
  formPreview: {},
  dispatchName: '',
  formDueDate: '',
  validation: '',
  notification: '',
  totalExpectedResponses: '',
  responsePerAgent: '',
  formShareDetails: {},
  allowMultipleResponses: '',
  sharedFormData: {},
  sharedLinks: {},
  formUsers: {},
  templateCategories: {},
  resultSummary: {},
  responseList: {},
  entryDetails: {},
  entryMap: [],
  activeFolder: '',
};

export default (state = initialState, action) => {
  switch (action.type) {
    case formActionTypes.GET_ALL_FORMS:
      return { ...state, allForms: action.payload };
    case formActionTypes.SET_COVER_IMAGE:
      return { ...state, coverImage: action.payload };
    case formActionTypes.GET_ENTRY_DETAILS:
      return { ...state, entryDetails: action.payload };
    case formActionTypes.SET_ACTIVE_FOLDER:
      return { ...state, activeFolder: action.payload };
    case formActionTypes.GET_ENTRY_MAP:
      return { ...state, entryMap: action.payload };
    case formActionTypes.GET_RESULT_SUMMARY:
      return { ...state, resultSummary: action.payload };
    case formActionTypes.GET_RESPONSE_LIST:
      return { ...state, responseList: action.payload };
    case formActionTypes.GET_TEMPLATE_CATEGORIES:
      return { ...state, templateCategories: action.payload };
    case formActionTypes.GET_FORM_PREVIEW:
      return { ...state, formPreview: action.payload };
    case formActionTypes.SAVING_FORM:
      return { ...state, savingForm: action.payload };
    case formActionTypes.GET_ALL_FOLDERS:
      return { ...state, allFolders: action.payload };
    case formActionTypes.ADD_FORM_ID:
      return { ...state, formId: action.payload };
    case formActionTypes.ADD_FORM_DUE_DATE:
      return { ...state, formDueDate: action.payload };
    case formActionTypes.SET_VALIDATION:
      return { ...state, validation: action.payload };
    case formActionTypes.SET_NOTIFICATION:
      return { ...state, notification: action.payload };
    case formActionTypes.SET_DISPATCH_NAME:
      return { ...state, dispatchName: action.payload };
    case formActionTypes.TOTAL_RESPONSE:
      return { ...state, totalExpectedResponses: action.payload };
    case formActionTypes.TOTAL_AGENT_RESPONSE:
      return { ...state, responsePerAgent: action.payload };
    case formActionTypes.ALLOW_MULTIPLE_RESPONSE:
      return { ...state, allowMultipleResponses: action.payload };
    case formActionTypes.SHARED_FORM_DATA:
      return { ...state, sharedFormData: action.payload };
    case formActionTypes.GET_SHARED_LINKS:
      return { ...state, sharedLinks: action.payload };
    case formActionTypes.GET_FORM_USERS:
      return { ...state, formUsers: action.payload };
    default:
      return state;
  }
};
