chore: rustfmt run
This commit is contained in:
1 parent
1abedae760
commit
12dfe502f4
7 files changed
+117
-102
No files matched your search
@@ -4,12 +4,8 @@ use leptos::prelude::*;
|
||||
pub fn AdminScholarshipPage() -> impl IntoView {
|
||||
view! {
|
||||
<div class="flex flex-1 flex-col gap-4">
|
||||
<div class="font-bold text-3xl">
|
||||
"Scholarships View"
|
||||
</div>
|
||||
<div>
|
||||
"This is a placeholder for now. It will show a list of all scholarships."
|
||||
</div>
|
||||
<div class="font-bold text-3xl">"Scholarships View"</div>
|
||||
<div>"This is a placeholder for now. It will show a list of all scholarships."</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,7 @@ pub fn StudentAcademicsPage() -> impl IntoView {
|
||||
let controller = use_student_form("academics");
|
||||
|
||||
view! {
|
||||
<Show
|
||||
when=move || controller.data_resource.get().is_some()
|
||||
fallback=Loading
|
||||
>
|
||||
<Show when=move || controller.data_resource.get().is_some() fallback=Loading>
|
||||
<div class="flex flex-1" />
|
||||
<div class="flex flex-col flex-2 mt-6">
|
||||
<ValidatedForm title="Academic Information" on_submit=controller.submit_action>
|
||||
|
||||
@@ -8,10 +8,7 @@ pub fn StudentAthleticsPage() -> impl IntoView {
|
||||
let controller = use_student_form("athletics");
|
||||
|
||||
view! {
|
||||
<Show
|
||||
when=move || controller.data_resource.get().is_some()
|
||||
fallback=Loading
|
||||
>
|
||||
<Show when=move || controller.data_resource.get().is_some() fallback=Loading>
|
||||
<div class="flex flex-1" />
|
||||
<div class="flex flex-col flex-2 mt-6">
|
||||
<ValidatedForm title="Athletics Information" on_submit=controller.submit_action>
|
||||
|
||||
@@ -60,53 +60,69 @@ pub fn StudentEligibilityPage() -> impl IntoView {
|
||||
let Some(Ok(student_info)) = student_resource.get() else {
|
||||
return view! {}.into_any();
|
||||
};
|
||||
|
||||
let valid_list = scholarships_list.iter()
|
||||
let valid_list = scholarships_list
|
||||
.iter()
|
||||
.filter_map(|scholarship| {
|
||||
let scholarship_name = scholarship.data.get("name")
|
||||
.unwrap_or(&ValueType::String(None))
|
||||
.as_string().ok().flatten().unwrap_or_default();
|
||||
let scholarship_name = scholarship
|
||||
.data
|
||||
.get("name")
|
||||
.unwrap_or(&ValueType::String(None))
|
||||
.as_string()
|
||||
.ok()
|
||||
.flatten()
|
||||
.unwrap_or_default();
|
||||
debug_log!("Checking scholarship: {}", scholarship_name);
|
||||
|
||||
// Each scholarship will return Some(itself), or None. This is will be automatically
|
||||
// filtered based on the information. Invalid scholarships are None, along with those
|
||||
// that fail validation for any reason. Scholarships that are valid or did not choose
|
||||
// any requirements are Some(scholarship).
|
||||
let requirements_map = scholarship.data.get("requirements")
|
||||
let requirements_map = scholarship
|
||||
.data
|
||||
.get("requirements")
|
||||
.unwrap_or(&ValueType::Map(None))
|
||||
.as_map().ok().flatten()
|
||||
.as_map()
|
||||
.ok()
|
||||
.flatten()
|
||||
.unwrap_or_default()
|
||||
.values().cloned()
|
||||
.values()
|
||||
.cloned()
|
||||
.collect::<Vec<ValueType>>();
|
||||
|
||||
let resolved_requirements = requirements_map
|
||||
.iter()
|
||||
.map(|list_val| {
|
||||
// We want to cast to a list, and then map the list to a new
|
||||
// one that contains the correct ComparisonData.
|
||||
let list = list_val.as_list().ok().flatten().unwrap_or_default();
|
||||
list.iter().filter_map(|v| {
|
||||
let id_string = v.as_string().ok().flatten().unwrap_or_default();
|
||||
relations_list.iter()
|
||||
.find(|relation| relation.id == id_string)
|
||||
})
|
||||
.cloned()
|
||||
.collect::<Vec<ComparisonData>>()
|
||||
let list = list_val
|
||||
.as_list()
|
||||
.ok()
|
||||
.flatten()
|
||||
.unwrap_or_default();
|
||||
list.iter()
|
||||
.filter_map(|v| {
|
||||
let id_string = v
|
||||
.as_string()
|
||||
.ok()
|
||||
.flatten()
|
||||
.unwrap_or_default();
|
||||
relations_list
|
||||
.iter()
|
||||
.find(|relation| relation.id == id_string)
|
||||
})
|
||||
.cloned()
|
||||
.collect::<Vec<ComparisonData>>()
|
||||
})
|
||||
.collect::<Vec<Vec<ComparisonData>>>();
|
||||
|
||||
debug_log!("Resolved requirements: {:?}", resolved_requirements.iter().flatten().map(|rel| rel.display_text.clone()).collect::<Vec<String>>());
|
||||
|
||||
let valid = resolved_requirements.iter()
|
||||
debug_log!(
|
||||
"Resolved requirements: {:?}", resolved_requirements.iter().flatten().map(|rel| rel.display_text.clone()).collect::<Vec<String>>()
|
||||
);
|
||||
let valid = resolved_requirements
|
||||
.iter()
|
||||
.all(|list| {
|
||||
list.iter().fold(false, |prev, requirement| {
|
||||
let result = requirement.compare(&student_info)
|
||||
.unwrap_or(false);
|
||||
|
||||
if prev { prev } else { result }
|
||||
})
|
||||
list.iter()
|
||||
.fold(
|
||||
false,
|
||||
|prev, requirement| {
|
||||
let result = requirement
|
||||
.compare(&student_info)
|
||||
.unwrap_or(false);
|
||||
if prev { prev } else { result }
|
||||
},
|
||||
)
|
||||
});
|
||||
|
||||
if valid {
|
||||
debug_log!("Scholarship is valid.");
|
||||
Some(scholarship.clone())
|
||||
@@ -116,15 +132,19 @@ pub fn StudentEligibilityPage() -> impl IntoView {
|
||||
})
|
||||
.collect::<Vec<ExpandableInfo>>();
|
||||
|
||||
// Each scholarship will return Some(itself), or None. This is will be automatically
|
||||
// filtered based on the information. Invalid scholarships are None, along with those
|
||||
// that fail validation for any reason. Scholarships that are valid or did not choose
|
||||
// any requirements are Some(scholarship).
|
||||
|
||||
// We want to cast to a list, and then map the list to a new
|
||||
// one that contains the correct ComparisonData.
|
||||
|
||||
view! {
|
||||
<div>{format!("Valid scholarships: {}", valid_list.len())}</div>
|
||||
<For
|
||||
each=move || valid_list.clone()
|
||||
key=|scholarship| {
|
||||
scholarship
|
||||
.subject
|
||||
.clone()
|
||||
}
|
||||
key=|scholarship| { scholarship.subject.clone() }
|
||||
children=move |scholarship| {
|
||||
let scholarship = StoredValue::new(scholarship);
|
||||
let scholarship_name = Memo::new(move |_| {
|
||||
@@ -163,7 +183,8 @@ pub fn StudentEligibilityPage() -> impl IntoView {
|
||||
}
|
||||
}
|
||||
/>
|
||||
}.into_any()
|
||||
}
|
||||
.into_any()
|
||||
}}
|
||||
</Suspense>
|
||||
</div>
|
||||
|
||||
@@ -15,7 +15,7 @@ pub fn StudentShell() -> impl IntoView {
|
||||
title="R15 Student Scholarship Application"
|
||||
logo="/PHS_Stacked_Acronym.png"
|
||||
/>
|
||||
|
||||
|
||||
<div class="flex flex-1 min-h-0">
|
||||
<AuthLoaded fallback=Loading>
|
||||
<Authenticated unauthenticated=UnauthenticatedPage>
|
||||
@@ -38,7 +38,7 @@ pub fn StudentShell() -> impl IntoView {
|
||||
],
|
||||
),
|
||||
),
|
||||
TabInfo::new("Eligible Scholarships", "eligibility", None)
|
||||
TabInfo::new("Eligible Scholarships", "eligibility", None),
|
||||
]
|
||||
/>
|
||||
</Authenticated>
|
||||
|
||||
Reference in new issue
Block a user