import SwiftUI

enum LoadConfigurationStatus: Identifiable, Equatable {
    case missingDetails(count: Int)

    var id: String {
        switch self {
        case .missingDetails(let count):
            return "missing-details-\(count)"
        }
    }

    var symbol: String {
        switch self {
        case .missingDetails:
            return "exclamationmark.triangle.fill"
        }
    }

    var tint: Color {
        switch self {
        case .missingDetails:
            return .orange
        }
    }

    var bannerText: String {
        switch self {
        case .missingDetails:
            return String(
                localized: "loads.overview.status.missing_details.banner",
                defaultValue: "Finish configuring your loads"
            )
        }
    }

    func detailInfo() -> LoadStatusDetail {
        switch self {
        case .missingDetails(let count):
            let title = String(
                localized: "loads.overview.status.missing_details.title",
                defaultValue: "Missing load details"
            )
            let format = String(
                localized: "loads.overview.status.missing_details.message",
                defaultValue: "Enter cable length and wire size for %d %@ to see accurate recommendations."
            )
            let loadWord = count == 1
                ? String(
                    localized: "loads.overview.status.missing_details.singular",
                    defaultValue: "load"
                )
                : String(
                    localized: "loads.overview.status.missing_details.plural",
                    defaultValue: "loads"
                )
            let message = String(format: format, count, loadWord)
            return LoadStatusDetail(title: title, message: message)
        }
    }
}

struct LoadStatusDetail {
    let title: String
    let message: String
}
