//
//  ActionAlertHandler.swift
//  MVMCoreUI
//
//  Created by Scott Pfeil on 7/18/22.
//  Copyright © 2022 Verizon Wireless. All rights reserved.
//

import Foundation
import MVMCore

/// Shows an alert using the model.
open class ActionAlertHandler: MVMCoreActionHandlerProtocol {
    required public init() {}
    
    public func execute(with model: ActionModelProtocol, delegateObject: DelegateObject?, additionalData: [AnyHashable : Any]?) async throws {
        guard let model = model as? ActionAlertModel else { return }
        let alertObject = AlertObject(alertModel: model.alert, alertDelegate: (delegateObject as? MVMCoreUIDelegateObject)?.alertDelegate)
        _ = await AlertHandler.shared().queueAlertToShow(with: alertObject)
    }
}
