Skip to content

Commit

Permalink
chore(web): change the register to login status (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael-Liendo authored Sep 10, 2024
1 parent d202efa commit 4422108
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
18 changes: 13 additions & 5 deletions crates/web/src/components/auth/register.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::str::FromStr;

use leptos::{
component, create_action, create_rw_signal, create_signal, view, IntoView, Show, SignalGet,
SignalGetUntracked, SignalSet,
component, create_action, create_rw_signal, create_signal, view, IntoView, RwSignal, Show,
SignalGet, SignalGetUntracked, SignalSet,
};

use townhall_client::Client;
Expand All @@ -11,7 +11,10 @@ use townhall_types::user::Email;
use crate::components::text_field::{TextField, TextFieldType};

#[component]
pub fn SignupCard() -> impl IntoView {
pub fn SignupCard(
#[prop(into)] signup_status: RwSignal<bool>,
#[prop(into)] login_status: RwSignal<bool>,
) -> impl IntoView {
let (error_getter, error_setter) = create_signal::<Option<String>>(None);

let name_value = create_rw_signal(String::default());
Expand All @@ -38,6 +41,11 @@ pub fn SignupCard() -> impl IntoView {
}
});

let handle_switch = move |_| {
signup_status.set(false);
login_status.set(true);
};

view! {

<div class="w-96 p-6 bg-white border border-gray-200 rounded-lg shadow">
Expand Down Expand Up @@ -87,9 +95,9 @@ pub fn SignupCard() -> impl IntoView {
</Show>
</form>
<div class="text-center mt-3">
{"Do you have an account? "} <a class="underline" href="/login">
{"Do you have an account? "} <button on:click=handle_switch class="underline" >
Log In
</a>
</button>
</div>
</div>

Expand Down
2 changes: 1 addition & 1 deletion crates/web/src/components/layout/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub fn Header() -> impl IntoView {
</header>
<Modal modal_status=is_open_auth_signup_modal>
<Show when=move || is_open_auth_signup_modal.get() fallback=move || ()>
<SignupCard />
<SignupCard login_status=is_open_auth_login_modal signup_status=is_open_auth_signup_modal />
</Show>
</Modal >
<Modal modal_status=is_open_auth_login_modal >
Expand Down

0 comments on commit 4422108

Please sign in to comment.