From 8dbaaf317db49b6afa60ced05251067228565b72 Mon Sep 17 00:00:00 2001 From: Daniel Miller Date: Wed, 11 Dec 2024 03:44:13 +0000 Subject: [PATCH] Added ArtistProfile component to get artist info based on id --- src/pages/artist.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/pages/artist.rs b/src/pages/artist.rs index 978b2cc..249f268 100644 --- a/src/pages/artist.rs +++ b/src/pages/artist.rs @@ -38,3 +38,34 @@ pub fn ArtistPage() -> impl IntoView { } } + +#[component] +fn ArtistProfile(#[prop(into)] id: MaybeSignal) -> impl IntoView { + let artist_info = create_resource(move || id.get(), move |id| { + get_artist_by_id(id) + }); + + view! { + } + > + {move || artist_info.get().map(|artist| { + match artist { + Ok(Some(artist)) => view! { }.into_view(), + Ok(None) => view! { + + title="Artist Not Found" + message=format!("Artist with ID {} not found", id.get()) + /> + }.into_view(), + Err(error) => view! { + + title="Error Getting Artist" + error + /> + }.into_view(), + } + })} + + } +}