import { REDUX_FIELD_NAME, TABLE_REDUX_FIELD_NAME } from '../../constants';

import { slice } from '../slices';
import createFormSelector from '@/modules/@common/Form/redux/selectors';
import createTableSelector from '@/modules/@common/Table/redux/selectors';

const nameSpace = slice.name;

// Account Details
export const salesforceInstanceUrlSelector = (state) => state[nameSpace].salesforceInstanceUrl;
export const salesforceIdSelector = (state) => state[nameSpace].salesforceId;
export const nameSelector = (state) => state[nameSpace].name;
export const salesManagerSelector = (state) => state[nameSpace].salesManager;
export const accountManagerSelector = (state) => state[nameSpace].accountManager;
export const accountManagerEmailSelector = (state) => state[nameSpace].accountManagerEmail;
export const typeSelector = (state) => state[nameSpace].type;
export const avatarUrlSelector = (state) => state[nameSpace].avatarUrl;
export const avatarSelector = (state) => state[nameSpace].avatar;
export const customLogoUrlSelector = (state) => state[nameSpace].customLogoUrl;
export const customLoadingMessageSelector = (state) => state[nameSpace].customLoadingMessage;
export const customLoginPageUrlSelector = (state) => state[nameSpace].customLoginPageUrl;
export const subdomainSelector = (state) => state[nameSpace].subdomain;
export const publisherRevShareSelector = (state) => state[nameSpace].publisherRevShare;
export const expensesSelector = (state) => state[nameSpace].expenses;
export const usersLimitSelector = (state) => state[nameSpace].usersLimit;
export const publisherDemandSelector = (state) => state[nameSpace].publisherDemand;
export const adServingFeeBusinessModelSelector = (state) => state[nameSpace].adServingFeeBusinessModel;
export const adServingFeeDisplaySelector = (state) => state[nameSpace].adServingFeeDisplay;
export const adServingFeeVideoSelector = (state) => state[nameSpace].adServingFeeVideo;
export const videoDuplicatesBy = (state) => state[nameSpace].videoDuplicatesBy;

// Features
export const featuresUiSelector = (state) => state[nameSpace].featuresUi;
export const featuresDataSelector = (state) => state[nameSpace].featuresData;
export const featuresDependsFieldDataSelector = (state) => state[nameSpace].featuresDependsFieldData;

// Dashboards
export const dashboardsGeneralSelector = (state) => state[nameSpace].dashboardsGeneral;
export const dashboardsCustomSelector = (state) => state[nameSpace].dashboardsCustom;

export const activeTabIdSelector = (state) => state[nameSpace].activeTabId;
export const isSalesforceDataLoadingSelector = (state) => state[nameSpace].isSalesforceDataLoading;

const formSelectors = createFormSelector(REDUX_FIELD_NAME, nameSpace);

export const scrollFieldSelector = (state) => formSelectors.getScrollField(state);
export const schemeSelector = (state) => formSelectors.schemeSelector(state);
export const fullAccessToStoreFieldsForValidation = (state) => state[nameSpace];

// table
export const {
  dataSelector,
  pageSelector,
  pageSizeSelector,
  totalCountSelector,
  isLoadingSelector,
  sortBySelector,
  sortOrderSelector,
} = createTableSelector(TABLE_REDUX_FIELD_NAME, nameSpace);
