Skip to content

Commit

Permalink
feat: cross-link the auth pages
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbchron committed Mar 29, 2024
1 parent f65c0fc commit 8a901ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion crates/site-app/src/pages/auth/login_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub fn LoginPageInner(next_url: Option<String>) -> 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<LoginParams> = create_memo(move |_| {
Expand Down Expand Up @@ -102,13 +103,22 @@ pub fn LoginPageInner(next_url: Option<String>) -> 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! {
<form class="d-card-body" on:submit=submit_callback>
<p class="d-card-title text-2xl">"Login to PicturePro"</p>
<p class="d-card-subtitle">
"Enter your email and password to login. No account? "
<a
href={format!("/signup{}", next_url().map(|n| format!("?next={}", n)).unwrap_or_default())}
class="underline hover:no-underline"
>
"Sign up here."
</a>
</p>

{ email_element }
{ password_element }
Expand Down
12 changes: 11 additions & 1 deletion crates/site-app/src/pages/auth/signup_page.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub fn SignupPageInner(next_url: Option<String>) -> 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<Option<SignupParams>> = create_memo(move |_| {
with!(|name, email, password, confirm, remember| {
Expand Down Expand Up @@ -123,13 +124,22 @@ pub fn SignupPageInner(next_url: Option<String>) -> 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! {
<form class="d-card-body" on:submit=submit_callback>
<p class="d-card-title text-2xl">"Sign Up to PicturePro"</p>
<p class="d-card-subtitle">
"Already have an account? "
<a
href={format!("/login{}", next_url().map(|n| format!("?next={}", n)).unwrap_or_default())}
class="underline hover:no-underline"
>
"Login here."
</a>
</p>

{ name_element }
{ email_element }
Expand Down

0 comments on commit 8a901ac

Please sign in to comment.