
enum RouteStatisticType: String, CaseIterable {

    case elevation

    case speed

    case pace

    case heartRate = "heart-rate"

    case energy

    var order: Int {
        switch self {
        case .elevation: 1
        case .speed: 2
        case .pace: 3
        case .heartRate: 4
        case .energy: 5
        }
    }

    var id: String {
        switch self {
        case .elevation: "elevation"
        case .speed: "speed"
        case .pace: "pace"
        case .heartRate: "hr"
        case .energy: "energy"
        }
    }

    var unit: String {
        switch self {
        case .elevation: "m"
        case .speed: "km/h"
        case .pace: "min/km"
        case .heartRate: "bpm"
        case .energy: "kcal/min"
        }
    }

    var icon: PageIcon {
        switch self {
        case .elevation: .statisticsElevationUp
        case .speed: .statisticsSpeedometer
        case .pace: .statisticsStopwatch
        case .heartRate: .statisticsHeart
        case .energy: .statisticsEnergy
        }
    }

    func displayText(in language: ContentLanguage) -> String {
        let localization: RouteLocalization = language == .english ? .english : .german
        return localization.statistics[self]!
    }
}

extension RouteStatisticType: Comparable {
    
    static func < (lhs: RouteStatisticType, rhs: RouteStatisticType) -> Bool {
        lhs.order < rhs.order
    }
}
