import { FuelType, FuelGrade } from './fuel-logs.types';

export interface FuelGradeOption {
  value: FuelGrade;
  label: string;
  description?: string;
}

export class FuelGradeService {
  static getFuelGradeOptions(fuelType: FuelType): FuelGradeOption[] {
    switch (fuelType) {
      case FuelType.GASOLINE:
        return [
          { value: '87', label: '87 (Regular)', description: 'Regular unleaded gasoline' },
          { value: '88', label: '88 (Mid-Grade)' },
          { value: '89', label: '89 (Mid-Grade Plus)' },
          { value: '91', label: '91 (Premium)' },
          { value: '93', label: '93 (Premium Plus)' }
        ];
      case FuelType.DIESEL:
        return [
          { value: '#1', label: '#1 Diesel', description: 'Light diesel fuel' },
          { value: '#2', label: '#2 Diesel', description: 'Standard diesel fuel' }
        ];
      case FuelType.ELECTRIC:
        return [];
      default:
        return [];
    }
  }

  static isValidGradeForFuelType(fuelType: FuelType, fuelGrade?: FuelGrade): boolean {
    if (!fuelGrade) return fuelType === FuelType.ELECTRIC;
    return this.getFuelGradeOptions(fuelType).some(opt => opt.value === fuelGrade);
  }

  static getDefaultGrade(fuelType: FuelType): FuelGrade {
    switch (fuelType) {
      case FuelType.GASOLINE:
        return '87';
      case FuelType.DIESEL:
        return '#2';
      case FuelType.ELECTRIC:
        return null;
      default:
        return null;
    }
  }
}

