import { User } from '../../models/user.model';
import { NotificationChannels } from '../../models/notification-channels.enum';
import { EnvironmentChannel } from '@swagger/oms';

export const SET_CART = '[CART] Set cart entry to cart';
export const DELETE_PRODUCT_CART = '[CART] Delete product from cart';
export const DELETE_CART = '[CART] Delete cart from process';
export const SET_CART_TO_PROCESS = '[CART] Set cart to process';
export const CREATE_ORDER = '[CART] Create order';
export const GET_PAYMENT_TYPE = '[CART] Get payment to checkout';
export const SET_PAYMENT_TYPE = '[CART] Set payment to checkout';
export const SET_BUYER = '[CART] Set buyer to checkout';
export const SET_PAYER = '[CART] Set payer to checkout';
export const SET_DESTINATION = '[CART] Set shipping address to checkout';
export const RELOAD_STATE = '[CART] Reload data from API';
export const SET_NOTIFICATION_CHANNEL = '[CART] Set notification channel';

export class SetCartData {
  static readonly type = SET_CART;

  constructor(public cartEntryId: number) {}
}

export class SetCartToProcess {
  static readonly type = SET_CART_TO_PROCESS;

  constructor() {}
}

export class DeleteProductFromCart {
  static readonly type = DELETE_PRODUCT_CART;

  constructor(public cartId: number, public cartEntryId: number) {}
}

export class DeleteCart {
  static readonly type = DELETE_CART;

  constructor(public cartId: number) {}
}

export class CreateOrder {
  static readonly type = CREATE_ORDER;

  constructor(public checkoutId: number) {}
}

export class SetPaymentTypeToCheckout {
  static readonly type = GET_PAYMENT_TYPE;

  constructor(public checkoutId: number, public customer: User, public isDelivery: boolean) {}
}

export class SetPaymentToCheckout {
  static readonly type = SET_PAYMENT_TYPE;

  constructor(
    public checkoutId: number,
    public type: 0 | 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 | 256 | 512 | 1024 | 2048 | 4096 | 8192 | 16384,
    public customer: User,
    public isDelivery: boolean
  ) {}
}

export class SetBuyerToCheckout {
  static readonly type = SET_BUYER;

  constructor(public checkoutId: number, public customer: User, public isDelivery: boolean) {}
}

export class SetPayerToCheckout {
  static readonly type = SET_PAYER;

  constructor(public checkoutId: number, public customer: User) {}
}

export class SetDestinationToCheckout {
  static readonly type = SET_DESTINATION;

  constructor(public checkoutId: number, public destinationId: number, public customer: User, public target?: EnvironmentChannel) {}
}

export class ReloadCartData {
  static readonly type = RELOAD_STATE;

  constructor(public carts: { [key: number]: number[] }) {}
}

export class SetNotificationChannel {
  static readonly type = SET_NOTIFICATION_CHANNEL;

  constructor(public checkoutId: number, public notificationChannel: NotificationChannels) {}
}
