export type Energy = "diesel" | "petrol" | "electricity";

/** manual / market: a range of the client. own, clients, default: computed when no range applies. */
export type EnergyPriceOrigin = "manual" | "market" | "own" | "clients" | "default";

export interface EnergyPriceRange {
  id: number;
  starts_on: string;
  /** The day before the next range starts; null for the range in force. */
  ends_on: string | null;
  price: number;
  origin: "manual" | "market";
}

export interface EnergyPrices {
  energy: Energy;
  unit: string;
  current: { price: number; origin: EnergyPriceOrigin; starts_on: string | null };
  /** Dadycar clients' 7-day average. */
  market: number | null;
  ranges: EnergyPriceRange[];
}

export interface CompanyEnergyPrices {
  energies: EnergyPrices[];
}

export interface EnergyPriceRangeInput {
  energy: Energy;
  starts_on: string;
  price: number;
}

/** Who set a vehicle's battery size: typed by hand, estimated from make and model, or reported by the car. */
export type BatterySource = "manual" | "estimated" | "reported";

export interface CompanyBatteryVehicle {
  id: number;
  numberplate: string;
  mark: string | null;
  model: string | null;
  battery_capacity: number | null;
  battery_capacity_source: BatterySource | null;
  connected: boolean;
  site: { id: number; name: string } | null;
}

export interface CompanyBatteries {
  summary: { vehicles: number; missing: number; manual: number; estimated: number; reported: number };
  vehicles: CompanyBatteryVehicle[];
}
