import { Breadcrumb } from '../../models/breadcrumb.model';
import { ProcessBreadcrumb } from '../../models/process-breadcrumb.model';
import { UPDATE_CURRENT_ROUTE_QUERY_PARAMS } from './process.actions';

export const ADD_BREADCRUMB = '[BREADCRUMB] Add breadcrumb';
export const ADD_BREADCRUMB_NO_DUB = '[BREADCRUMB] Add breadcrumb if dosnt exists';
export const UPDATE_CURRENT_BREADCRUMB_NAME = '[BREADCRUMB] Update breadcrumb name';
export const POP_BREADCRUMB = '[BREADCRUMB] Pop breadcrumb';
export const POP_LAST_BREADCRUMB = '[BREADCRUMB] Pop last breadcrumb';
export const RESET_BREADCRUMB = '[BREADCRUMB] Reset breadcumbs';
export const DELETE_BREADCRUMBS_FOR_PROCESS = '[BREADCRUMB] Delete breadcrumbs for process';
export const POP_BREADCRUMB_BEFORE = '[BREADCRUMB] Pop breadcrumb before current';
export const CLEAR_BREADCRUMBS = '[BREADCRUMB] Clear all breadcrumbs for process';
export const RELOAD_STATE = '[BREADCRUMB] Reload data from API';
export const RESET_BREADCRUMBS_AFTER_ORDER = '[BREADCRUMBS] Reset breadcrumbs state after order';
export const UPDATE_ACTIVE_CRUMB = '[BREADCRUMB] Update active crumb';
export const DELETE_LAST_PREVIOUS_PATH = '[BREADCRUMB] Delete last previous path';
export const UPDATE_BREADCRUMB_QUERY_PARAMS = '[BREADCRUMB] Update query params';

export class AddBreadcrumb {
  static readonly type = ADD_BREADCRUMB;

  constructor(public payload: Breadcrumb, public breadcrumbsId: string, public isMainBreadcrumb = false) {}
}

export class AddBreadcrumbNoDub {
  static readonly type = ADD_BREADCRUMB_NO_DUB;

  constructor(public payload: Breadcrumb, public breadcrumbsId: string) {}
}

export class UpdateCurrentBreadcrumbName {
  static readonly type = UPDATE_CURRENT_BREADCRUMB_NAME;

  constructor(public payload: string, public breadcrumbsId: string, public queryParams?: any) {}
}

export class PopBreadcrumbsAfterCurrent {
  static readonly type = POP_BREADCRUMB;

  constructor(public path: string) {}
}
export class PopBreadcrumbsBeforeCurrent {
  static readonly type = POP_BREADCRUMB_BEFORE;

  constructor(public breadcrumbsId: string) {}
}

export class PopLastBreadcrumbs {
  static readonly type = POP_LAST_BREADCRUMB;

  constructor(public path: string) {}
}

export class ResetBreadcrumbsTo {
  static readonly type = RESET_BREADCRUMB;

  constructor(public payload: Breadcrumb, public breadcrumbsId: string, public isMainBreadcrumb = false, public isBranchView = false) {}
}

export class DeleteBreadcrumbsForProcess {
  static readonly type = DELETE_BREADCRUMBS_FOR_PROCESS;

  constructor(public payload: number) {}
}

export class ClearBreadcrumbs {
  static readonly type = CLEAR_BREADCRUMBS;

  constructor(public breadcrumbsId: string) {}
}

export class ReloadBreadcrumbsData {
  static readonly type = RELOAD_STATE;

  constructor(
    public processesBreadcrumbs: ProcessBreadcrumb,
    public activeCrumbs: { [id: number]: string },
    public previusMenuPath: { [id: number]: { crumb: string; path: string }[] }
  ) {}
}

export class ResetBreadcrumbsAfterOrder {
  static readonly type = RESET_BREADCRUMBS_AFTER_ORDER;

  constructor() {}
}

export class UpdateActiveCrumb {
  static readonly type = UPDATE_ACTIVE_CRUMB;

  constructor(public crumb: string) {}
}

export class DeleteLastPreviousPath {
  static readonly type = DELETE_LAST_PREVIOUS_PATH;

  constructor() {}
}

export class UpdateBreadcrumbQueryParams {
  static readonly type = UPDATE_CURRENT_ROUTE_QUERY_PARAMS;

  constructor(public path: string, public breadcrumbId: string, public queryParams: any) {}
}
