-
+
impl IntoView {
/// is authenticated, this component will get all the scholarships that this provider owns and
/// will display them in a list, giving them the option to edit, delete, or create new scholarships.
///
-/// It does not accept any props, and instead pulls the provider's information from the surrounding
-/// environment.
-///
/// Example usage:
/// ```
+/// let refresh = RwSignal::new(0);
+///
/// view! {
///
///
-///
+///
///
///
/// }
/// ```
#[component]
fn ScholarshipList(
+ /// A signal that refreshes the list when changed. Most times, we don't need to worry about the
+ /// user reloading our page 2 billion times.
#[prop()] refresh_token: RwSignal,
+ /// A callback that is run on successful server-side deletion of an item.
+ #[prop(into)] on_delete: Callback<()>
) -> impl IntoView {
// List state
let pending_delete = RwSignal::new(None::);
@@ -125,7 +139,7 @@ fn ScholarshipList(
});
};
- let on_delete = move |s| {
+ let on_item_delete = move |s| {
pending_delete.set(Some(s));
};
@@ -149,6 +163,7 @@ fn ScholarshipList(
scholarships.refetch();
pending_delete.set(None);
delete_action.clear();
+ on_delete.run(());
}
});
@@ -213,7 +228,7 @@ fn ScholarshipList(
let views = list.iter().map(|entry| {
view! {
+ on_delete=Callback::new(on_item_delete)/>
}
});
Either::Left(views.collect_view())