feat: scholarship info page takes a scholarship id param

This commit is contained in:
alphafetus committed 2025-11-23 16:55:26 -05:00
1 parent 0ace17d28c
commit 86086f3388
4 files changed
+26 -12

No files matched your search

+5 -8
View File
@@ -1,10 +1,7 @@
use leptos::prelude::*;
use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
use leptos_oidc::{Auth, AuthParameters, AuthSignal, Challenge};
use leptos_router::{
components::{Route, Router, Routes},
StaticSegment,
};
use leptos_router::{components::{Route, Router, Routes}, path};
use url::Url;
use crate::pages::{AboutPage, ComparisonTestPage, HomePage, ScholarshipInfoPage};
@@ -65,10 +62,10 @@ pub fn App() -> impl IntoView {
<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("comparison") view=ComparisonTestPage />
<Route path=StaticSegment("scholarship") view=ScholarshipInfoPage />
<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>
+7
View File
@@ -0,0 +1,7 @@
use leptos::Params;
use leptos_router::params::Params;
#[derive(Params, PartialEq, Debug)]
pub struct ScholarshipFormParams {
pub id: Option<String>,
}
+2 -1
View File
@@ -3,5 +3,6 @@ mod expandable_info;
mod form_schema;
mod user;
mod value_type;
mod form_params;
pub use self::{comparison::*, expandable_info::*, form_schema::*, user::*, value_type::*};
pub use self::{comparison::*, expandable_info::*, form_schema::*, user::*, value_type::*, form_params::*};
+12 -3
View File
@@ -1,7 +1,8 @@
use leptos::logging::log;
use leptos::prelude::*;
use leptos_oidc::{AuthLoaded, Authenticated};
use crate::common::ExpandableInfo;
use leptos_router::hooks::use_params;
use crate::common::{ExpandableInfo, ScholarshipFormParams};
use crate::components::{ActionButton, ChipsList, Loading, OutlinedTextField, Panel, RadioList, Row};
use super::UnauthenticatedPage;
use traits::{AsReactive, ReactiveCapture};
@@ -19,10 +20,18 @@ use super::api::{get_comparison_info, get_scholarship_info, CreateScholarshipInf
/// changed before a full release.
#[component]
pub fn ScholarshipInfoPage() -> impl IntoView {
let scholarship_id = String::from("test-scholarship-id2");
// let scholarship_id = String::from("test-scholarship-id2");
let url_params = use_params::<ScholarshipFormParams>();
let scholarship_id = move || {
url_params.read()
.as_ref()
.ok()
.and_then(|params| params.id.clone())
.unwrap_or_default()
};
let get_scholarship_action: Resource<ExpandableInfo> = Resource::new(
move || scholarship_id.clone(),
move || scholarship_id().clone(),
async |id| {
get_scholarship_info(id.clone()).await
// Note that this really should notify us of an error and then redirect or ask