import { RPCClientError } from '@loafer/ng-rpc';

import { NoAuthProbe } from '@overflow/commons-typescript/model/noauth';
import { Selector, createSelector } from '@ngrx/store';
import { createEntityAdapter, EntityState } from '@loafer/ng-entity';

export const noAuthProbeListContainerAdapter = createEntityAdapter<NoAuthProbe, RPCClientError>();
export interface State extends EntityState<NoAuthProbe, RPCClientError> {
  pending: boolean;
}
export const initialState: State = noAuthProbeListContainerAdapter.getInitialState({
  pending: false,
});

export function getSelectors(selector: Selector<any, State>) {
  return {
    ...noAuthProbeListContainerAdapter.getSelectors(selector),
    selectPending: createSelector(selector, (state: State) => state.pending),
  };
}
