diff --git a/src/pages/student/eligibility_page.rs b/src/pages/student/eligibility_page.rs index b880f29..c359d90 100644 --- a/src/pages/student/eligibility_page.rs +++ b/src/pages/student/eligibility_page.rs @@ -1,10 +1,12 @@ -use crate::common::{ComparisonData, ExpandableInfo, SchemaNode, SchemaType, ValueType}; -use crate::components::ValueDisplay; +use crate::common::{ComparisonData, ExpandableInfo, ValueType}; +use crate::components::{FileDrop, Header}; +use crate::pages::api::files::list_files; use crate::pages::api::students::get_all_student_data; use crate::pages::api::{get_all_scholarship_info, get_comparison_info}; use crate::utils::get_user_claims; use leptos::logging::debug_log; use leptos::prelude::*; +use leptos_oidc::AuthSignal; #[component] pub fn StudentEligibilityPage() -> impl IntoView { @@ -18,9 +20,12 @@ pub fn StudentEligibilityPage() -> impl IntoView { // My only reservation with showing the scholarships that aren't valid is that people will want // to know why. That's hard information to keep track of right now. + let auth = expect_context::(); let user_claims = get_user_claims(); let user_id = Memo::new(move |_| user_claims.get().map(|info| info.claims.subject.clone())); + let form_id = StoredValue::new("scholarship_essays".to_string()); + let refresh_trigger = Trigger::new(); let scholarships_resource = Resource::new( @@ -38,7 +43,7 @@ pub fn StudentEligibilityPage() -> impl IntoView { view! {
-
+
"Checking eligibility..."
} }> @@ -117,39 +122,91 @@ pub fn StudentEligibilityPage() -> impl IntoView { }); if valid { debug_log!("Scholarship is valid."); - Some(scholarship.clone()) + let scholarship_id = StoredValue::new(scholarship.subject.clone()); + let resource = Resource::new( + move || ( + auth + .try_with(|a| a.authenticated().map(|a| a.access_token())) + .flatten(), + form_id.get_value(), + scholarship_id.get_value(), + ), + async move |(access_token, form_id, scholarship_id)| { + list_files( + access_token.unwrap_or_default(), + form_id, + scholarship_id, + ) + .await + }, + ); + Some((scholarship.clone(), resource)) } else { None } }) - .collect::>(); + .collect::< + Vec<(ExpandableInfo, Resource, ServerFnError>>)>, + >(); + view! { -
{format!("Valid scholarships: {}", valid_list.len())}
- +
+ + view! { +
+
+ {scholarship_name.get_value()} +
+ +
+ "This scholarship does not require an essay."
+ } + } + > +
{scholarship_essay.get_value()}
+ + +
+
+ } } - } - /> + /> +
} .into_any() }}