import { createSelector } from 'reselect';
import { fromJS } from 'immutable';

/**
 * Direct selector to the create state domain
 */
const selectMobilePushEditDomain = () => (state) => state.get('mobileEdit') || fromJS({}); // reducer injected as mobileEdit in library mode.


/**
 * Other specific selectors
 */


/**
 * Default selector used by Create
 */

const makeSelectEdit = () => createSelector(
  selectMobilePushEditDomain(),
  (substate) => substate.toJS()
);
const makeSelectEditResponse = () => createSelector(
  selectMobilePushEditDomain(), (dimensionState) => dimensionState.get('editResponse')
);
const makeSelectTemplateDetailsResponse = () => createSelector(
  makeSelectEdit(), (dimensionState) => dimensionState.templateDetails
);
const makeSelectIosCta = () => createSelector(makeSelectEdit(), (create) => create.getIosCtasSucccess && create.iosCtasData );

export {
  makeSelectEdit, makeSelectEditResponse, makeSelectTemplateDetailsResponse, makeSelectIosCta,
};
