import { createSelector } from 'reselect';

/**
 * Direct selector to the email state domain
 */
const selectEmailDomain = () => (state) => state.get('email');

/**
 * Other specific selectors
 */


/**
 * Default selector used by Email
 */

const makeSelectEmail = () => createSelector(
  selectEmailDomain(),
  (substate) => substate.toJS()
);

const makeSelectCreateResponse = () => createSelector(
  selectEmailDomain(), (dimensionState) => dimensionState.get('createResponse')
);
const selectLoadingStatus = () => createSelector(
  selectEmailDomain(), (email) => email.createTemplateInProgress || (email.assetUploading !== undefined && email.assetUploading)
);

const makeSelectFetchingCmsData = () => createSelector(
  selectEmailDomain(), (state) => state.get('fetchingCmsData')
);

export default makeSelectEmail;
export {
  makeSelectEmail,
  makeSelectCreateResponse,
  selectLoadingStatus,
  makeSelectFetchingCmsData,
};
