Moved login link logic to unauthenticated_page.rs

This commit is contained in:
meraghon committed 2025-10-03 11:48:00 -04:00
1 parent 20df508ed7
commit ade13e711f
1 file changed
+19 -5
+19 -5
View File
@@ -1,20 +1,34 @@
use leptos::leptos_dom::logging::console_log;
use leptos::prelude::*;
use leptos_oidc::{LoginLink};
use leptos_oidc::{AuthSignal};
use crate::components::ActionButton;
#[component]
pub fn UnauthenticatedPage() -> impl IntoView {
let auth = use_context::<AuthSignal>().expect("AuthSignal not present in LoginLink");
let login_url = move || {
auth.with(|auth| {
auth.unauthenticated()
.map(|unauthenticated| unauthenticated.login_url())
})
};
let navigate = leptos_router::hooks::use_navigate();
view! (
<div class="flex h-screen justify-center items-center pb-50">
<div class="bg-white p-8 border rounded-lg shadow-lg">
<h3> "You're not signed in. Please sign in with your Region 15 email." </h3>
<div class="flex pt-4 justify-center items-center">
<LoginLink class="text-login">
<ActionButton> "Sign in" </ActionButton>
</LoginLink>
<ActionButton on:click=move |_| {
if let Some(url) = login_url() {
navigate(&url, Default::default())
}
}>
"Sign in"
</ActionButton>
</div>
</div>
</div>
)
}