Add liked songs page
This commit is contained in:
38
src/pages/liked_songs.rs
Normal file
38
src/pages/liked_songs.rs
Normal 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>
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
Reference in New Issue
Block a user