Compare commits

..

4 Commits

3 changed files with 105 additions and 13 deletions

View File

@ -10,7 +10,6 @@ use crate::components::loading::Loading;
pub fn Login() -> impl IntoView { pub fn Login() -> impl IntoView {
let (username_or_email, set_username_or_email) = create_signal("".to_string()); let (username_or_email, set_username_or_email) = create_signal("".to_string());
let (password, set_password) = create_signal("".to_string()); let (password, set_password) = create_signal("".to_string());
let (two_fa_code, set_two_fa_code) = create_signal("".to_string());
let (show_password, set_show_password) = create_signal(false); let (show_password, set_show_password) = create_signal(false);
@ -28,8 +27,6 @@ pub fn Login() -> impl IntoView {
let username_or_email1 = username_or_email.get(); let username_or_email1 = username_or_email.get();
let password1 = password.get(); let password1 = password.get();
let two_fa_code1 = two_fa_code.get();
spawn_local(async move { spawn_local(async move {
loading.set(true); loading.set(true);
error_msg.set(None); error_msg.set(None);
@ -109,16 +106,6 @@ pub fn Login() -> impl IntoView {
</Show> </Show>
</div> </div>
<div class="input-box">
<input class="login-2fa" type="text" required
on:input = move |ev| {
set_two_fa_code(event_target_value(&ev));
log!("2FA code changed to: {}", two_fa_code.get());
}
/>
<span>2FA Code</span>
<i></i>
</div>
<a href="" class="forgot-pw">Forgot Password?</a> <a href="" class="forgot-pw">Forgot Password?</a>
<div class="error-msg" >{ move || error_msg.get() }</div> <div class="error-msg" >{ move || error_msg.get() }</div>
<Show <Show

92
src/pages/songpage.rs Normal file
View File

@ -0,0 +1,92 @@
use leptos::*;
use leptos_router::use_params_map;
use leptos_icons::*;
use server_fn::error::NoCustomError;
use crate::components::loading::*;
use crate::components::error::*;
use crate::api::song::*;
use crate::models::Song;
use crate::songs::get_song_by_id;
#[component]
pub fn SongPage() -> impl IntoView {
let params = use_params_map();
view! {
<div class="song-container home-component">
{move || params.with(|params| {
match params.get("id").map(|id| id.parse::<i32>()) {
Some(Ok(id)) => {
view! { <SongDetails id /> }.into_view()
},
Some(Err(e)) => {
view! {
<Error<String>
title="Invalid Song ID"
error=e.to_string()
/>
}.into_view()
},
None => {
view! {
<Error<String>
title="No Song ID"
message="You must specify a song ID to view its page."
/>
}.into_view()
}
}
})}
</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>
}
}
#[component]
fn SongOverview(song: Song) -> impl IntoView {
view! {
<div class="song-header">
<h1>{song.title}</h1>
<p>{format!("Artist: {}", song.artist)}</p>
<p>{format!("Album: {}", song.album.unwrap_or_else(|| "Unknown".to_string()))}</p>
<p>{format!("Duration: {}", song.duration)}</p>
</div>
}
}

13
style/songpage.scss Normal file
View File

@ -0,0 +1,13 @@
.song-container {
.song-header {
h1 {
font-size: 2.5rem;
margin-bottom: 0.5rem;
}
p {
font-size: 1.2rem;
margin: 0.2rem 0;
}
}
}