Merge branch 'main' into feat/provider_portal

# Conflicts:
#	src/app.rs
This commit is contained in:
meraghon committed 2025-12-22 07:35:06 -05:00
commit c6f0a2e5e5
32 files changed
+2544 -138

No files matched your search

+68 -26
View File
@@ -1,27 +1,26 @@
use crate::pages::{AboutPage, ComparisonTestPage, HomePage, LoanerPage, ProviderPortal, TestPage};
use leptos::leptos_dom::log;
use leptos::prelude::*;
use leptos_meta::{MetaTags, Stylesheet, Title, provide_meta_context};
use leptos_oidc::{Auth, AuthParameters, AuthSignal, Challenge, LoginLink};
use leptos_oidc::{Auth, AuthParameters, AuthSignal, Challenge};
use leptos_router::{
StaticSegment,
components::{Route, Router, Routes},
path,
};
use url::Url;
use crate::pages::{AboutPage, HomePage, ProviderPortal, TestPage, UnauthenticatedPage};
pub fn shell(options: LeptosOptions) -> impl IntoView {
view! {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<AutoReload options=options.clone() />
<HydrationScripts options/>
<MetaTags/>
<HydrationScripts options />
<MetaTags />
</head>
<body>
<App/>
<App />
</body>
</html>
}
@@ -32,12 +31,55 @@ pub fn App() -> impl IntoView {
// Provides context that manages stylesheets, titles, meta tags, etc.
provide_meta_context();
view! {
// injects a stylesheet into the document <head>
// id=leptos means cargo-leptos will hot-reload this stylesheet
<Stylesheet id="leptos" href="/pkg/scholarships-rs-wasm.css"/>
// sets the document title
<Title text="R15 Scholarship App DEV"/>
// content for this welcome page
<Router>
<AppWithRoutes />
</Router>
}
}
fn use_origin() -> String {
#[cfg(target_arch = "wasm32")]
{
use leptos::web_sys;
// Just get the current URL origin.
web_sys::window()
.unwrap()
.location()
.origin()
.unwrap_or("http://localhost:3000/".to_string())
}
#[cfg(not(target_arch = "wasm32"))]
{
// Read the expected origin out of an environment variable.
std::env::var("LP_SITE_ORIGIN").unwrap_or("http://localhost:3000/".to_string())
}
}
#[component]
pub fn AppWithRoutes() -> impl IntoView {
provide_meta_context();
let current_origin = use_origin();
log!("Current origin: {}", current_origin);
// Authentication setup
let parameters = AuthParameters {
issuer: "https://cognito-idp.us-east-1.amazonaws.com/us-east-1_Lfjuy5zaM".into(),
client_id: "10jr2h3vtpu9n7gj46pvg5qo2q".into(),
redirect_uri: Url::parse("http://localhost:3000").unwrap().to_string(),
post_logout_redirect_uri: Url::parse("http://localhost:3000").unwrap().to_string(),
redirect_uri: format!("{}/", use_origin()),
// redirect_uri: Url::parse(format!("{}", current_origin).as_str()).unwrap().to_string(),
// redirect_uri: Url::parse("http://localhost:3000").unwrap().to_string(),
post_logout_redirect_uri: current_origin,
scope: Some("openid%20profile%20email".into()),
audience: None,
challenge: Challenge::None,
@@ -52,26 +94,26 @@ pub fn App() -> impl IntoView {
view! {
// injects a stylesheet into the document <head>
// id=leptos means cargo-leptos will hot-reload this stylesheet
<Stylesheet id="leptos" href="/pkg/scholarships-rs-wasm.css"/>
<Stylesheet id="leptos" href="/pkg/scholarships-rs-wasm.css" />
// <AuthLoading><p>"Authentication is loading"</p></AuthLoading>
// <AuthErrorContext><AuthErrorView/></AuthErrorContext>
// sets the document title
<Title text="R15 Scholarship App DEV"/>
<Title text="R15 Scholarship App DEV" />
// content for this welcome page
<Router>
<main>
// TODO Create a 404 page
<Routes fallback=|| "Page not found.".into_view()>
<Route path=StaticSegment("") view=HomePage/>
<Route path=StaticSegment("about") view=AboutPage/>
<Route path=StaticSegment("test_page") view=TestPage/>
<Route path=StaticSegment("providers") view=ProviderPortal/>
</Routes>
</main>
</Router>
<main>
// TODO Create a 404 page
<Routes fallback=|| "Page not found.".into_view()>
<Route path=path!("") view=HomePage/>
<Route path=path!("about") view=AboutPage/>
<Route path=path!("test_page") view=TestPage/>
<Route path=path!("comparison") view=ComparisonTestPage />
<Route path=path!("providers") view=ProviderPortal />
<Route path=path!("loaners") view=LoanerPage />
<Route path=path!("loaners/:form_name") view=LoanerPage />
</Routes>
</main>
}
}