Skip to content

Commit

Permalink
feat(ui): add subs notification
Browse files Browse the repository at this point in the history
  • Loading branch information
DefectingCat committed Feb 13, 2025
1 parent b3c5677 commit 414a01f
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions venus-ui/src/components/home_page/subscripiton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use crate::{
components::subscription_card::{SubCardForm, SubscriptionCard},
hooks::{use_global_ui, use_global_user},
utils::error_to_string,
User,
Notification, NotificationKind, User,
};
use gloo::net::http::Method;
use leptos::{logging, prelude::*};
use leptos::prelude::*;
use serde::{Deserialize, Serialize};
use web_sys::MouseEvent;

Expand Down Expand Up @@ -158,6 +158,7 @@ pub fn Subscription() -> impl IntoView {
url: "".into(),
});

let ui = use_global_ui();
let user = use_global_user();

let form_ref: NodeRef<leptos::html::Form> = NodeRef::new();
Expand All @@ -179,11 +180,35 @@ pub fn Subscription() -> impl IntoView {
add_action.dispatch(form());
};
Effect::new(move |_| {
logging::log!("test {:?}", add_result.get());
let result = add_result.get();
if let Some(res) = result {
match res {
Ok(response) => ui.notifications.update(|nts| {
if response.code == 200 {
nts.push(Notification::new(
NotificationKind::Success,
"Add subscription success".into(),
));
} else {
nts.push(Notification::new(
NotificationKind::Success,
response.message.clone(),
));
}
}),
Err(err) => {
ui.notifications.update(|nts| {
nts.push(Notification::new(
NotificationKind::Error,
format!("Add subscription failed {}", err),
));
});
}
}
}
});

// subscriptions
let ui = use_global_ui();
let subscriptions = move || ui.proxies.get().subscriptions;

view! {
Expand Down

0 comments on commit 414a01f

Please sign in to comment.