import { createSelector } from "reselect";

const selectEmail = state => state.email;
const selectEmailConfigMessageOptions = state =>
  state.email.emailConfig.messageOptions;
const selectEmailConfigTemplate = state => state.email.emailConfig.template;
const selectEmailConfigQuery = state => state.email.emailConfig.queryConfig;

export const selectEmailVisible = createSelector(
  [selectEmail],
  email => email.visible
);

export const selectEmailConfig = createSelector(
  [
    selectEmailConfigMessageOptions,
    selectEmailConfigTemplate,
    selectEmailConfigQuery
  ],
  (messageOptions, template, queryConfig) => ({
    messageOptions,
    template,
    queryConfig
  })
);
