import { Pagination, ListQueryParams } from "redux/Common/types";
import { Requestor } from "redux/Requestor/types";
import { Talent } from "redux/Talent/types";
import { Experience } from "redux/Experience/types";
import { User } from "redux/User/types";
import { AvailablePeriod } from "models/availability-calendar/availability-calendar.model";

export enum PURCHASE_TYPE {
  ALL_PURCHASES = "all_purchase",
}

type Video = {
  createdAt: string;
  id: string;
  status: string;
  updatedAt: string;
  videoOriginalSource: string;
  zencoderJobId: string;
  metadata: {
    duration_in_ms: number;
    file_size_in_bytes: number;
    format: string;
    height: number;
    id: number;
    state: string;
    url: string;
    width: number;
  }[];
};

export type Booking = {
  createdAt?: string;
  updatedAt?: string;
  isExpired?: boolean;
  description?: string;
  id?: number;
  forMe?: boolean;
  from?: string | null;
  to?: string | null;
  message?: string;
  isPublic?: boolean;
  status?: string;
  videos?: Video[];
  requestor?: Requestor;
  talent?: Talent;
  occasion?: {
    id: number;
    name: string;
  };
  experience?: Experience;
  paymentStatus?: string;
  date?: string;
  duration?: number;
  room?: {
    id: number;
    roomId: string;
    name: string;
    url: string;
  };
  notes?: string;
  rejected?: {
    reason?: string;
  };
  completed?: {
    rating?: number;
    comment?: string;
    tips: number;
  };
  rejectNotes?: string;
  transactions?: {
    amount: string;
    braintreeTransactions: any;
    createdAt: string;
    id: string;
    paymentMethodNonce: string | null;
    pricePercent: string | null;
    transactionStatus: TransactionStatus;
    transactionType: string;
    updatedAt: string;
    iapLocalPrice: number;
    iapCurrencyCode: string;
    couponCodeId: string;
    paymentGatewayProvider: string;
    chargeAmountGBP: number;
    chargeAmountLocal: number;
    chargeCurrency: string;
  }[];
  shortenId?: string;
  type: string;
  chargeAmountLocal?: number;
  chargeAmountGBP?: number;
  chargeCurrency?: string;
  experiencePriceGBP?: number;
  experiencePrice?: number;
  attachments?: {
    id: string;
    url: string[];
  };
  availablePeriod?: AvailablePeriod;
};

export enum TransactionStatus {
  PENDING = "PENDING",
  ACCEPTED = "ACCEPTED",
  REJECTED = "REJECTED",
  REFUNDED = "REFUNDED",
  REFUND_PENDING = "REFUND_PENDING",
  REFUND_FAILED = "REFUND_FAILED",
}

export enum PaymentMethodType {
  CREDIT_CARD = "credit_card",
  APPLE_PAY = "apple_pay",
  BRAINTREE = "BRAINTREE",
  PAYPAL = "paypal_account",
  APPLE_IAP = "APPLE_IAP",
  GOOGLE_IAP = "GOOGLE_IAP",
  STRIPE = "STRIPE",
}

export type GetBookingRequest = {
  userId: User["id"];
  params: ListQueryParams;
};

export type UpdateBookingAttachmentsRequest = {
  id: string;
  urls: string[];
};

export type GetBookingDetailRequest = {
  userId: User["id"];
  bookingId: Booking["id"];
};

export type RejectBookingRequest = {
  bookingId: Booking["id"];
  notes: string;
};

export type CompleteBookingRequest = {
  bookingId: Booking["id"];
  notes: string;
};

export type BookingState = {
  bookings1To1?: Pagination<Booking[]> | null;
  booking1To1Data?: Booking | null;
  upcomingBookings?: Pagination<Booking[]> | null;
  lastestPurchases?: Pagination<Booking[]> | null;
  error?: string | null;
  loading: boolean;
  isCompletedRoom: boolean;
  bookingSetup: number[];
};

export enum BookingStatusType {
  ALL = "all",
  PENDING = "pending",
  REJECTED = "declined",
  EXPIRED = "expired",
  COMPLETED = "completed",
  UNCOMPLETED = "uncompleted",
  ACCEPTED = "accepted",
  ADMIN_APPROVAL_PENDING = "admin_approval_pending", //waiting for admin approval
  TALENT_APPROVAL_PENDING = "talent_approval_pending", //waiting for talent approval
  ADMIN_DECLINED = "admin_declined", //Admin rejected
  DECLINED = "declined", //Talent rejected
  CANCELED = "canceled", //Canceled
  REFUNDED = "REFUNDED",
  REFUND_PENDING = "REFUND_PENDING",
  REFUND_FAILED = "REFUND_FAILED",
  PAYMENT_FAILED = "payment_failed", //No success payment until required completion date
}

export enum BOOKING_STATUS {
  ADMIN_APPROVAL_PENDING = "admin_approval_pending",
  TALENT_APPROVAL_PENDING = "talent_approval_pending",
  ADMIN_DECLINED = "admin_declined",
  CANCELED = "canceled",
  PENDING = "pending",
  ACCEPTED = "accepted",
  DECLINED = "declined",
  COMPLETED = "completed",
  EXPIRED = "expired",
  UNCOMPLETED = "uncompleted",
  PAYMENT_FAILED = "payment_failed",
}
