import type { Selectable } from "kysely";
import type { BookingItineraries, Bookings, BookingUnits } from "../datastore/db";
import type { BookingEntityType } from "./booking.types";

export interface IBookingRepository {
  CreateEntry: (entry: {
    member_id: string;
    entity_type: BookingEntityType;
    entity_code: string;
    entity_name: string;
    additional_data?: Record<string, string | boolean | number>;
    itinerary?: Omit<
      Selectable<BookingItineraries>,
      "id" | "booking_destination_id" | "created_at" | "updated_at"
    >;
    units?: (Omit<
      Selectable<BookingUnits>,
      "id" | "booking_id" | "booking_ext_ref_id" | "created_at" | "updated_at"
    > & {
      external_source?: {
        inventory_id?: string;
        ref_id: string;
        source_name: "RCI" | "GUESTLINE";
        additional_data?: Record<string, string | boolean | number>;
      };
      guests: {
        member_number: string;
        type: string;
        additional_data?: Record<string, string | boolean | number>;
      }[];
      charges: {
        type: string;
        name: string;
        value: number;
        currency?: string;
        note?: string;
        additional_data?: Record<string, string | boolean | number>;
      }[];
    })[];
    note?: string;
  }) => Promise<Selectable<Bookings> | null>;
}

export interface IBookingServices {
  CreateUnitHold: (
    entity_code: string,
    entity_name: string,
    entity_type: BookingEntityType,
    unit: {
      code: string;
      name: string;
      check_in_date: string;
      check_out_date: string;
      guests: {
        member_number: string;
        send_confirmation: boolean;
      };
      note?: string;
      additional_data?: Record<string, string | boolean | number>;
    },
    note?: string,
    additional_data?: Record<string, string | boolean | number>,
  ) => Promise<void>;
  ConfirmUnitHold: () => void;
  ReleaseUnitHold: () => void;
  CancelConfirmedUnitBooking: () => void;
}
