// Trip planning database
export type TripPlan = {
  id: number;
  name: string;
  destination: string;
  region: string;
  departureDate?: string;
  returnDate?: string;
  tripLength?: number;
  budget?: number;
  currency: string;
  status: "planning" | "booked" | "completed";
  preferences?: {
    beach?: number;
    pool?: number;
    golf?: number;
    spa?: number;
    food?: number;
    nightlife?: number;
    shopping?: number;
    culture?: number;
    outdoor?: number;
    family?: number;
  };
  resorts?: string[];
  notes?: string;
  createdAt: string;
  updatedAt: string;
};

// Sample trips
export const TRIP_PLANS: Record<number, TripPlan> = {
  1: {
    id: 1,
    name: "Jan 2026 Caribbean Holiday",
    destination: "Mexico & Dominican Republic",
    region: "Caribbean",
    departureDate: "2026-01-15",
    tripLength: 7,
    budget: 5500,
    currency: "CAD",
    status: "planning",
    preferences: {
      food: 10,
      pool: 9,
      beach: 8,
      nightlife: 7,
      golf: 6,
      spa: 5,
      outdoor: 4
    },
    resorts: [
      "Dreams Onyx Resort & Spa",
      "Excellence Riviera Cancun",
      "Secrets Maroma Beach",
      "Hyatt Ziva Cancun",
      "Moon Palace Cancun",
      "Barcelo Maya Riviera",
      "Grand Sirenis Riviera Maya",
      "Hotel Xcaret Mexico"
    ],
    notes: "All-inclusive beach vacation. Prefer adults-only or adult-focused resorts.",
    createdAt: "2025-10-29T00:00:00Z",
    updatedAt: "2025-10-29T00:00:00Z"
  },
  2: {
    id: 2,
    name: "Fall 2026 Japan Adventure",
    destination: "Tokyo, Kyoto, Osaka",
    region: "Asia",
    departureDate: "2026-10-15",
    tripLength: 14,
    budget: 8000,
    currency: "CAD",
    status: "planning",
    preferences: {
      culture: 10,
      food: 10,
      shopping: 8,
      outdoor: 7,
      nightlife: 6
    },
    notes: "Cherry blossom season alternative. Focus on temples, food tours, and cultural experiences.",
    createdAt: "2025-10-29T00:00:00Z",
    updatedAt: "2025-10-29T00:00:00Z"
  }
};

export function getAllTrips(): TripPlan[] {
  return Object.values(TRIP_PLANS);
}

export function getTripById(id: number | string): TripPlan | undefined {
  const numId = typeof id === 'string' ? parseInt(id, 10) : id;
  return TRIP_PLANS[numId];
}

export function getTripsByStatus(status: "planning" | "booked" | "completed"): TripPlan[] {
  return Object.values(TRIP_PLANS).filter(trip => trip.status === status);
}

export function getTripsByRegion(region: string): TripPlan[] {
  return Object.values(TRIP_PLANS).filter(trip => 
    trip.region.toLowerCase().includes(region.toLowerCase())
  );
}
