feat: scholarship info page takes a scholarship id param
This commit is contained in:
1 parent
0ace17d28c
commit
86086f3388
4 files changed
+26
-12
No files matched your search
+5
-8
@@ -1,10 +1,7 @@
|
|||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
|
use leptos_meta::{provide_meta_context, MetaTags, Stylesheet, Title};
|
||||||
use leptos_oidc::{Auth, AuthParameters, AuthSignal, Challenge};
|
use leptos_oidc::{Auth, AuthParameters, AuthSignal, Challenge};
|
||||||
use leptos_router::{
|
use leptos_router::{components::{Route, Router, Routes}, path};
|
||||||
components::{Route, Router, Routes},
|
|
||||||
StaticSegment,
|
|
||||||
};
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::pages::{AboutPage, ComparisonTestPage, HomePage, ScholarshipInfoPage};
|
use crate::pages::{AboutPage, ComparisonTestPage, HomePage, ScholarshipInfoPage};
|
||||||
@@ -65,10 +62,10 @@ pub fn App() -> impl IntoView {
|
|||||||
<main>
|
<main>
|
||||||
// TODO Create a 404 page
|
// TODO Create a 404 page
|
||||||
<Routes fallback=|| "Page not found.".into_view()>
|
<Routes fallback=|| "Page not found.".into_view()>
|
||||||
<Route path=StaticSegment("") view=HomePage />
|
<Route path=path!("") view=HomePage />
|
||||||
<Route path=StaticSegment("about") view=AboutPage />
|
<Route path=path!("about") view=AboutPage />
|
||||||
<Route path=StaticSegment("comparison") view=ComparisonTestPage />
|
<Route path=path!("comparison") view=ComparisonTestPage />
|
||||||
<Route path=StaticSegment("scholarship") view=ScholarshipInfoPage />
|
<Route path=path!("scholarship/:id") view=ScholarshipInfoPage />
|
||||||
</Routes>
|
</Routes>
|
||||||
</main>
|
</main>
|
||||||
</Router>
|
</Router>
|
||||||
|
|||||||
@@ -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
@@ -3,5 +3,6 @@ mod expandable_info;
|
|||||||
mod form_schema;
|
mod form_schema;
|
||||||
mod user;
|
mod user;
|
||||||
mod value_type;
|
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::*};
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
use leptos::logging::log;
|
use leptos::logging::log;
|
||||||
use leptos::prelude::*;
|
use leptos::prelude::*;
|
||||||
use leptos_oidc::{AuthLoaded, Authenticated};
|
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 crate::components::{ActionButton, ChipsList, Loading, OutlinedTextField, Panel, RadioList, Row};
|
||||||
use super::UnauthenticatedPage;
|
use super::UnauthenticatedPage;
|
||||||
use traits::{AsReactive, ReactiveCapture};
|
use traits::{AsReactive, ReactiveCapture};
|
||||||
@@ -19,10 +20,18 @@ use super::api::{get_comparison_info, get_scholarship_info, CreateScholarshipInf
|
|||||||
/// changed before a full release.
|
/// changed before a full release.
|
||||||
#[component]
|
#[component]
|
||||||
pub fn ScholarshipInfoPage() -> impl IntoView {
|
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(
|
let get_scholarship_action: Resource<ExpandableInfo> = Resource::new(
|
||||||
move || scholarship_id.clone(),
|
move || scholarship_id().clone(),
|
||||||
async |id| {
|
async |id| {
|
||||||
get_scholarship_info(id.clone()).await
|
get_scholarship_info(id.clone()).await
|
||||||
// Note that this really should notify us of an error and then redirect or ask
|
// Note that this really should notify us of an error and then redirect or ask
|
||||||
|
|||||||
Reference in new issue
Block a user