import { OrderHistory, OrderHistoryStatus } from '../defs';
import { props, createAction } from '@ngrx/store';
import { StrictHttpResponse, ResponseArgsOfHistoryDTO } from '@swagger/oms';
import { HistoryDTO } from '@cmf/trade-api';

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

export const initOrderHistory = createAction(`${prefix} Init Order History`, props<{ id: number }>());

export const addOrderHistory = createAction(`${prefix} Add Order History`, props<{ id: number; histories: HistoryDTO[] }>());

export const setStatus = createAction(`${prefix} Set Order Status`, props<{ id: number; status: OrderHistoryStatus }>());

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

export const fetchHistoryDone = createAction(
  `${prefix} Fetch Order History Done`,
  props<{
    id: number;
    response: StrictHttpResponse<ResponseArgsOfHistoryDTO>;
  }>()
);

export const updateOrderHistory = createAction(`${prefix} Update Order History`, props<{ id: number; history: Partial<OrderHistory> }>());
