import { createAction } from "@reduxjs/toolkit";
import { get } from "lodash";
const getApiActionCreator = (api) => (operation) => ({
  [operation]: createAction(`${api}/${operation}`),
  [`${operation}Success`]: createAction(`${api}/${operation}Success`),
  [`${operation}Error`]: createAction(`${api}/${operation}Error`)
});
const getSelectField = (stateName) => (fieldName = "", defaultValue) => (state = {}, stateValue = get(state, stateName)) => Array.isArray(fieldName) ? fieldName.map(
  (field, i) => get(
    stateValue,
    field,
    Array.isArray(defaultValue) ? defaultValue[i] : defaultValue
  )
) : get(stateValue, fieldName, defaultValue);
export {
  getApiActionCreator,
  getSelectField
};
