use crate::domain::api::prelude::Alert;
use leptos::*;

#[component]
pub fn Alert(alert: Alert, children: Children) -> impl IntoView {
    match alert {
        Alert::None => view! {
            <div role="alert" class="alert my-2">
                <span>{ children() }</span>
            </div>
        }
        .into_view(),
        Alert::Info => view! {
            <div role="alert" class="alert alert-info my-2">
                <i class="fas fa-info-circle"></i>
                <span>{ children() }</span>
            </div>
        }
        .into_view(),
        Alert::Success => view! {
            <div role="alert" class="alert alert-success my-2">
                <i class="fas fa-check-circle"></i>
                <span>{ children() }</span>
            </div>
        }
        .into_view(),
        Alert::Warning => view! {
            <div role="alert" class="alert alert-warning my-2">
                <i class="fas fa-exclamation-triangle"></i>
                <span>{ children() }</span>
            </div>
        }
        .into_view(),
        Alert::Error => view! {
            <div role="alert" class="alert alert-error my-2">
                <i class="fas fa-exclamation-circle"></i>
                <span>{ children() }</span>
            </div>
        }
        .into_view(),
    }
}
