feat: implement new ValidatedForm and error handling for text fields

Note that text fields only accept Region 15 email addresses right now. We should add extra domains in the future.
This commit is contained in:
alphafetus committed 2025-12-29 18:07:13 -05:00
1 parent 139ffdbe55
commit 74e7111820
9 files changed
+285 -67

No files matched your search

+6 -6
View File
@@ -9,12 +9,9 @@ use std::process::{Command, Stdio};
#[cfg(feature = "ssr")]
use std::io::Write;
use crate::common::{ExpandableInfo, UserClaims};
use crate::common::ExpandableInfo;
use crate::pages::UnauthenticatedPage;
use crate::components::{
ActionButton, CheckboxList, Loading, MultiEntry, OutlinedTextField, Panel, RadioList, Row,
Select,
};
use crate::components::{ActionButton, CheckboxList, Loading, MultiEntry, OutlinedTextField, Panel, RadioList, Row, Select, TextFieldType, ValidatedForm};
use crate::input;
use leptos::leptos_dom::logging::console_log;
use leptos::prelude::*;
@@ -167,6 +164,7 @@ pub fn HomePage() -> impl IntoView {
<Authenticated unauthenticated=UnauthenticatedPage>
// Replace this fallback with a real loading screen.
<Suspense fallback=Loading>
<ValidatedForm on_submit=Callback::new(move |_| {})>
{move || {
server_resource
.get()
@@ -227,6 +225,7 @@ pub fn HomePage() -> impl IntoView {
disabled=elements_disabled
data_member="contact_email"
data_map=expandable_react.data
input_type=TextFieldType::Email
/>
</Row>
<Row>
@@ -254,7 +253,7 @@ pub fn HomePage() -> impl IntoView {
disabled=elements_disabled
data_member="math_sat"
data_map=expandable_react.data
input_type="number"
input_type=TextFieldType::Number
/>
</Row>
<Row>
@@ -357,6 +356,7 @@ pub fn HomePage() -> impl IntoView {
}
})
}}
</ValidatedForm>
</Suspense>
</Authenticated>
</AuthLoaded>
+4 -4
View File
@@ -5,7 +5,7 @@ use leptos::prelude::*;
use leptos_oidc::{AuthLoaded, Authenticated};
use leptos_router::hooks::{use_navigate, use_params};
use crate::common::{ExpandableInfo, ScholarshipFormParams, SubmitStatus, ValueType};
use crate::components::{ActionButton, Banner, ChipsList, Loading, OutlinedTextField, Panel, RadioList, Row};
use crate::components::{ActionButton, Banner, ChipsList, Loading, OutlinedTextField, Panel, RadioList, Row, TextFieldType};
use super::UnauthenticatedPage;
use traits::{AsReactive, ReactiveCapture};
use crate::common::ComparisonData;
@@ -461,7 +461,7 @@ fn ScholarshipForm(
disabled=elements_disabled
data_member="amount_per_award"
data_map=reactive_info.data
input_type="number"
input_type=TextFieldType::Number
/>
</Row>
<Row>
@@ -471,7 +471,7 @@ fn ScholarshipForm(
disabled=elements_disabled
data_member="num_awards"
data_map=reactive_info.data
input_type="number"
input_type=TextFieldType::Number
/>
</Row>
<Row>
@@ -481,7 +481,7 @@ fn ScholarshipForm(
disabled=elements_disabled
data_member="total_awards"
data_map=reactive_info.data
input_type="number"
input_type=TextFieldType::Number
/>
</Row>
<Row>