feat: remove former MultiEntry component and unused ProviderEntry page

This commit is contained in:
alphafetus committed 2025-10-16 11:58:25 -04:00
1 parent 86bd471c1e
commit 208bea2d09
20 files changed
+129 -426

No files matched your search

+5 -5
View File
@@ -1,16 +1,16 @@
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use crate::common::ValueType;
use macros::Reactive;
use crate::components::ValueType;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// This struct allows for completely open-ended data storage.
///
///
/// The `HashMap` allows the application to store an arbitrary number of values which are accessible
/// using a `String` as a key, allowing for simple shifting of stored values. All information is
/// stored using the `ValueType` enum, which provides some simple methods to verify the type of the
/// stored value. It *must* have a main key member name so that a database will know how to store
/// the data.
///
///
/// In the future, this should also be optimized to store properly within a DynamoDB table. As of
/// now, the table will simply create a single massive `Map` field that contains all the stored
/// information in the `HashMap`. We'd prefer to be able to get single values if possible,
+11 -10
View File
@@ -1,13 +1,14 @@
use std::collections::HashMap;
use leptos::{view, IntoView};
use crate::common::ValueType;
use crate::components::{CheckboxList, OutlinedTextField, RadioList, Row, Select};
use leptos::either::EitherOf5;
use leptos::prelude::RwSignal;
use serde::{Serialize, Deserialize};
use crate::components::{CheckboxList, OutlinedTextField, RadioList, Row, Select, ValueType};
use leptos::{IntoView, view};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
/// Defines a series of options that allow a user to define a form.
#[derive(Serialize, Deserialize, Clone, Debug)]
pub enum InputType{
pub enum InputType {
/// Represents a text input. Requires a `String` key, `String` label, and `String` placeholder.
/// The entered value will be returned as a single `String` value.
Text(String, String, String),
@@ -23,7 +24,7 @@ pub enum InputType{
Checkbox(String, String, Vec<String>),
/// Represents a dropdown input. Requires a `String` key, `String` label, and a series
/// of `String` options. The selected value will be returned as a `String`.
Select(String, String, Vec<String>)
Select(String, String, Vec<String>),
}
impl InputType {
@@ -80,7 +81,7 @@ impl InputType {
}}
}
}
pub fn into_view_rows(self, data_map: RwSignal<HashMap<String, ValueType>>) -> impl IntoView {
view! {
<Row>
@@ -91,12 +92,12 @@ impl InputType {
}
/// Shorthand macro for creating `InputType` enums.
///
///
/// Example usage:
/// ```
/// // To create an InputType::Text
/// let text_input = input!(Text, "member", "label", "placeholder");
///
///
/// // To create an InputType::Select
/// let select_input = input!(Select, "member", "label", ["option1", "option2"]);
/// ```
@@ -109,7 +110,7 @@ macro_rules! input {
vec![$($option.to_string()), *]
)
};
($variant:ident, $key:expr, $label:expr, $placeholder:expr) => {
$crate::common::InputType::$variant(
$key.to_string(),
+3 -4
View File
@@ -1,7 +1,6 @@
mod student_info;
mod user;
mod form_schema;
mod expandable_info;
mod form_schema;
mod user;
pub mod value_type;
pub use self::{expandable_info::*, form_schema::*, student_info::*, user::*};
pub use self::{expandable_info::*, form_schema::*, user::*, value_type::*};
-50
View File
@@ -1,50 +0,0 @@
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, 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.
///
/// This is the primary key of the table, and should not have a default value.
pub Email: String,
/// The student's first name.
#[serde(default)]
pub first_name: ValueType, // String
/// The student's last name.
#[serde(default)]
pub last_name: ValueType, // String
/// The student's highest math score on the SAT.
#[serde(default = "default_number")]
pub math_sat: ValueType, // Number
/// The student's desired contact email.
#[serde(default)]
pub contact_email: ValueType, // String
/// The student's address.
#[serde(default)]
pub address: ValueType, // String
/// The student's town of residence.
#[serde(default)]
pub town: ValueType, // String
/// The student's entered phone number.
#[serde(default)]
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: ValueType, // String
/// The student's athletic information.
#[serde(default)]
pub athletic_info: Vec<MultiEntryData>,
}
fn default_number() -> ValueType {
ValueType::Number(None)
}
+25 -9
View File
@@ -1,11 +1,11 @@
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use serde::{Serialize, Deserialize};
use std::fmt::Display;
/// Defines a set of possible input types. They allow for the type and value of every data member
/// to be stored within a single `HashMap` or `Vec`. This means that even though all the data is
/// created as a single type, the values are still able to be type safe.
///
///
/// A note: other structs cannot be stored in this enum, however it was designed to work with
/// a `HashMap` of more `ValueType` enums. There are numerous ways to convert a struct into a
/// `HashMap`, specifically storing all the struct's fields as `String` keys in the map.
@@ -24,7 +24,11 @@ pub enum ValueType {
impl ValueType {
/// Returns true if this is a `String`, otherwise false.
pub fn is_string(&self) -> bool {
if let ValueType::String(_) = self { true } else { false }
if let ValueType::String(_) = self {
true
} else {
false
}
}
/// Attempts to get this value as a `String` type. This is different from the `to_string` method.
@@ -38,7 +42,11 @@ impl ValueType {
/// Returns true if this is a `Number`, otherwise false.
pub fn is_number(&self) -> bool {
if let ValueType::Number(_) = self { true } else { false }
if let ValueType::Number(_) = self {
true
} else {
false
}
}
/// Attempts to get this value as an `i32`.
@@ -52,7 +60,11 @@ impl ValueType {
/// Returns true if this is a `List`, otherwise false.
pub fn is_list(&self) -> bool {
if let ValueType::List(_) = self { true } else { false }
if let ValueType::List(_) = self {
true
} else {
false
}
}
/// Attempts to get this value as a `Vec<ValueType>`. Each of the values inside the list must
@@ -64,12 +76,16 @@ impl ValueType {
Err(self.clone())
}
}
/// Returns true if this is a `Map`, otherwise false.
pub fn is_map(&self) -> bool {
if let ValueType::Map(_) = self { true } else { false }
pub fn is_map(&self) -> bool {
if let ValueType::Map(_) = self {
true
} else {
false
}
}
/// Attempts to get this value as a `HashMap<String, ValueType>`.
pub fn as_map(&self) -> Result<Option<HashMap<String, ValueType>>, Self> {
if let ValueType::Map(v) = self {