Use GlobalState instead of passing play_status/logged_in_user everywhere

This commit is contained in:
2024-11-15 18:49:19 -05:00
parent d42737f856
commit f0f34d4abe
6 changed files with 85 additions and 89 deletions

View File

@ -1,12 +1,12 @@
use crate::auth::signup;
use crate::models::User;
use crate::util::state::GlobalState;
use leptos::leptos_dom::*;
use leptos::*;
use leptos_icons::*;
use crate::app::LoggedInUserResource;
#[component]
pub fn Signup(user: LoggedInUserResource) -> impl IntoView {
pub fn Signup() -> impl IntoView {
let (username, set_username) = create_signal("".to_string());
let (email, set_email) = create_signal("".to_string());
let (password, set_password) = create_signal("".to_string());
@ -30,6 +30,8 @@ pub fn Signup(user: LoggedInUserResource) -> impl IntoView {
};
log!("new user: {:?}", new_user);
let user = GlobalState::logged_in_user();
spawn_local(async move {
if let Err(err) = signup(new_user.clone()).await {
// Handle the error here, e.g., log it or display to the user