From 94c2930d2a1ff34710fd51e87f6d0e3e9a607ee1 Mon Sep 17 00:00:00 2001 From: Lucas Vas Date: Mon, 29 Dec 2025 19:08:28 -0500 Subject: [PATCH] feat: signal refactor for loaner page --- src/components/text_field.rs | 3 - src/pages/loaner_page.rs | 148 +++++++++++++++++------------------ 2 files changed, 72 insertions(+), 79 deletions(-) diff --git a/src/components/text_field.rs b/src/components/text_field.rs index 5c22009..7ef089b 100644 --- a/src/components/text_field.rs +++ b/src/components/text_field.rs @@ -21,7 +21,6 @@ pub enum TextFieldType { /// Entry point for validating a text field. fn validate(required: bool, value: &str, input_type: &TextFieldType) -> ValidationState { - log!("Input information: required: {}, value: \"{}\", input_type: {:?}", required, value, input_type); if required && value.is_empty() { ValidationState::Invalid("This field is required.".to_string()) } else { @@ -36,7 +35,6 @@ fn validate(required: bool, value: &str, input_type: &TextFieldType) -> Validati /// Validates an email address. fn validate_email(input: &str) -> ValidationState { // TODO Accept more than just Region 15 addresses. - log!("Validating email: {}", input); let pattern = regex::Regex::new(r"^[a-zA-Z0-9._%+-]+@region15\.org$").expect("Invalid regex pattern"); if pattern.is_match(input) { @@ -48,7 +46,6 @@ fn validate_email(input: &str) -> ValidationState { /// Validates a number. fn validate_number(input: &str) -> ValidationState { - log!("Validating number: {}", input); if input.parse::().is_ok() { ValidationState::Valid } else { diff --git a/src/pages/loaner_page.rs b/src/pages/loaner_page.rs index b03cd9b..a916cbe 100644 --- a/src/pages/loaner_page.rs +++ b/src/pages/loaner_page.rs @@ -5,9 +5,7 @@ use aws_sdk_dynamodb::{Client, error::ProvideErrorMetadata, types::AttributeValu use serde_dynamo::{from_item, to_item}; use crate::common::{ExpandableInfo, ValueType}; -use crate::components::{ - ActionButton, Banner, DashboardButton, OutlinedTextField, Panel, Row, Select, -}; +use crate::components::{ActionButton, Banner, DashboardButton, OutlinedTextField, Panel, Row, Select, TextFieldType, ValidatedForm}; use chrono::{FixedOffset, TimeZone}; use leptos::Params; use leptos::either::{Either, EitherOf3}; @@ -247,81 +245,79 @@ pub fn LoanerBorrowForm() -> impl IntoView { let create_entry_action = ServerAction::::new(); let navigate = use_navigate(); - let temp = ExpandableInfo::new(uuid::Uuid::new_v4().to_string()); - let temp_reactive = temp.as_reactive(); - let elements_disabled = RwSignal::new(false); + let data = RwSignal::new(HashMap::new()); + let elements_disabled = Signal::derive(move || create_entry_action.pending().get()); + + let on_submit = move |_| { + create_entry_action.dispatch(CreateBorrowEntry { + input: ExpandableInfo { + subject: uuid::Uuid::new_v4().to_string(), + data: data.get(), + } + }); + }; view! { -
-

"Borrower Information"

-

"Please fill out the form below."

-
- - - - - - - - - - - - "Submit" - + +
+

"Borrower Information"

+

"Please fill out the form below."

+
+ + + + + + + + + + +
} }