/**
 * Customer Search Section Selectors
 */

import { createSelector } from 'reselect';

const selectPreviewAndTestDomain = (state) => state.get('previewAndTest');

const makeSelectPreviewAndTest = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate
);

const makeSelectCustomers = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('customers'),
);

const makeSelectExtractedTags = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('extractedTags')
);

const makeSelectIsSearchingCustomer = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('isSearchingCustomer')
);

const makeSelectIsExtractingTags = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('isExtractingTags')
);

const makeSelectSearchError = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('searchError')
);

const makeSelectHasSearched = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('hasSearched')
);

const makeSelectApiWarnings = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('apiWarnings')
);

const makeSelectApiErrors = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('apiErrors')
);

const makeSelectPreviewData = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('previewData')
);

const makeSelectIsUpdatingPreview = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('isUpdatingPreview')
);

const makeSelectIsSendingTestEmail = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('isSendingTestEmail')
);

const makeSelectTags = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('tags'),
);

const makeSelectTestCustomers = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('testCustomers'),
);

const makeSelectIsFetchingTestCustomers = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('isFetchingTestCustomers'),
);

const makeSelectTestGroups = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('testGroups'),
);

const makeSelectIsFetchingTestGroups = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('isFetchingTestGroups'),
);

const makeSelectMessageMetaConfigId = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('messageMetaConfigId'),
);

const makeSelectIsCreatingMessageMeta = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('isCreatingMessageMeta'),
);

const makeSelectPrefilledValues = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('prefilledValues')?.toJS(),
);

const makeSelectTestMessageResponse = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('testMessageResponse'),
);

const makeSelectIsSendingTestMessage = () => createSelector(
  selectPreviewAndTestDomain,
  (substate) => substate.get('isSendingTestMessage'),
);

export {
  makeSelectPreviewAndTest,
  makeSelectCustomers,
  makeSelectExtractedTags,
  makeSelectIsSearchingCustomer,
  makeSelectIsExtractingTags,
  makeSelectSearchError,
  makeSelectHasSearched,
  makeSelectApiWarnings,
  makeSelectApiErrors,
  makeSelectPreviewData,
  makeSelectIsUpdatingPreview,
  makeSelectIsSendingTestEmail,
  makeSelectTags,
  makeSelectTestCustomers,
  makeSelectIsFetchingTestCustomers,
  makeSelectTestGroups,
  makeSelectIsFetchingTestGroups,
  makeSelectMessageMetaConfigId,
  makeSelectIsCreatingMessageMeta,
  makeSelectPrefilledValues,
  makeSelectTestMessageResponse,
  makeSelectIsSendingTestMessage,
};
