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

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

const nameSpace = slice.name;
const formSelectors = createFormSelector(FORM_REDUX_FIELD_NAME, nameSpace);

export const nameSelector = (state) => state[nameSpace].name;
export const statusSelector = (state) => state[nameSpace].status;
export const urlSelector = (state) => state[nameSpace].url;
export const placementIdSelector = (state) => state[nameSpace].placementId;
export const isDefaultForPlayerTypeSelector = (state) => state[nameSpace].isDefaultForPlayerType;
export const playerTypesIdsSelector = (state) => state[nameSpace].playerTypesIds;
export const playerTypesOptionsSelector = (state) => state[nameSpace].playerTypesOptions;
export const playerTypesValueSelector = (state) => {
  const playerTypesIds = playerTypesIdsSelector(state);
  const playerTypesOptions = playerTypesOptionsSelector(state);
  return playerTypesIds.map((playerId) => playerTypesOptions.find(({ id }) => id === playerId));
};
export const macroSelector = (state) => state[nameSpace].macro;
export const commentsSelector = (state) => state[nameSpace].comments;
export const activeTabIdSelector = (state) => state[nameSpace].activeTabId;

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