import { Remission } from '../../models/remission.model';
import { RemissionProcess, RemissionProduct, RemissionSupplier, ShippingDocument, RemissionFilter } from '@isa/remission';
import { RemissionResourceType } from '../../../modules/remission/models/remission-resource-type.model';
import { RemissionFinishingProcessStatus } from '../../../modules/remission/models/remission-finishing-process-status.enum';
import { RemissionActiveView } from '../../../modules/remission/models';

export const SET_REMISSION_CREATED = '[REMISSION] Set created';
export const SET_REMISSION_STARTED = '[REMISSION] Set started';
export const SET_REMISSION_COMPLETED = '[REMISSION] Set compleated';
export const SET_REMISSION_PROCESS = '[REMISSION] Set remission process';
export const RELOAD_REMISSION = '[REMISSION] Reload';
export const INIT_REMISSION_STATE = '[REMISSION] Init';
export const RESET_REMISSION_STATE = '[REMISSION] Reset';
export const COMPLEATE_REMISSION_STATE = '[REMISSION] Compleate remission';
export const SET_REMISSION_SOURCE = '[REMISSION] Set source';
export const SET_REMISSION_TARGET = '[REMISSION] Set target';
export const SET_REMISSION_PRODUCTS = '[REMISSION] Set products';
export const SET_SHIPPING_DOCUMENT = '[REMISSION] Set shipping document';
export const COMPLETE_SHIPPING_DOCUMENT = '[REMISSION] Complete shipping document';
export const RESET_SHIPPING_DOCUMENT = '[REMISSION] Reset shipping document';
export const SET_REMISSION_SEARCHED_PRODUCT = '[REMISSION] Set remission searched product';
export const ACTIVATE_REMISSION_REMINDER = '[REMISSION] Activate reminder';
export const SET_REMISSION_FINISHED_PROCESS_STATUS = '[REMISSION] Set remission finished process status';
export const SET_REMISSION_SCANNED_CONTAINER_ID = '[REMISSION] Set remission scanned container id';
export const DELETE_SHIPPING_DOCUMENT = '[REMISSION] Delete shipping document';
export const SET_ALL_OPEN_REMISSIONS = '[REMISSION] Set all open remissions';
export const SET_ALL_REMISSIONS = '[REMISSION] Set all remissions';
export const SET_REMISSION_FILTER = '[REMISSION] Set remission filter';
export const SET_REMISSION_ISLOADING = '[REMISSION] Set remission isLoading';
export const SET_REMISSION_ACTIVE_VIEW = '[REMISSION] Set remission active view';
export const REQUEST_UPDATE_SHIPPING_DOCUMENT = '[REMISSION] Update shipping document';

export const REQUEST_DELETE_SHIPPING_DOCUMENT = '[REMISSION] [API] Send delete shipping document request';
export const REQUEST_UPDATE_REMISSION_FILTER = '[REMISSION] [API] Send update remission filter request';

export class SetRemissionCreated {
  static readonly type = SET_REMISSION_CREATED;

  constructor(public status: boolean) {}
}

export class SetRemissionStarted {
  static readonly type = SET_REMISSION_STARTED;

  constructor(public status: boolean) {}
}

export class SetRemissionCompleted {
  static readonly type = SET_REMISSION_COMPLETED;

  constructor(public status: boolean) {}
}

export class SetRemissionProcess {
  static readonly type = SET_REMISSION_PROCESS;

  constructor(public remissionProcess: RemissionProcess, public initialValue: boolean = false) {}
}

export class ReloadRemission {
  static readonly type = RELOAD_REMISSION;

  constructor(public remission: Remission) {}
}

export class InitRemissionState {
  static readonly type = INIT_REMISSION_STATE;
}

export class ResetRemissionState {
  static readonly type = RESET_REMISSION_STATE;
}

export class CompleateRemissionState {
  static readonly type = COMPLEATE_REMISSION_STATE;
}

export class SetRemissionSource {
  static readonly type = SET_REMISSION_SOURCE;

  constructor(public source: RemissionResourceType) {}
}

export class SetRemissionTarget {
  static readonly type = SET_REMISSION_TARGET;

  constructor(public target: RemissionSupplier, public source: RemissionResourceType) {}
}

export class SetRemissionProducts {
  static readonly type = SET_REMISSION_PRODUCTS;

  constructor(public products: RemissionProduct[]) {}
}

export class SetRemissionShippingDocument {
  static readonly type = SET_SHIPPING_DOCUMENT;

  constructor(public shippingDocument: ShippingDocument) {}
}

export class CompleteRemissionShippingDocument {
  static readonly type = COMPLETE_SHIPPING_DOCUMENT;

  constructor(public shippingDocument: ShippingDocument) {}
}

export class ResetRemissionShippingDocument {
  static readonly type = RESET_SHIPPING_DOCUMENT;
}

export class SetRemissionSearchedProduct {
  static readonly type = SET_REMISSION_SEARCHED_PRODUCT;

  constructor(public product?: RemissionProduct) {}
}

export class ActivateRemissionReminder {
  static readonly type = ACTIVATE_REMISSION_REMINDER;
}

export class SetRemissionFinishedProcessStatus {
  static readonly type = SET_REMISSION_FINISHED_PROCESS_STATUS;

  constructor(public status: RemissionFinishingProcessStatus) {}
}

export class SetRemissionScannedContainerId {
  static readonly type = SET_REMISSION_SCANNED_CONTAINER_ID;

  constructor(public containerId: string) {}
}

export class DeleteRemissionShippingDocument {
  static readonly type = DELETE_SHIPPING_DOCUMENT;

  constructor(public remissionProcessId: number) {}
}

export class SetAllOpenExistingRemissions {
  static readonly type = SET_ALL_OPEN_REMISSIONS;

  constructor(public remissionProcesses: RemissionProcess[]) {}
}

export class SetAllExistingRemissions {
  static readonly type = SET_ALL_REMISSIONS;

  constructor(public remissionProcesses: RemissionProcess[]) {}
}

// Actions with effects
export class RequestDeleteShippingDocument {
  static readonly type = REQUEST_DELETE_SHIPPING_DOCUMENT;

  constructor(public remissionProcess: RemissionProcess) {}
}

export class RequestUpdateRemissionFilter {
  static readonly type = REQUEST_UPDATE_REMISSION_FILTER;

  constructor(public remissionProcessId: number, public filter: Partial<RemissionFilter>) {}
}

export class UpdateShippingDocuent {
  static readonly type = REQUEST_UPDATE_SHIPPING_DOCUMENT;

  constructor(public remissionProcessId: number) {}
}

// End Actions with effects

export class SetRemissionFilter {
  static readonly type = SET_REMISSION_FILTER;

  constructor(public remissionProcessId: number, public filter: RemissionFilter) {}
}

export class SetRemissionIsLoading {
  static readonly type = SET_REMISSION_ISLOADING;

  constructor(public isLoading: boolean) {}
}

export class SetRemissionActiveView {
  static readonly type = SET_REMISSION_ACTIVE_VIEW;

  constructor(public activeView: RemissionActiveView) {}
}
