Add liked songs page

This commit is contained in:
2025-05-06 03:17:35 +00:00
parent d2aebde562
commit f61507b197
3 changed files with 41 additions and 0 deletions

38
src/pages/liked_songs.rs Normal file
View File

@ -0,0 +1,38 @@
use crate::components::error::*;
use crate::components::loading::*;
use crate::components::song_list::*;
use leptos::either::*;
use leptos::prelude::*;
use crate::api::profile::get_liked_songs;
#[component]
pub fn LikedSongsPage() -> impl IntoView {
let liked_songs = Resource::new(|| (), |_| get_liked_songs());
view! {
<h1 class="text-4xl">"Liked Songs"</h1>
<Transition
fallback=move || view! { <LoadingPage /> }
>
{move || liked_songs.get().map(|songs| {
match songs {
Ok(songs) => {
Either::Left(view! {
<p class="text-neutral-500">{songs.len()} " liked songs"</p>
<SongList songs />
})
},
Err(e) => {
Either::Right(view! {
<Error<String>
title="Error loading liked songs"
error=e.to_string()
/>
})
}
}
})}
</Transition>
}
}

View File

@ -1,6 +1,7 @@
pub mod album;
pub mod artist;
pub mod dashboard;
pub mod liked_songs;
pub mod login;
pub mod playlist;
pub mod profile;