import Foundation
import Localization

public struct HookStatusAlertStyle: Equatable {
    public struct TextCopy: Equatable, Codable {
        let title: String
        let reasons: String
        let buttonLabel: String

        public init(title: String, reasons: String, buttonLabel: String) {
            self.title = title
            self.reasons = reasons
            self.buttonLabel = buttonLabel
        }

        func toString() -> String {
            return "\(title)|\(reasons)|\(buttonLabel)"
        }
    }

    public let reasons: [String]

    public init(reasons: [String]) {
        self.reasons = reasons
    }

    public var formattedReasons: String {
        reasons
            .map { $0.capitalized }
            .joined(separator: ", ")
    }

    public var textCopy: TextCopy {
        return TextCopy(
            title: L10n.FeatureHooks.videoFailedToPost,
            reasons: formattedReasons,
            buttonLabel: L10n.FeatureHooks.close
        )
    }
}
