Added songdetails component

This commit is contained in:
Daniel Miller 2024-12-11 04:37:28 +00:00
parent 4c46f78135
commit 186821d838

View File

@ -41,3 +41,40 @@ pub fn SongPage() -> impl IntoView {
</div> </div>
} }
} }
#[component]
fn SongDetails(#[prop(into)] id: MaybeSignal<i32>) -> impl IntoView {
let song_info = create_resource(move || id.get(), move |id| {
get_song_by_id(id)
});
view! {
<Transition
fallback=move || view! { <LoadingPage /> }
>
{move || song_info.get().map(|song| {
match song {
Ok(Some(song)) => {
view! { <SongOverview song /> }.into_view()
},
Ok(None) => {
view! {
<Error<String>
title="Song Not Found"
message=format!("Song with ID {} not found", id.get())
/>
}.into_view()
},
Err(error) => {
view! {
<ServerError<NoCustomError>
title="Error Fetching Song"
error
/>
}.into_view()
}
}
})}
</Transition>
}
}