From 8a901ac754c1cf1df99b04458a2be763b2325d46 Mon Sep 17 00:00:00 2001 From: John Lewis Date: Fri, 29 Mar 2024 15:09:13 +0100 Subject: [PATCH] feat: cross-link the auth pages --- crates/site-app/src/pages/auth/login_page.rs | 12 +++++++++++- crates/site-app/src/pages/auth/signup_page.rs | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/crates/site-app/src/pages/auth/login_page.rs b/crates/site-app/src/pages/auth/login_page.rs index 18cbfa1..2cf9f57 100644 --- a/crates/site-app/src/pages/auth/login_page.rs +++ b/crates/site-app/src/pages/auth/login_page.rs @@ -28,6 +28,7 @@ pub fn LoginPageInner(next_url: Option) -> impl IntoView { let (email, set_email) = create_signal(String::new()); let (password, set_password) = create_signal(String::new()); let (remember, set_remember) = create_signal(false); + let next_url = create_memo(move |_| next_url.clone()); // create the params, aborting if validation fails let params: Memo = create_memo(move |_| { @@ -102,13 +103,22 @@ pub fn LoginPageInner(next_url: Option) -> impl IntoView { create_effect(move |_| { if matches!(value(), Some(Ok(true))) { - navigate_to(&next_url.clone().unwrap_or("/".to_string())); + navigate_to(&next_url().unwrap_or("/".to_string())); } }); view! {

"Login to PicturePro"

+

+ "Enter your email and password to login. No account? " + + "Sign up here." + +

{ email_element } { password_element } diff --git a/crates/site-app/src/pages/auth/signup_page.rs b/crates/site-app/src/pages/auth/signup_page.rs index 65b4e05..98baa72 100644 --- a/crates/site-app/src/pages/auth/signup_page.rs +++ b/crates/site-app/src/pages/auth/signup_page.rs @@ -31,6 +31,7 @@ pub fn SignupPageInner(next_url: Option) -> impl IntoView { let (password, set_password) = create_signal(String::new()); let (confirm, set_confirm) = create_signal(String::new()); let (remember, set_remember) = create_signal(false); + let next_url = create_memo(move |_| next_url.clone()); let params: Memo> = create_memo(move |_| { with!(|name, email, password, confirm, remember| { @@ -123,13 +124,22 @@ pub fn SignupPageInner(next_url: Option) -> impl IntoView { create_effect(move |_| { if matches!(value(), Some(Ok(_))) { - navigate_to(&next_url.clone().unwrap_or("/".to_string())); + navigate_to(&next_url().unwrap_or("/".to_string())); } }); view! {

"Sign Up to PicturePro"

+

+ "Already have an account? " + + "Login here." + +

{ name_element } { email_element }