style: automatic rustfmt run

This commit is contained in:
alphafetus committed 2026-01-15 07:30:32 -05:00
1 parent 9eacc9a618
commit 4e8f4a3c5e
12 files changed
+309 -300

No files matched your search

+74 -83
View File
@@ -57,93 +57,84 @@ pub fn ComparisonTestPage() -> impl IntoView {
let student_info = student_resource.get();
let comparison_info = comparison_resource.get();
let scholarship_info = scholarship_resource.get();
match (student_info, comparison_info, scholarship_info) {
(Some(student), Some(comparisons), Some(scholarships)) => Either::Right(view! {
<Panel>
<Row>
<p>{result_msg}</p>
</Row>
<Row>
<ActionButton on:click=move |_| {
// Iterate over all scholarships, get the comparison IDs,
// get ComparisonData from the IDs, then perform the
// comparisons and return a boolean. Alternatively, return
// a list of comparisons that complete and a list that don't.
let comp_member = "requirements".to_string();
let comparison_results = scholarships.iter().map(|scholarship| {
let list = match scholarship.data.get(&comp_member) {
Some(ValueType::List(Some(list))) => list,
_ => {
log!("Cannot find requirements, assuming none.");
return Ok(Some(scholarship)) // students will always qualify when there are no requirements
}
};
(Some(student), Some(comparisons), Some(scholarships)) => {
Either::Right(
let mut final_result = Ok(true);
// The list should exist, and it should contain a series of strings.
for val in list {
let comp_opt = match val {
ValueType::String(Some(comp_id)) => {
// Find the comparison
comparisons.iter().find(|comp| comp.id == *comp_id)
}
_ => None
};
let comparison_outcome = match comp_opt {
Some(comp) => {
// Perform the comparison
comp.compare(&student)
}
_ => Err("".to_string())
};
match comparison_outcome {
Ok(true) => {},
Ok(false) => final_result = Ok(false),
Err(e) => {
final_result = Err(e);
break;
view! {
<Panel>
<Row>
<p>{result_msg}</p>
</Row>
<Row>
<ActionButton on:click=move |_| {
let comp_member = "requirements".to_string();
let comparison_results = scholarships
.iter()
.map(|scholarship| {
let list = match scholarship.data.get(&comp_member) {
Some(ValueType::List(Some(list))) => list,
_ => {
log!("Cannot find requirements, assuming none.");
return Ok(Some(scholarship));
}
};
let mut final_result = Ok(true);
for val in list {
let comp_opt = match val {
ValueType::String(Some(comp_id)) => {
comparisons.iter().find(|comp| comp.id == *comp_id)
}
_ => None,
};
let comparison_outcome = match comp_opt {
Some(comp) => comp.compare(&student),
_ => Err("".to_string()),
};
match comparison_outcome {
Ok(true) => {}
Ok(false) => final_result = Ok(false),
Err(e) => {
final_result = Err(e);
break;
}
}
}
match final_result {
Ok(true) => Ok(Some(scholarship)),
Ok(false) => Ok(None),
Err(e) => Err(e),
}
})
.collect::<Vec<Result<Option<&ExpandableInfo>, String>>>();
let mut strings = Vec::new();
strings.push("Scholarship results: \n".to_string());
for result in comparison_results {
match result {
Ok(Some(scholarship_info)) => {
let name_member = "name".to_string();
let scl_name = scholarship_info
.data
.get(&name_member)
.unwrap()
.as_string()
.unwrap()
.unwrap();
strings.push(scl_name);
}
Ok(None) => {}
Err(msg) => strings.push(msg),
}
}
}
match final_result {
Ok(true) => Ok(Some(scholarship)),
Ok(false) => Ok(None),
Err(e) => Err(e)
}
}).collect::<Vec<Result<Option<&ExpandableInfo>, String>>>();
// Build a display string
let mut strings = Vec::new();
strings.push("Scholarship results: \n".to_string());
for result in comparison_results {
match result {
Ok(Some(scholarship_info)) => {
// Get the scholarship name.
let name_member = "name".to_string();
let scl_name = scholarship_info.data.get(&name_member).unwrap()
.as_string().unwrap().unwrap();
strings.push(scl_name);
},
Ok(None) => {},
Err(msg) => strings.push(msg)
}
}
let display_text = strings.join("\n").to_string();
result_msg.set(display_text);
}>"Test Comparison"</ActionButton>
</Row>
</Panel>
}),
_ => Either::Left(view! {
<p>"Failed API requests."</p>
})
let display_text = strings.join("\n").to_string();
result_msg.set(display_text);
}>"Test Comparison"</ActionButton>
</Row>
</Panel>
},
)
}
_ => Either::Left(view! { <p>"Failed API requests."</p> }),
}
}}
</Suspense>
+8 -5
View File
@@ -289,7 +289,7 @@ pub fn HomePage() -> impl IntoView {
data_member="contact_email"
data_map=form_data
input_type=TextFieldType::Email(
vec!["fakeemail.org".to_string(), "gmail.com".to_string()]
vec!["fakeemail.org".to_string(), "gmail.com".to_string()],
)
required=true
/>
@@ -369,8 +369,12 @@ pub fn HomePage() -> impl IntoView {
data_map=form_data
data_member="community_involvement"
schema=vec![
input!(Text, "service_name", "Activity Name:", true, "Some service activity..."),
input!(Number, "service_hours", "Total Service Hours", true, "20")
input!(
Text, "service_name", "Activity Name:", true, "Some service activity..."
),
input!(
Number, "service_hours", "Total Service Hours", true, "20"
),
]
/>
</Row>
@@ -380,8 +384,7 @@ pub fn HomePage() -> impl IntoView {
</Row>
}
})
}}
<Row>
}} <Row>
<ActionButton on:click=pdf_button_click>"Get PDF"</ActionButton>
</Row>
</Suspense>
+68 -63
View File
@@ -213,11 +213,7 @@ pub fn LoanerShell() -> impl IntoView {
// We'll create the page here - the sidebar contains all the buttons, while the form
// container either shows forms or shows placeholder text.
view! {
<Banner
title="Chromebook Loaners"
logo="/PHS_Stacked_Acronym.png"
path="/loaners"
/>
<Banner title="Chromebook Loaners" logo="/PHS_Stacked_Acronym.png" path="/loaners" />
<div class="flex m-5">
<div class="flex flex-1 flex-row gap-3">
<div id="sidebar" class="flex flex-1 flex-col gap-2">
@@ -247,16 +243,9 @@ pub fn LoanerShell() -> impl IntoView {
#[component]
pub fn LoanerFallback() -> impl IntoView {
view! {
<div
class="flex flex-col items-center justify-center"
use:animate=pop_in_out()
>
<div class="text-3xl font-bold mb-2">
"Chromebook Loaner Form"
</div>
<div class="text-lg">
"Select an option from the left to begin."
</div>
<div class="flex flex-col items-center justify-center" use:animate=pop_in_out()>
<div class="text-3xl font-bold mb-2">"Chromebook Loaner Form"</div>
<div class="text-lg">"Select an option from the left to begin."</div>
</div>
}
}
@@ -431,69 +420,85 @@ pub fn LoanerReturnForm() -> impl IntoView {
<dialog
use:animate=pop_in_out()
class="p-3 m-auto rounded-md shadow-lg/33 backdrop:backdrop-blur-xs backdrop:transition-backdrop-filter"
node_ref=dialog_ref>
node_ref=dialog_ref
>
<h2 class="text-2xl font-bold">"Confirmation"</h2>
<h4 class="text-xl mb-3">
{move || chosen_student.with(|opt_student| {
if let Some(student) = opt_student.as_ref() {
format!("Are you sure want to check in {} {}?", student.first_name, student.last_name)
} else {
"There is no student selected.".to_string()
}
})}
{move || {
chosen_student
.with(|opt_student| {
if let Some(student) = opt_student.as_ref() {
format!(
"Are you sure want to check in {} {}?",
student.first_name,
student.last_name,
)
} else {
"There is no student selected.".to_string()
}
})
}}
</h4>
<ActionButton on:click=close_dialog disabled=dialog_disabled>"Close"</ActionButton>
<ActionButton on:click=dialog_check_in disabled=dialog_disabled>"Check In"</ActionButton>
<ActionButton on:click=close_dialog disabled=dialog_disabled>
"Close"
</ActionButton>
<ActionButton on:click=dialog_check_in disabled=dialog_disabled>
"Check In"
</ActionButton>
</dialog>
<div
class="flex flex-col gap-2 m-2"
use:animate=pop_in_out()
>
<div class="flex flex-col gap-2 m-2" use:animate=pop_in_out()>
<div class="flex flex-col justify-center gap-2 mb-3 py-3 px-2">
<h2 class="text-2xl font-bold">"Student List"</h2>
<p class="text-lg">"Please select your name from the list."</p>
</div>
<Suspense fallback=move || "Loading...".into_view()>
<Suspense fallback=move || {
"Loading...".into_view()
}>
{move || {
match return_list_resource.get() {
Some(loaner_list) => {
let list_view = loaner_list.iter().map(|student| {
let on_click = {
let student_click = student.clone();
move |_| {
log!("Running on_click using student {:?}", student_click);
if let Some(dialog) = dialog_ref.get() {
chosen_student.set(Some(student_click.clone()));
dialog.show_modal().expect("Couldn't show modal dialog.");
let list_view = loaner_list
.iter()
.map(|student| {
let on_click = {
let student_click = student.clone();
move |_| {
log!("Running on_click using student {:?}", student_click);
if let Some(dialog) = dialog_ref.get() {
chosen_student.set(Some(student_click.clone()));
dialog.show_modal().expect("Couldn't show modal dialog.");
}
}
};
let naive_time = chrono::NaiveDateTime::parse_from_str(
&student.date,
"%H:%M, %m/%d/%Y",
)
.unwrap();
let time_zone = FixedOffset::west_opt(5 * 3600).unwrap();
let student_date = time_zone
.from_utc_datetime(&naive_time)
.format("%l:%M %p, %m/%d/%Y")
.to_string();
log!("Found current date {:?}", student_date);
view! {
<div
class="flex flex-row p-3 rounded-md cursor-pointer transition-shadow shadow-sm hover:shadow-lg/33"
on:click=on_click
>
<div class="flex-1">
{student.first_name.clone()}" "{student.last_name.clone()}
</div>
<div class="flex-none">{student_date.clone()}</div>
</div>
}
};
let naive_time = chrono::NaiveDateTime::parse_from_str(&student.date, "%H:%M, %m/%d/%Y")
.unwrap();
let time_zone = FixedOffset::west_opt(5 * 3600).unwrap();
let student_date = time_zone.from_utc_datetime(&naive_time)
.format("%l:%M %p, %m/%d/%Y")
.to_string();
log!("Found current date {:?}", student_date);
view! {
<div class="flex flex-row p-3 rounded-md cursor-pointer transition-shadow shadow-sm hover:shadow-lg/33" on:click=on_click>
<div class="flex-1">
{student.first_name.clone()}" "{student.last_name.clone()}
</div>
<div class="flex-none">
{student_date.clone()}
</div>
</div>
}
}).collect_view();
})
.collect_view();
Either::Left(list_view)
},
None => Either::Right("No loaners found.".into_view())
}
None => Either::Right("No loaners found.".into_view()),
}
}}
</Suspense>
+1 -1
View File
@@ -143,7 +143,7 @@ pub fn ProviderContactPage() -> impl IntoView {
<div class="flex flex-row">
<div class="flex flex-col flex-1" />
<Panel>
<ValidatedForm
<ValidatedForm
on_submit=on_submit
title="Contact Form"
description="Enter your contact information and click submit."
+32 -31
View File
@@ -14,19 +14,19 @@ pub fn TestPage() -> impl IntoView {
description="Edit user profile"
icon="/Person_Black.png"
path="/"
/>
/>
<DashboardButton
title="Create Scholarship"
description="Navigate to Scholarship Creation Page"
icon="/Create_Black.png"
path="/"
/>
/>
<DashboardButton
title="Applicants"
description="View Scholarship Applicants"
icon="/Form_Black.png"
path="/"
/>
/>
</section>
<section class="space-y-2">
<div class="rounded-lg shadow-lg/25 overflow-hidden">
@@ -35,34 +35,35 @@ pub fn TestPage() -> impl IntoView {
</div>
<div class="p-2">
<div class="flex flex-col p-3 gap-3">
<DateList
dates=vec![
DateInfo {
title: "Title".to_string(),
date: DateRange::Range("February 2nd, 2026".to_string(), "February 10th, 2026".to_string()),
description: "This is a test".to_string(),
status: DateStatus::Upcoming
},
DateInfo {
title: "Scholarships Due".to_string(),
date: DateRange::Single("November 4th, 2025".to_string()),
description: "This is a test".to_string(),
status: DateStatus::Open
},
DateInfo {
title: "Scholarships Due".to_string(),
date: DateRange::Single("November 4th, 2025".to_string()),
description: "This is a test".to_string(),
status: DateStatus::Deadline
},
DateInfo {
title: "Scholarships Due".to_string(),
date: DateRange::Single("November 4th, 2025".to_string()),
description: "This is a test".to_string(),
status: DateStatus::Closed
}
]
/>
<DateList dates=vec![
DateInfo {
title: "Title".to_string(),
date: DateRange::Range(
"February 2nd, 2026".to_string(),
"February 10th, 2026".to_string(),
),
description: "This is a test".to_string(),
status: DateStatus::Upcoming,
},
DateInfo {
title: "Scholarships Due".to_string(),
date: DateRange::Single("November 4th, 2025".to_string()),
description: "This is a test".to_string(),
status: DateStatus::Open,
},
DateInfo {
title: "Scholarships Due".to_string(),
date: DateRange::Single("November 4th, 2025".to_string()),
description: "This is a test".to_string(),
status: DateStatus::Deadline,
},
DateInfo {
title: "Scholarships Due".to_string(),
date: DateRange::Single("November 4th, 2025".to_string()),
description: "This is a test".to_string(),
status: DateStatus::Closed,
},
] />
</div>
</div>
</div>