import {
  TravelEventInvitationRequest,
  TravelEventLocationType,
  TravelEventTrainItineraryType,
  TravelEventTravelWindowsDateTimeType,
  TravelEventVertical
} from '@admin-factory/interface/guest_travel';
import { faker } from '@faker-js/faker';
import { Dates } from '@utility-lib/dates';

export function createTrainGuestTravel(
  userResponse: any,
  paymentMethodUuid: string
): TravelEventInvitationRequest {
  const guestTravel: TravelEventInvitationRequest = {
    settings: {
      notificationSettings: {
        enabledOrganizerNotifications: [],
        enabledParticipantNotifications: [],
        enabledParticipantReminders: []
      },
      travelConditions: {
        accommodation: {
          hotelConditions: {
            numberOfBookingsAllowed: 0
          }
        },
        transportation: {
          carConditions: {
            numberOfBookingsAllowed: 0
          },
          flightConditions: {
            numberOfBookingsAllowed: 0
          },
          trainConditions: {
            numberOfBookingsAllowed: 1,
            allowedItineraryTypes: [TravelEventTrainItineraryType.ONE_WAY]
          }
        },
        commute: {
          blackCars: [],
          cars: [],
          trains: []
        },
        travelWindows: [
          {
            verticals: [
              TravelEventVertical.FLIGHT,
              TravelEventVertical.HOTEL,
              TravelEventVertical.CAR,
              TravelEventVertical.BLACK_CAR,
              TravelEventVertical.RAIL
            ],
            earliestDepartureDateTime: {
              value: Dates.getDateTime(31).slice(0, 10).concat('T12:00'),
              type: TravelEventTravelWindowsDateTimeType.MANDATORY
            },
            latestReturnDateTime: {
              value: Dates.getDateTime(35).slice(0, 10).concat('T12:00'),
              type: TravelEventTravelWindowsDateTimeType.MANDATORY
            },
            latestArrivalDateTime: {
              value: Dates.getDateTime(31).slice(0, 10).concat('T12:00'),
              type: TravelEventTravelWindowsDateTimeType.SUGGESTED
            },
            earliestLeaveDateTime: {
              value: Dates.getDateTime(35).slice(0, 10).concat('T12:00'),
              type: TravelEventTravelWindowsDateTimeType.SUGGESTED
            }
          }
        ],
        payment: {
          allowedPaymentMethodIds: [paymentMethodUuid],
          allowedCarDirectBillPaymentMethodIds: [],
          addingNewPaymentMethodAllowed: false
        },
        numberOfExtraGuestsAllowed: 0,
        companyPolicyLevelId: userResponse.companyPolicyLevel.uuid
      },
      reportingSettings: {
        billTo: undefined,
        region: undefined,
        subsidiary: undefined,
        department: undefined,
        customFieldValues: []
      }
    },
    summary: {
      name: `TrainEvent-${faker.datatype.number({ min: 10000000 })}`,
      description: '',
      pictureUrl: '',
      startDateTime: Dates.getDateTime(32).slice(0, 10).concat('T12:00'),
      endDateTime: Dates.getDateTime(34).slice(0, 10).concat('T12:00'),
      location: {
        placeId:
          'EhpOZXcgU3RyZWV0LCBCaXJtaW5naGFtLCBVSyIuKiwKFAoSCSsWIU6JvHBIEQd-t699Q2a6EhQKEgk5MAZ4NLpwSBF1EoEaKyMk2w',
        displayName: 'New Street, Birmingham, UK',
        type: TravelEventLocationType.PLACE,
        companyOfficeId: undefined,
        companyOfficeName: undefined
      },
      note: [],
      cancellationNote: []
    },
    participants: [
      {
        email: userResponse.email,
        givenName: faker.name.firstName(),
        familyName: faker.name.lastName().replace(/'/g, ''),
        billTo: undefined,
        department: undefined
      }
    ],
    contactId: userResponse.uuid,
    shouldSendEmail: false
  };

  return guestTravel;
}
