Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cf5e6342b | ||
|
|
467f8c9020 | ||
|
|
909f33b044 | ||
|
|
44450f407c | ||
|
|
70a86f4545 | ||
|
|
e6409cc423 | ||
|
|
4e3161a05f | ||
|
|
51dfa013df | ||
|
|
1d41b6022e | ||
|
|
f9d5b25436 | ||
|
|
891e324186 | ||
|
|
b502c2f96d | ||
|
|
681da8c326 |
No files matched your search
+18
-27
@@ -1,11 +1,11 @@
|
||||
use crate::components::ToastList;
|
||||
use crate::components::login::ProviderLoginContext;
|
||||
use crate::pages::student;
|
||||
use crate::pages::{
|
||||
AdminHomePage, AdminProviderPage, AdminScholarshipPage, AdminShell, AdminUtilsPage,
|
||||
ApplicantsPageFallback, AuthCallbackPage, LoanerBorrowForm, LoanerFallback, LoanerReturnForm,
|
||||
LoanerShell, ProviderContactPage, ProviderPortal, ScholarshipInfoPage,
|
||||
LoanerShell, ProviderContactPage, ProviderPortal,
|
||||
};
|
||||
use crate::pages::{FormClosedPage, student};
|
||||
use leptos::prelude::*;
|
||||
use leptos_meta::{MetaTags, Stylesheet, Title, provide_meta_context};
|
||||
use leptos_oidc::AuthSignal;
|
||||
@@ -89,11 +89,11 @@ fn ProviderRoutes() -> impl MatchNestedRoutes + Clone {
|
||||
<Route path=path!("/applicants") view=ApplicantsPageFallback />
|
||||
<Route path=path!("/callback") view=AuthCallbackPage />
|
||||
<Route path=path!("/profile") view=ProviderContactPage />
|
||||
// <Route path=path!("/scholarships") view=FormClosedPage />
|
||||
<ParentRoute path=path!("/scholarships") view=ScholarshipInfoPage>
|
||||
<Route path=path!(":id") view=ScholarshipInfoPage />
|
||||
<Route path=path!("") view=ScholarshipInfoPage />
|
||||
</ParentRoute>
|
||||
<Route path=path!("/scholarships") view=FormClosedPage />
|
||||
// <ParentRoute path=path!("/scholarships") view=ScholarshipInfoPage>
|
||||
// <Route path=path!(":id") view=ScholarshipInfoPage />
|
||||
// <Route path=path!("") view=ScholarshipInfoPage />
|
||||
// </ParentRoute>
|
||||
</ParentRoute>
|
||||
}
|
||||
.into_inner()
|
||||
@@ -134,26 +134,17 @@ fn StudentRoutes() -> impl MatchNestedRoutes + Clone {
|
||||
<ParentRoute path=path!("students") view=student::StudentShell>
|
||||
<Route path=path!("callback") view=AuthCallbackPage />
|
||||
<Route path=path!("home") view=student::StudentHomePage />
|
||||
<Route path=path!("demographics") view=student::StudentDemographicsPage />
|
||||
<Route path=path!("eligibility") view=student::StudentEligibilityPage />
|
||||
<Route path=path!("additional") view=student::AdditionalPage />
|
||||
<Route path=path!("additional/academics") view=student::StudentAcademicsPage />
|
||||
<Route path=path!("additional/athletics") view=student::StudentAthleticsPage />
|
||||
<Route
|
||||
path=path!("additional/extracurriculars")
|
||||
view=student::StudentExtracurricularsPage
|
||||
/>
|
||||
<Route
|
||||
path=path!("additional/work-experience")
|
||||
view=student::StudentWorkExperiencePage
|
||||
/>
|
||||
<Route path=path!("additional/university") view=student::StudentUniversityPage />
|
||||
<Route path=path!("additional/family-info") view=student::StudentFamilyPage />
|
||||
<Route path=path!("additional/financials") view=student::StudentFinancialPage />
|
||||
<Route
|
||||
path=path!("additional/specifics")
|
||||
view=student::StudentSpecificRequirementsPage
|
||||
/>
|
||||
<Route path=path!("demographics") view=student::ClosedForm />
|
||||
<Route path=path!("eligibility") view=student::ClosedForm />
|
||||
<Route path=path!("additional") view=student::ClosedForm />
|
||||
<Route path=path!("additional/academics") view=student::ClosedForm />
|
||||
<Route path=path!("additional/athletics") view=student::ClosedForm />
|
||||
<Route path=path!("additional/extracurriculars") view=student::ClosedForm />
|
||||
<Route path=path!("additional/work-experience") view=student::ClosedForm />
|
||||
<Route path=path!("additional/university") view=student::ClosedForm />
|
||||
<Route path=path!("additional/family-info") view=student::ClosedForm />
|
||||
<Route path=path!("additional/financials") view=student::ClosedForm />
|
||||
<Route path=path!("additional/specifics") view=student::ClosedForm />
|
||||
</ParentRoute>
|
||||
}
|
||||
.into_inner()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::pages::api::files::{DeleteFile, upload_file};
|
||||
use leptos::html::{Input, Label};
|
||||
use leptos::logging::debug_log;
|
||||
use leptos::logging::{debug_error, debug_log};
|
||||
use leptos::prelude::*;
|
||||
use leptos::web_sys::{File, FormData};
|
||||
use leptos_icons::Icon;
|
||||
@@ -28,6 +28,7 @@ pub fn FileDrop(
|
||||
|
||||
let file_name_list = RwSignal::new(Vec::new());
|
||||
let hovering = RwSignal::new(false);
|
||||
let error_msg = RwSignal::new(String::new());
|
||||
let name = StoredValue::new(name);
|
||||
let form_id = StoredValue::new(form_id);
|
||||
let auth = expect_context::<AuthSignal>();
|
||||
@@ -172,10 +173,18 @@ pub fn FileDrop(
|
||||
existing_files
|
||||
.get()
|
||||
.map(|result| {
|
||||
if let Ok(files) = result {
|
||||
file_name_list.set(files);
|
||||
match result {
|
||||
Ok(files) => {
|
||||
error_msg.set("".to_string());
|
||||
file_name_list.set(files);
|
||||
}
|
||||
Err(err) => {
|
||||
let msg = err.to_string();
|
||||
debug_error!("Error while getting files: {}", msg);
|
||||
error_msg.set(msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}}
|
||||
<label
|
||||
node_ref=zone_ref
|
||||
@@ -194,6 +203,9 @@ pub fn FileDrop(
|
||||
<div class="text-sm text-gray-400">"Or click to select a file"</div>
|
||||
<input node_ref=input_ref type="file" class="hidden" on:change=on_input_change />
|
||||
</label>
|
||||
<Show when=move || !error_msg.get().is_empty()>
|
||||
<div class="flex-1">{error_msg}</div>
|
||||
</Show>
|
||||
<For
|
||||
each=move || file_name_list.get()
|
||||
key=|file| file.clone()
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
use leptos::prelude::*;
|
||||
|
||||
#[component]
|
||||
pub fn ClosedForm() -> impl IntoView {
|
||||
view! {
|
||||
<div class="flex flex-col items-center mx-auto mt-10">
|
||||
<h1 class="text-2xl font-bold">"Form Closed"</h1>
|
||||
<p class="text-lg">
|
||||
"This form is now closed. If you believe this is an error, please contact the guidance office."
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ 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::logging::{debug_error, debug_log};
|
||||
use leptos::prelude::*;
|
||||
use leptos_oidc::AuthSignal;
|
||||
|
||||
@@ -23,6 +23,11 @@ pub fn StudentEligibilityPage() -> impl IntoView {
|
||||
let auth = expect_context::<AuthSignal>();
|
||||
let user_claims = get_user_claims();
|
||||
let user_id = Memo::new(move |_| user_claims.get().map(|info| info.claims.subject.clone()));
|
||||
let access_token = Memo::new(move |_| auth.get().authenticated().map(|a| a.access_token()));
|
||||
|
||||
Effect::new(move || {
|
||||
debug_log!("User ID was updated: {}", user_id.get().unwrap_or_default());
|
||||
});
|
||||
|
||||
let form_id = StoredValue::new("scholarship_essays".to_string());
|
||||
|
||||
@@ -63,8 +68,7 @@ pub fn StudentEligibilityPage() -> impl IntoView {
|
||||
.get("name")
|
||||
.unwrap_or(&ValueType::String(None))
|
||||
.as_string()
|
||||
.ok()
|
||||
.flatten()
|
||||
.ok()?
|
||||
.unwrap_or_default();
|
||||
debug_log!("Checking scholarship: {}", scholarship_name);
|
||||
let requirements_map = scholarship
|
||||
@@ -72,8 +76,7 @@ pub fn StudentEligibilityPage() -> impl IntoView {
|
||||
.get("requirements")
|
||||
.unwrap_or(&ValueType::Map(None))
|
||||
.as_map()
|
||||
.ok()
|
||||
.flatten()
|
||||
.ok()?
|
||||
.unwrap_or_default()
|
||||
.values()
|
||||
.cloned()
|
||||
@@ -108,38 +111,46 @@ pub fn StudentEligibilityPage() -> impl IntoView {
|
||||
&& resolved_requirements
|
||||
.iter()
|
||||
.all(|list| {
|
||||
list.iter()
|
||||
.fold(
|
||||
false,
|
||||
|prev, requirement| {
|
||||
let result = requirement
|
||||
.compare(&student_info)
|
||||
.unwrap_or_else(|err| {
|
||||
debug_log!("Requirement failed: {err}");
|
||||
debug_log!("Checking list: {:?}", list);
|
||||
if list.is_empty() {
|
||||
true
|
||||
} else {
|
||||
list.iter()
|
||||
.any(|requirement| {
|
||||
let result = requirement.compare(&student_info);
|
||||
match result.as_ref() {
|
||||
Ok(status) => {
|
||||
debug_log!(
|
||||
"Requirement with id {} is Ok({})", requirement.id, status
|
||||
);
|
||||
status.clone()
|
||||
}
|
||||
Err(e) => {
|
||||
debug_error!(
|
||||
"Requirement with id {} failed: {}", requirement.id, e
|
||||
);
|
||||
false
|
||||
});
|
||||
if prev { prev } else { result }
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
if valid {
|
||||
debug_log!("Scholarship is valid.");
|
||||
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(),
|
||||
access_token.get(),
|
||||
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
|
||||
let Some(access_token) = access_token else {
|
||||
return Err(
|
||||
ServerFnError::new("Couldn't find access token"),
|
||||
);
|
||||
};
|
||||
list_files(access_token, form_id, scholarship_id).await
|
||||
},
|
||||
);
|
||||
Some((scholarship.clone(), resource))
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use std::collections::HashMap;
|
||||
use leptos::prelude::*;
|
||||
use uuid::Uuid;
|
||||
use crate::common::ValueType;
|
||||
use crate::components::{Toast, ToastContext};
|
||||
use crate::pages::api::students::{get_student_data, PutStudentData};
|
||||
use crate::pages::api::students::{PutStudentData, get_student_data};
|
||||
use crate::utils::get_user_claims;
|
||||
use leptos::prelude::*;
|
||||
use std::collections::HashMap;
|
||||
use uuid::Uuid;
|
||||
|
||||
pub struct StudentFormInfo {
|
||||
pub data_map: RwSignal<HashMap<String, ValueType>>,
|
||||
@@ -20,22 +20,21 @@ pub fn use_student_form(
|
||||
enable_toasts: bool,
|
||||
) -> StudentFormInfo {
|
||||
let form_type = form_type.into();
|
||||
|
||||
|
||||
let user_claims = get_user_claims();
|
||||
let user_id = Memo::new(move |_| {
|
||||
user_claims.get()
|
||||
.map(|info| info.claims.subject.clone())
|
||||
});
|
||||
let user_id = Memo::new(move |_| user_claims.get().map(|info| info.claims.subject.clone()));
|
||||
|
||||
let data_map = RwSignal::new(HashMap::new());
|
||||
|
||||
let refresh_trigger = Trigger::new();
|
||||
let data_resource = Resource::new(
|
||||
move || (user_id.get().unwrap_or_default(), form_type.get(), refresh_trigger.track()),
|
||||
async move |(id, form_type, _)| get_student_data(
|
||||
id,
|
||||
form_type,
|
||||
).await
|
||||
move || (user_id.get(), form_type.get(), refresh_trigger.track()),
|
||||
async move |(id, form_type, _)| {
|
||||
let Some(id) = id else {
|
||||
return Ok(HashMap::new());
|
||||
};
|
||||
get_student_data(id, form_type).await
|
||||
},
|
||||
);
|
||||
|
||||
Effect::new(move || {
|
||||
@@ -50,13 +49,15 @@ pub fn use_student_form(
|
||||
|
||||
let submit_action = ServerAction::<PutStudentData>::new();
|
||||
let on_submit = move || {
|
||||
submit_action.dispatch(PutStudentData {
|
||||
subject: user_id.get().unwrap_or_default(),
|
||||
data_type: form_type.get(),
|
||||
data_map: data_map.get()
|
||||
});
|
||||
if let Some(id) = user_id.get() {
|
||||
submit_action.dispatch(PutStudentData {
|
||||
subject: id,
|
||||
data_type: form_type.get(),
|
||||
data_map: data_map.get(),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if enable_toasts {
|
||||
let mut toasts = expect_context::<ToastContext>();
|
||||
Effect::watch(
|
||||
@@ -74,13 +75,13 @@ pub fn use_student_form(
|
||||
Err(e) => Toast::new()
|
||||
.id(Uuid::new_v4())
|
||||
.header("Submission Failed")
|
||||
.msg(e.to_string())
|
||||
.msg(e.to_string()),
|
||||
};
|
||||
|
||||
toasts.toast(toast);
|
||||
untrack(move || submit_action.clear());
|
||||
},
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -90,6 +91,6 @@ pub fn use_student_form(
|
||||
data_resource,
|
||||
user_id,
|
||||
submit_action: on_submit.into(),
|
||||
submit_pending: submit_action.pending()
|
||||
submit_pending: submit_action.pending(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
mod academics_page;
|
||||
mod additional_page;
|
||||
mod athletics_page;
|
||||
mod closed_form;
|
||||
mod demographics_page;
|
||||
mod eligibility_page;
|
||||
mod extracurriculars_page;
|
||||
@@ -9,14 +10,15 @@ mod financial_page;
|
||||
mod form_setup;
|
||||
mod home_page;
|
||||
mod shell;
|
||||
mod specific_requirements_page;
|
||||
mod test_display;
|
||||
mod university_page;
|
||||
mod work_experience_page;
|
||||
mod specific_requirements_page;
|
||||
|
||||
pub use academics_page::*;
|
||||
pub use additional_page::*;
|
||||
pub use athletics_page::*;
|
||||
pub use closed_form::*;
|
||||
pub use demographics_page::*;
|
||||
pub use eligibility_page::*;
|
||||
pub use extracurriculars_page::*;
|
||||
@@ -24,7 +26,7 @@ pub use family_info_page::*;
|
||||
pub use financial_page::*;
|
||||
pub use home_page::*;
|
||||
pub use shell::*;
|
||||
pub use specific_requirements_page::*;
|
||||
pub use test_display::*;
|
||||
pub use university_page::*;
|
||||
pub use work_experience_page::*;
|
||||
pub use specific_requirements_page::*;
|
||||
Reference in new issue
Block a user