import { Process } from '../../models/process.model';
import { Search } from '../../models/search.model';
import { CustomerSearch } from '../../models/customer-search.model';
import { DisplayOrderDTO } from '@swagger/oms';
import { RecentArticleSearch } from '../../models/recent-article-search.model';
import { ProductSerachFilters } from '../../models/product-search-filters.model';
import { ShelfSearch } from '../../models/shelf-search.modal';
import { ItemDTO } from '@swagger/cat';

export const ADD_PROCESS = '[PROCESS] Add';
export const DELETE_PROCESS = '[PROCESS] Delete';
export const SELECT_PROCESS = '[PROCESS] Select';
export const CHANGE_CURRENT_ROUTE = '[PROCESS] Change current route';
export const ADD_SEARCH = '[PROCESS] Add search';
export const PREVENT_PRODUCT_LOAD = '[POCESS] Prevent product load';
export const ALLOW_PRODUCT_LOAD = '[POCESS] Allow product load';
export const UPDATE_NAME = '[PROCESS] Update name';
export const REMOVE_PROCESS_NEW_STATE = '[PROCESS] Remove process new state';
export const ADD_CUSTOMER_ID = '[PROCESS] Add customer id';
export const ADD_CUSTOMER_IDS = '[PROCESS] Add customer ids';
export const REMOVE_CUSTOMER_ID = '[PROCESS] Remove customer id';
export const SET_ACTIVE_CUSTOMER = '[PROCESS] Set active customer';
export const SET_DETAILS_CUSTOMER = '[PROCESS] Set details customer';
export const ADD_CART = '[PROCESS] Add cart to process';
export const UPDATE_CUSTOMER_FORM_STATE = '[PROCESS] Update customer form state';
export const RESET_PROCESS = '[PROCESS] Reset process';
export const ADD_CUSTOMER_SEARCH = '[PROCESS] Add customer search';
export const SET_CHECKOUT_ID = '[PROCESS] Set checkout id';
export const SET_FINISHED_ORDER = '[PROCESS] Set finished order';
export const RELOAD_STATE = '[PROCESS] Reload data from API';
export const ORDERS_PAGE_OPENED = '[PROCESS] Orders page visited for customer';
export const EMPTY_FINISHED_ORDERS = '[PROCESS] Empty finished orders';
export const SET_ARTICLE_SEARCH_ERROR_STATUS = '[PROCESS] Set article search error status';
export const SET_PROCESS_NEW_STATUS_TO_FALSE = '[PROCESS] Set process new status to false';
export const SET_PROCESS_PRODUCT_FILTERS = '[PROCESS] Set process filters for products';
export const RESET_PROCESS_PRODUCT_FILTERS = '[PROCESS] Reset process filters for products';
export const SET_PREVIUS_PATH = '[PROCESS] Set previus path for process';
export const SET_SHELF_SEARCH = '[PROCESS] Set shelf search';
export const SET_SELECTED_ITEM_IF_MISSING_OF_CHANGED = '[PROCESS] Set selected item in process if it is missing or changed';
export const REMOVE_SELECTED_ITEM = '[PROCESS] Remove selected item from process';
export const UPDATE_CURRENT_ROUTE_QUERY_PARAMS = '[PROCESS] Update current route query params for process';
export const SET_ONLINE_CUSTOMER_CREATION_STATUS = '[PROCESS] Set last online customer creation status';
export const CLEAR_PART_CUSTOMER_CREATION_STATUS = '[PROCESS] Clear part of customer creation status';
export const SET_USER_DATA = '[PROCESS] Set user form data';
export const SET_CUSTOMER_NOTIFICATION_FLAG = '[PROCESS] Set customer notification flag';

export class AddProcess {
  static readonly type = ADD_PROCESS;

  constructor(public payload: Process) {}
}

export class DeleteProcess {
  static readonly type = DELETE_PROCESS;

  constructor(public payload: Process) {}
}

export class ChangeCurrentRoute {
  static readonly type = CHANGE_CURRENT_ROUTE;

  constructor(public payload: string, public removeLastBreadcrumb: boolean = false, public queryParams?: any) {}
}

export class AddSearch {
  static readonly type = ADD_SEARCH;

  constructor(public payload: Search) {}
}

export class PreventProductLoad {
  static readonly type = PREVENT_PRODUCT_LOAD;
}

export class AllowProductLoad {
  static readonly type = ALLOW_PRODUCT_LOAD;
}

export class UpdateProcessName {
  static readonly type = UPDATE_NAME;

  constructor(public payload: string) {}
}

export class UpdateCustomerFormState {
  static readonly type = UPDATE_CUSTOMER_FORM_STATE;

  constructor(public payload: string) {}
}

export class RemoveProcessNewState {
  static readonly type = REMOVE_PROCESS_NEW_STATE;
}

export class AddCustomerId {
  static readonly type = ADD_CUSTOMER_ID;

  constructor(public payload: number) {}
}

export class AddCustomerIds {
  static readonly type = ADD_CUSTOMER_IDS;

  constructor(public payload: number[]) {}
}

export class RemoveCustomerId {
  static readonly type = REMOVE_CUSTOMER_ID;

  constructor(public payload: number) {}
}

export class SetActiveCustomer {
  static readonly type = SET_ACTIVE_CUSTOMER;

  constructor(public payload: number) {}
}

export class SetDetailsCustomer {
  static readonly type = SET_DETAILS_CUSTOMER;

  constructor(public payload: number) {}
}

export class AddCartToProcess {
  static readonly type = ADD_CART;

  constructor(public cartId: number) {}
}

export class ResetProcess {
  static readonly type = RESET_PROCESS;

  constructor() {}
}

export class AddCustomerSearch {
  static readonly type = ADD_CUSTOMER_SEARCH;

  constructor(public payload: CustomerSearch) {}
}

export class SetFinishedOrderData {
  static readonly type = SET_CHECKOUT_ID;

  constructor(public order: { failedItemIds: { id: number; type: number }[]; displayOrder: DisplayOrderDTO[] }) {}
}

export class ReloadProcessData {
  static readonly type = RELOAD_STATE;

  constructor(public processes: { [id: number]: Process }, public recentArticles: RecentArticleSearch[]) {}
}

export class CustomerOrdersVisited {
  static readonly type = ORDERS_PAGE_OPENED;

  constructor(public visited: boolean) {}
}

export class EmptyFinishedOrders {
  static readonly type = EMPTY_FINISHED_ORDERS;

  constructor() {}
}

export class SetArticleSearchErrorStatus {
  static readonly type = SET_ARTICLE_SEARCH_ERROR_STATUS;

  constructor(public status: boolean) {}
}

export class SetProcessNewStatusToFalse {
  static readonly type = SET_PROCESS_NEW_STATUS_TO_FALSE;

  constructor() {}
}

export class SetProcessProductFilters {
  static readonly type = SET_PROCESS_PRODUCT_FILTERS;

  constructor(public filters: ProductSerachFilters) {}
}

export class ResetProcessProductFilters {
  static readonly type = RESET_PROCESS_PRODUCT_FILTERS;
}

export class SetPreviusPath {
  static readonly type = SET_PREVIUS_PATH;

  constructor(public path: string) {}
}

export class SetShelfSearch {
  static readonly type = SET_SHELF_SEARCH;

  constructor(public shelfSearch: ShelfSearch) {}
}

export class SetSelectedItemIfMissingOrChanged {
  static readonly type = SET_SELECTED_ITEM_IF_MISSING_OF_CHANGED;

  constructor(public item: ItemDTO) {}
}

export class UpdateCurrentRouteQueryParams {
  static readonly type = UPDATE_CURRENT_ROUTE_QUERY_PARAMS;

  constructor(public queryParams: any) {}
}

export class SetOnlineCustomerCreationStatus {
  static readonly type = SET_ONLINE_CUSTOMER_CREATION_STATUS;

  constructor(public error: { error: boolean; invalidProperties: any }) {}
}

export class ClearPartOfCustomerCreationStatus {
  static readonly type = CLEAR_PART_CUSTOMER_CREATION_STATUS;

  constructor(public field: string) {}
}

export class RemoveSelectedItem {
  static readonly type = REMOVE_SELECTED_ITEM;

  constructor() {}
}

export class SetCustomerNotificationFlag {
  static readonly type = SET_CUSTOMER_NOTIFICATION_FLAG;

  constructor(public flag: boolean) {}
}
