feat(ui): toast entegrasyonu (sonner)
All checks were successful
Build MIPS Binary / build (push) Successful in 5m13s
All checks were successful
Build MIPS Binary / build (push) Successful in 5m13s
This commit is contained in:
@@ -7,19 +7,21 @@ use std::collections::HashMap;
|
||||
use struct_patch::traits::Patch;
|
||||
use base64::{Engine as _, engine::general_purpose::STANDARD as BASE64};
|
||||
|
||||
use crate::components::toast::ToastContext;
|
||||
use crate::components::ui::toast::{ToastType, toast};
|
||||
|
||||
pub fn show_toast(level: NotificationLevel, message: impl Into<String>) {
|
||||
let msg = message.into();
|
||||
gloo_console::log!("TOAST CALL:", &msg, format!("{:?}", level));
|
||||
log::info!("Displaying toast: [{:?}] {}", level, msg);
|
||||
|
||||
if let Some(context) = use_context::<ToastContext>() {
|
||||
context.add(msg, level);
|
||||
} else {
|
||||
log::error!("ToastContext not found!");
|
||||
gloo_console::error!("ToastContext not found!");
|
||||
}
|
||||
let variant = match level {
|
||||
NotificationLevel::Success => ToastType::Success,
|
||||
NotificationLevel::Error => ToastType::Error,
|
||||
NotificationLevel::Warning => ToastType::Warning,
|
||||
NotificationLevel::Info => ToastType::Info,
|
||||
};
|
||||
|
||||
toast(msg, variant);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user