function normalizeLocations(value: unknown) {
  return Array.isArray(value) ? value.filter((entry): entry is string => typeof entry === 'string') : []
}

export function presentVehicle(vehicle: any) {
  return {
    ...vehicle,
    pickupLocations: normalizeLocations(vehicle?.pickupLocations),
    allowDifferentDropoff: Boolean(vehicle?.allowDifferentDropoff),
    dropoffLocations: normalizeLocations(vehicle?.dropoffLocations),
  }
}

export function presentVehicleList(vehicles: any[], meta: { total: number; page: number; pageSize: number; totalPages: number }) {
  return { data: vehicles, ...meta }
}
