import { FORM_REDUX_FIELD_NAME, VALUE_FORM_REDUX_FIELD_NAME } from '../../constants';

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

const nameSpace = slice.name;

export const searchSelector = (state$) => state$[nameSpace].search;
export const statusSelector = (state$) => state$[nameSpace].status;
export const totalCountSelector = (state$) => state$[nameSpace].totalCount;
export const pageSelector = (state$) => state$[nameSpace].page;
export const rowsPerPageSelector = (state$) => state$[nameSpace].rowsPerPage;
export const sortBySelector = (state$) => state$[nameSpace].sortBy;
export const sortOrderSelector = (state$) => state$[nameSpace].sortOrder;
export const keyListsSelector = (state$) => state$[nameSpace].keyLists;
export const tabSelector = (state$) => state$[nameSpace].tab;
export const userHubsSelector = (state$) => state$[nameSpace].userHubs;
export const userDemandAccountsSelector = (state$) => state$[nameSpace].userDemandAccounts;
export const nameSelector = (state$) => state$[nameSpace].name;
export const demandAccountSelector = (state$) => state$[nameSpace].demandAccount;
export const demandAccountOptionsSelector = (state$) => state$[nameSpace].demandAccountOptions;
export const keyNameSelector = (state$) => state$[nameSpace].keyName;
export const keyValueSelector = (state$) => state$[nameSpace].keyValue;
export const searchKeysSelector = (state$) => state$[nameSpace].searchKeys;
export const keysSelector = (state$) => state$[nameSpace].keys;
export const keysPageSelector = (state$) => state$[nameSpace].keysPage;
export const keysRowsPerPageSelector = (state$) => state$[nameSpace].keysRowsPerPage;
export const bulkKeysSelector = (state$) => state$[nameSpace].bulkKeys;

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

const formValueSelectors = createFormSelector(VALUE_FORM_REDUX_FIELD_NAME, nameSpace);
export const scrollFieldValueFormSelector = (state) => formValueSelectors.getScrollField(state);
export const schemeValueFormSelector = (state) => formValueSelectors.schemeSelector(state);
