import { EntityState, createEntityAdapter } from '@ngrx/entity';
import { SearchProcess } from './defs';
import { SelectFilter } from 'apps/sales/src/app/modules/filter';
import { PrimaryFilterOption } from 'apps/sales/src/app/modules/shelf/defs';
import { SearchProcessState } from './defs';

export interface SearchState extends EntityState<SearchProcess> {}

export const searchStateAdapter = createEntityAdapter<SearchProcess>();

export const INITIAL_SEARCH_STATE: SearchState = {
  ...searchStateAdapter.getInitialState(),
};

export const INITIAL_FILTERS: {
  selectedFilters?: SelectFilter[];
  primaryFilters?: PrimaryFilterOption[];
} = {
  selectedFilters: [],
  primaryFilters: [],
};

export const INITIAL_SEARCH_PROCESS: SearchProcess = {
  id: undefined,
  result: [],
  input: '',
  state: SearchProcessState.INIT,
  filters: INITIAL_FILTERS,
  pendingInput: '',
};
