feat(ui): toast entegrasyonu (sonner)
All checks were successful
Build MIPS Binary / build (push) Successful in 5m13s

This commit is contained in:
spinline
2026-02-11 21:32:39 +03:00
parent 7539307e18
commit a24e4101e8
8 changed files with 260 additions and 29 deletions

View File

@@ -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);
}