feat: optimize imports to remove warnings

This commit is contained in:
alphafetus committed 2026-01-05 15:56:28 -05:00
1 parent 9c7b7f1d4f
commit a2f69a83c2
16 files changed
+46 -109

No files matched your search

+1
View File
@@ -23,6 +23,7 @@ pub struct ComparisonData {
}
impl ComparisonData {
#[allow(unused)]
pub fn new(
id: impl Into<String>,
member: impl Into<String>,
-1
View File
@@ -3,7 +3,6 @@ mod lists;
mod number;
mod text;
mod traits;
mod utils;
pub use self::{base::*, lists::*, number::*, text::*, traits::*};
-28
View File
@@ -1,28 +0,0 @@
use crate::common::ValueType;
/// This function is a work in progress. It's designed to flatten a list of maps by using the
/// given key and verifier function, however it currently doesn't work and just needs to be
/// planned out a little more.
fn flatten_map_helper<F>(
list: &Vec<ValueType>,
key: &String,
verifier: F,
) -> Result<Vec<ValueType>, String>
where
F: Fn(&ValueType) -> Option<&ValueType>,
{
let mut out = Vec::new();
for item in list {
let map = match item {
ValueType::Map(Some(map)) => map,
_ => return Err("Expected a map".to_owned()),
};
// Get the key, and verify that the value is the correct type. If so, push it.
if let Some(value) = map.get(key).and_then(|v| verifier(v)) {
out.push(value.clone());
}
}
Ok(out)
}
-8
View File
@@ -87,14 +87,6 @@ impl InputType {
}}
}
}
pub fn into_view_rows(self, data_map: RwSignal<HashMap<String, ValueType>>) -> impl IntoView {
view! {
<Row>
{self.into_view(data_map)}
</Row>
}
}
}
/// Shorthand macro for creating `InputType` enums.
+1 -1
View File
@@ -3,5 +3,5 @@ pub enum SubmitStatus {
Idle,
Sending,
Success,
Error(String),
Error(()),
}
-2
View File
@@ -7,7 +7,6 @@ pub struct ListController {
pub error: Signal<ValidationState>,
pub dirty: RwSignal<bool>,
pub show_errors: Signal<bool>,
pub validator: RwSignal<InputState>,
pub selected_list: RwSignal<Vec<String>>,
}
@@ -87,7 +86,6 @@ pub fn use_selectable_list(
error,
dirty,
show_errors,
validator,
selected_list,
}
}
-1
View File
@@ -21,7 +21,6 @@ fn validate(required: bool, value: String) -> ValidationState {
#[component]
pub fn Select(
#[prop()] value_list: Vec<String>,
#[prop(optional)] value: RwSignal<String>,
#[prop(into)] data_member: Signal<String>,
#[prop()] data_map: RwSignal<HashMap<String, ValueType>>,
#[prop(optional, into)] label: String,
-12
View File
@@ -73,9 +73,6 @@ pub fn MultiEntry(
/// component's `data_member` input.
#[prop()]
data_map: RwSignal<HashMap<String, ValueType>>,
/// Currently unused.
#[prop(optional, into)]
name_member: String,
/// The type and order of the inputs for each `Entry` component within this `MultiEntry` component.
#[prop(optional)]
schema: Vec<InputType>,
@@ -132,7 +129,6 @@ pub fn MultiEntry(
view! {
<Entry
data_map = map_signal
name_member = name_member.clone()
schema = schema.clone()
/>
}
@@ -186,14 +182,6 @@ fn Entry(
/// data members those inputs modify.
#[prop()]
schema: Vec<InputType>,
/// The display name member of this entry. Determines where the component should search for the
/// name of the entry within the `data_map`.
#[prop(into)]
name_member: String,
/// The info member of this entry. Determines where the component should search for the extra
/// information of this entry within the `data_map`.
#[prop(optional, into)]
info_member: String,
) -> impl IntoView {
view! {
<div class="flex flex-col flex-1 p-2 rounded-sm transition-shadow shadow-sm hover:shadow-lg/30">
+1 -3
View File
@@ -2,9 +2,8 @@ use crate::common::ValueType;
use leptos::prelude::*;
use std::collections::HashMap;
use leptos::html::Input;
use leptos::logging::log;
use crate::components::{use_validation_context, InputState};
use crate::components::validated_form::{FormValidationRegistry, ValidationState};
use crate::components::validated_form::ValidationState;
/// Determines the available types of text fields.
#[derive(Default, Debug, Clone)]
@@ -64,7 +63,6 @@ pub fn OutlinedTextField(
#[prop(optional, into)] label: String,
#[prop(optional, into)] required: Signal<bool>
) -> impl IntoView {
let valid = RwSignal::new(true);
let input_ref = NodeRef::<Input>::new();
// Register this input's validation signal.
-1
View File
@@ -2,7 +2,6 @@ pub mod app;
mod common;
mod components;
mod pages;
mod utils;
#[cfg(feature = "hydrate")]
#[wasm_bindgen::prelude::wasm_bindgen]
+18 -7
View File
@@ -8,12 +8,12 @@ use crate::common::{
ComparisonData, ComparisonType, MapListComparison, NumberComparison, NumberListComparison,
TextComparison, TextListComparison, ValueType,
};
use leptos::leptos_dom::log;
use leptos::prelude::ServerFnError;
use leptos::server;
/// Helper function to create all sports comparisons. Only used to create initial
/// comparison data, and should be removed upon completion of a comparison editor page.
#[allow(unused)]
fn create_sports_comparisons() -> Vec<ComparisonData> {
vec![
ComparisonData::new(
@@ -184,12 +184,8 @@ fn create_sports_comparisons() -> Vec<ComparisonData> {
]
}
#[server(CreateTestComparisons, endpoint = "/comparisons/create-test")]
pub async fn create_test_comparisons() -> Result<(), ServerFnError> {
let client = create_dynamo_client().await;
log!("Creating test comparisons");
#[allow(unused)]
fn make_comp_list() -> Vec<ComparisonData> {
let test_comp = ComparisonData::new(
"math_sat_comp",
"math_sat",
@@ -304,6 +300,19 @@ pub async fn create_test_comparisons() -> Result<(), ServerFnError> {
comp_list.append(&mut sports_comps);
comp_list.append(&mut major_comps);
comp_list
}
#[server(CreateTestComparisons, endpoint = "/comparisons/create-test")]
pub async fn create_test_comparisons() -> Result<(), ServerFnError> {
use leptos::logging::log;
let client = create_dynamo_client().await;
log!("Creating test comparisons");
let comp_list = make_comp_list();
for comparison in comp_list {
if let Err(err) = client
.put_item()
@@ -322,6 +331,8 @@ pub async fn create_test_comparisons() -> Result<(), ServerFnError> {
#[server]
pub async fn get_comparison_info() -> Result<Vec<ComparisonData>, ServerFnError> {
use leptos::logging::log;
let client = create_dynamo_client().await;
log!("Getting all comparisons from the database");
+9 -5
View File
@@ -3,15 +3,19 @@ use aws_sdk_dynamodb::{
types::AttributeValue,
error::ProvideErrorMetadata,
};
#[cfg(feature = "ssr")]
use leptos::leptos_dom::log;
use leptos::prelude::ServerFnError;
use leptos::server;
#[cfg(feature = "ssr")]
use uuid::Uuid;
use crate::common::{ExpandableInfo, ValueType};
#[cfg(feature = "ssr")]
use crate::pages::utils::server_utils::create_dynamo_client;
#[cfg(feature = "ssr")]
use crate::common::ValueType;
use crate::common::ExpandableInfo;
use leptos::prelude::ServerFnError;
use leptos::server;
#[server(GetScholarshipInfo, endpoint = "/scholarship/info/get")]
pub async fn get_scholarship_info(id: String) -> Result<ExpandableInfo, ServerFnError> {
+1 -1
View File
@@ -217,7 +217,7 @@ pub fn HomePage() -> impl IntoView {
{move || {
server_resource
.get()
.map(|submission| {
.map(|_| {
view! {
<Row>
<div class="flex flex-col flex-1" />
+4 -3
View File
@@ -4,7 +4,10 @@ use aws_sdk_dynamodb::{Client, error::ProvideErrorMetadata, types::AttributeValu
#[cfg(feature = "ssr")]
use serde_dynamo::{from_item, to_item};
use crate::common::{ExpandableInfo, ValueType};
#[cfg(feature = "ssr")]
use crate::common::ValueType;
use crate::common::ExpandableInfo;
use crate::components::{ActionButton, Banner, DashboardButton, OutlinedTextField, Panel, Row, Select, TextFieldType, ValidatedForm};
use chrono::{FixedOffset, TimeZone};
use leptos::Params;
@@ -16,7 +19,6 @@ use leptos_router::hooks::{use_navigate, use_params};
use leptos_router::params::Params;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use traits::{AsReactive, ReactiveCapture};
#[derive(Params, PartialEq)]
struct LoanerParams {
@@ -243,7 +245,6 @@ pub fn LoanerPage() -> impl IntoView {
pub fn LoanerBorrowForm() -> impl IntoView {
// Register server actions.
let create_entry_action = ServerAction::<CreateBorrowEntry>::new();
let navigate = use_navigate();
let data = RwSignal::new(HashMap::new());
let elements_disabled = Signal::derive(move || create_entry_action.pending().get());
+11 -13
View File
@@ -10,7 +10,7 @@ use crate::components::{ActionButton, Banner, ChipsList, Loading, OutlinedTextFi
use super::UnauthenticatedPage;
use crate::common::ComparisonData;
use crate::pages::utils::get_user_claims;
use super::api::{get_comparison_info, get_provider_scholarships, get_scholarship_info, CreateScholarshipInfo, CreateTestComparisons, RegisterScholarship, DeleteProviderScholarship};
use super::api::{get_comparison_info, get_provider_scholarships, get_scholarship_info, CreateScholarshipInfo, RegisterScholarship, DeleteProviderScholarship};
/// # Scholarship Info Page
@@ -31,7 +31,7 @@ pub fn ScholarshipInfoPage() -> impl IntoView {
.and_then(|params| params.id.clone())
});
let create_test_comps = ServerAction::<CreateTestComparisons>::new();
// let create_test_comps = ServerAction::<CreateTestComparisons>::new();
let on_delete = move || {
let navigate = use_navigate();
@@ -279,7 +279,7 @@ fn ScholarshipListEntry(
) -> impl IntoView {
let navigate = use_navigate();
let user_claims = get_user_claims();
let user_id = Memo::new(move |_| {
let _user_id = Memo::new(move |_| {
user_claims.get()
.map(|info| info.claims.subject.clone())
});
@@ -350,13 +350,6 @@ fn ScholarshipForm(
/// submission fails, this function is not run.
#[prop(into)] on_submit: Callback<()>
) -> impl IntoView {
let submit_status = RwSignal::new(SubmitStatus::Idle);
let elements_disabled = Signal::derive(move || {
match submit_status.get() {
SubmitStatus::Sending => true,
_ => false
}
});
// let result_msg = Signal::derive(move || {
// match submit_status.get() {
// SubmitStatus::Idle => "".into(),
@@ -367,7 +360,12 @@ fn ScholarshipForm(
// });
let submit_action = ServerAction::<CreateScholarshipInfo>::new();
let submit_status = RwSignal::new(SubmitStatus::Idle);
let elements_disabled = Signal::derive(move || {
matches!(submit_action.pending().get(), true)
});
Effect::new(move || {
if submit_action.pending().get() {
submit_status.set(SubmitStatus::Sending);
@@ -380,7 +378,7 @@ fn ScholarshipForm(
submit_status.set(SubmitStatus::Success);
on_submit.run(());
},
Err(err) => submit_status.set(SubmitStatus::Error(err.to_string()))
Err(_err) => submit_status.set(SubmitStatus::Error(()))
}
}
});
@@ -455,7 +453,7 @@ fn ScholarshipForm(
scholarship_info.get()
.map(|res_scholarship| {
match res_scholarship {
Ok(scholarship) => {
Ok(_) => {
Either::Left(view! {
<Row>
<h1 class="text-3xl font-bold">
-23
View File
@@ -1,23 +0,0 @@
use crate::common::{ExpandableInfo, ValueType};
use std::ops::ControlFlow;
pub fn get_number_list(student_info: &ExpandableInfo, member: &String) -> Result<Vec<f64>, String> {
match student_info.data.get(member) {
Some(ValueType::List(Some(list))) => {
let temp = list.iter().try_fold(vec![], |mut list_acc, item| {
if let ValueType::Number(Some(number)) = item {
list_acc.push(number.parse::<f64>().unwrap());
ControlFlow::Continue(list_acc)
} else {
ControlFlow::Break(list_acc)
}
});
match temp {
ControlFlow::Continue(list) => Ok(list),
ControlFlow::Break(_) => return Err("List contains non-number values".to_owned()),
}
}
_ => return Err("Couldn't find the list".to_owned()),
}
}