feat: alter OutlinedTextField to use ValueType enum

Also implemented extra error checking when the values are passed as the incorrect type. For example, the only accepted types are strings and numbers, so that will be checked and handled accordingly.
This commit is contained in:
alphafetus committed 2025-09-19 12:30:27 -04:00
1 parent 0d4bbc9e70
commit 39996319ba
6 files changed
+89 -59

No files matched your search

+16 -11
View File
@@ -1,11 +1,12 @@
use crate::components::MultiEntryData;
use crate::components::{MultiEntryData, ValueType};
use macros::Reactive;
use serde::{Deserialize, Serialize};
use std::default::Default;
use chrono::{DateTime, Utc};
use reactive_stores::Store;
/// Represents information about a student.
#[derive(Serialize, Deserialize, Debug, Clone, Reactive, Default)]
#[derive(Serialize, Deserialize, Debug, Clone, Default, Store, Reactive)]
pub struct StudentInfo {
/// The email address of the student. This was used in the previous version of the database,
/// and should now be deprecated.
@@ -14,32 +15,36 @@ pub struct StudentInfo {
pub Email: String,
/// The student's first name.
#[serde(default)]
pub first_name: String,
pub first_name: ValueType, // String
/// The student's last name.
#[serde(default)]
pub last_name: String,
pub last_name: ValueType, // String
/// The student's highest math score on the SAT.
#[serde(default)]
pub math_sat: i32,
#[serde(default = "default_number")]
pub math_sat: ValueType, // Number
/// The student's desired contact email.
#[serde(default)]
pub contact_email: String,
pub contact_email: ValueType, // String
/// The student's address.
#[serde(default)]
pub address: String,
pub address: ValueType, // String
/// The student's town of residence.
#[serde(default)]
pub town: String,
pub town: ValueType, // String
/// The student's entered phone number.
#[serde(default)]
pub phone_number: String, // May be stored as a straight number in the future.
pub phone_number: ValueType, // May be stored as a straight number in the future, but String
/// The student's birthdate.
#[serde(default)]
pub birth_date: DateTime<Utc>,
/// The student's gender.
#[serde(default)]
pub gender: String,
pub gender: ValueType, // String
/// The student's athletic information.
#[serde(default)]
pub athletic_info: Vec<MultiEntryData>,
}
fn default_number() -> ValueType {
ValueType::Number(0)
}