import 'dart:typed_data';

import 'package:hl_lieferservice/model/car.dart';
import 'package:hl_lieferservice/model/tour.dart';

import '../../../../model/delivery.dart';

abstract class TourEvent {}

class LoadTour extends TourEvent {
  String teamId;

  LoadTour({required this.teamId});
}

class RequestDeliveryDistanceEvent extends TourEvent {
  Tour tour;
  List<Payment> payments;

  RequestDeliveryDistanceEvent({required this.tour, required this.payments});
}

class RequestSortingInformationEvent extends TourEvent {
  Tour tour;
  List<Payment> payments;
  Map<String, double>? distances;

  RequestSortingInformationEvent({
    required this.tour,
    required this.payments,
    this.distances,
  });
}

class ReorderDeliveryEvent extends TourEvent {
  int newPosition;
  int oldPosition;

  ReorderDeliveryEvent({required this.newPosition, required this.oldPosition});
}

class TourUpdated extends TourEvent {
  Tour tour;
  List<Payment> payments;

  TourUpdated({required this.tour, required this.payments});
}

class PaymentOptionsUpdated extends TourEvent {
  List<Payment> options;

  PaymentOptionsUpdated({required this.options});
}

class UpdateTour extends TourEvent {
  Tour tour;

  UpdateTour({required this.tour});
}

class AssignCarEvent extends TourEvent {
  String deliveryId;
  String carId;

  AssignCarEvent({required this.deliveryId, required this.carId});
}

class IncrementArticleScanAmount extends TourEvent {
  String internalArticleId;
  String deliveryId;
  String carId;

  IncrementArticleScanAmount({
    required this.internalArticleId,
    required this.deliveryId,
    required this.carId,
  });
}

class ScanArticleEvent extends TourEvent {
  ScanArticleEvent({
    required this.articleNumber,
    required this.carId,
    required this.deliveryId,
  });

  String articleNumber;
  String deliveryId;
  String carId;
}

class CancelDeliveryEvent extends TourEvent {
  String deliveryId;

  CancelDeliveryEvent({required this.deliveryId});
}

class HoldDeliveryEvent extends TourEvent {
  String deliveryId;

  HoldDeliveryEvent({required this.deliveryId});
}

class ReactivateDeliveryEvent extends TourEvent {
  String deliveryId;

  ReactivateDeliveryEvent({required this.deliveryId});
}

class LoadDeliveryEvent extends TourEvent {
  LoadDeliveryEvent({required this.delivery});

  Delivery delivery;
}

class UnscanArticleEvent extends TourEvent {
  UnscanArticleEvent({
    required this.articleId,
    required this.newAmount,
    required this.reason,
    required this.deliveryId,
  });

  String articleId;
  String deliveryId;
  String reason;
  int newAmount;
}

class ResetScanAmountEvent extends TourEvent {
  ResetScanAmountEvent({required this.articleId, required this.deliveryId});

  String articleId;
  String deliveryId;
}

class AddDiscountEvent extends TourEvent {
  AddDiscountEvent({
    required this.deliveryId,
    required this.value,
    required this.reason,
  });

  String deliveryId;
  String reason;
  int value;
}

class RemoveDiscountEvent extends TourEvent {
  RemoveDiscountEvent({required this.deliveryId});

  String deliveryId;
}

class UpdateDiscountEvent extends TourEvent {
  UpdateDiscountEvent({
    required this.deliveryId,
    required this.value,
    required this.reason,
  });

  String deliveryId;
  String? reason;
  int? value;
}

class CarsLoadedEvent extends TourEvent {
  List<Car> cars;

  CarsLoadedEvent({required this.cars});
}

class UpdateDeliveryOptionEvent extends TourEvent {
  UpdateDeliveryOptionEvent({
    required this.key,
    required this.value,
    required this.deliveryId,
  });

  String deliveryId;
  String key;
  dynamic value;
}

class UpdateSelectedPaymentMethodEvent extends TourEvent {
  UpdateSelectedPaymentMethodEvent({
    required this.payment,
    required this.deliveryId,
  });

  Payment payment;
  String deliveryId;
}

class FinishDeliveryEvent extends TourEvent {
  FinishDeliveryEvent({
    required this.deliveryId,
    required this.driverSignature,
    required this.customerSignature,
  });

  String deliveryId;
  Uint8List customerSignature;
  Uint8List driverSignature;
}
