diff --git a/src/app.rs b/src/app.rs
index 2dc3611..394aeb7 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -7,7 +7,7 @@ use leptos_router::{
};
use url::Url;
-use crate::pages::{AboutPage, HomePage, ProviderEntry};
+use crate::pages::{AboutPage, HomePage};
pub fn shell(options: LeptosOptions) -> impl IntoView {
view! {
@@ -67,7 +67,6 @@ pub fn App() -> impl IntoView {
-
diff --git a/src/common/expandable_info.rs b/src/common/expandable_info.rs
index ebb0f8f..8f6c2b4 100644
--- a/src/common/expandable_info.rs
+++ b/src/common/expandable_info.rs
@@ -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,
diff --git a/src/common/form_schema.rs b/src/common/form_schema.rs
index 8655c94..84e2816 100644
--- a/src/common/form_schema.rs
+++ b/src/common/form_schema.rs
@@ -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),
/// 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)
+ Select(String, String, Vec),
}
impl InputType {
@@ -80,7 +81,7 @@ impl InputType {
}}
}
}
-
+
pub fn into_view_rows(self, data_map: RwSignal>) -> impl IntoView {
view! {
@@ -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(),
diff --git a/src/common/mod.rs b/src/common/mod.rs
index 7e04a46..fd320cb 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -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::*};
diff --git a/src/common/student_info.rs b/src/common/student_info.rs
deleted file mode 100644
index 6f7b792..0000000
--- a/src/common/student_info.rs
+++ /dev/null
@@ -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,
- /// The student's gender.
- #[serde(default)]
- pub gender: ValueType, // String
- /// The student's athletic information.
- #[serde(default)]
- pub athletic_info: Vec,
-}
-
-fn default_number() -> ValueType {
- ValueType::Number(None)
-}
\ No newline at end of file
diff --git a/src/common/value_type.rs b/src/common/value_type.rs
index ffea234..982df27 100644
--- a/src/common/value_type.rs
+++ b/src/common/value_type.rs
@@ -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`. 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`.
pub fn as_map(&self) -> Result