Merge branch 'main' into feature/form-schema
This commit is contained in:
42 files changed
+687
-51
No files matched your search
+58
-18
@@ -1,11 +1,11 @@
|
||||
use leptos::logging::log;
|
||||
use leptos::prelude::*;
|
||||
use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
|
||||
use leptos_meta::{MetaTags, Stylesheet, Title, provide_meta_context};
|
||||
use leptos_oidc::{Auth, AuthParameters, AuthSignal, Challenge};
|
||||
use leptos_router::{components::{Route, Router, Routes}, path};
|
||||
use crate::pages::{AboutPage, ComparisonTestPage, HomePage, LoanerPage, TestPage};
|
||||
use url::Url;
|
||||
|
||||
use crate::pages::{AboutPage, ComparisonTestPage, HomePage, ScholarshipInfoPage};
|
||||
|
||||
pub fn shell(options: LeptosOptions) -> impl IntoView {
|
||||
view! {
|
||||
<!DOCTYPE html>
|
||||
@@ -29,12 +29,53 @@ 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,
|
||||
@@ -56,19 +97,18 @@ pub fn App() -> impl IntoView {
|
||||
|
||||
// sets the document title
|
||||
<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=path!("") view=HomePage />
|
||||
<Route path=path!("about") view=AboutPage />
|
||||
<Route path=path!("comparison") view=ComparisonTestPage />
|
||||
<Route path=path!("scholarship/:id") view=ScholarshipInfoPage />
|
||||
</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!("loaners") view=LoanerPage />
|
||||
<Route path=path!("loaners/:form_name") view=LoanerPage />
|
||||
</Routes>
|
||||
</main>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user