import { createAction, props } from '@ngrx/store';
import {
  OrderItemListItemDTO,
  StrictHttpResponse,
  ListResponseArgsOfOrderItemListItemDTO,
  ResponseArgsOfIEnumerableOfInputDTO,
} from '@swagger/oms';
import { SelectFilter } from 'apps/sales/src/app/modules/filter';
import { PrimaryFilterOption } from 'apps/sales/src/app/modules/shelf/defs';

const prefix = '[CUSTOMER] [SHELF] [SEARCH]';

export const addSearchProcess = createAction(`${prefix} Add Search Process`, props<{ id: number }>());

export const removeSearchProcess = createAction(`${prefix} Remove Search Process`, props<{ id: number }>());

export const fetchFilters = createAction(`${prefix} Fetch Filters`, props<{ id: number }>());

export const fetchFiltersDone = createAction(
  `${prefix} Fetch Filters Done`,
  props<{
    id: number;
    response: StrictHttpResponse<ResponseArgsOfIEnumerableOfInputDTO>;
  }>()
);

export const setSelectFilters = createAction(`${prefix} Set Selected Filters`, props<{ id: number; filters: SelectFilter[] }>());

export const resetSelectFilters = createAction(`${prefix} Reset Selected Filters`, props<{ id: number }>());

export const setPrimaryFilters = createAction(`${prefix} Set Primary Filters`, props<{ id: number; filters: PrimaryFilterOption[] }>());

export const resetPrimaryFilters = createAction(`${prefix} Reset Primary Filters`, props<{ id: number }>());

export const setInput = createAction(`${prefix} Search Input`, props<{ id: number; input: string }>());

export const clearError = createAction(`${prefix} Clear Error`, props<{ id: number }>());

export const clearResults = createAction(`${prefix} Clear Results`, props<{ id: number }>());

export const reloadResults = createAction(`${prefix} Reload Results`, props<{ id: number }>());

export const addResult = createAction(`${prefix} Add Result`, props<{ id: number; result: OrderItemListItemDTO[] }>());

export const clearHits = createAction(`${prefix} Clear Hits`, props<{ id: number }>());

export const setHits = createAction(`${prefix} Set Hits`, props<{ id: number; hits: number }>());

export const setTimestamp = createAction(`${prefix} Set Timestamp`, props<{ id: number }>());

export const fetchResult = createAction(`${prefix} Fetch Result`, props<{ id: number; skip?: number; take?: number }>());

export const cleanup = createAction(`${prefix} Cleanup`);

export const fetchResultDone = createAction(
  `${prefix} Fetch Result Done`,
  props<{
    id: number;
    response: StrictHttpResponse<ListResponseArgsOfOrderItemListItemDTO>;
  }>()
);

export const setPendingInput = createAction(
  `${prefix} Set Pending Input`,
  props<{
    id: number;
    input: string;
  }>()
);
