fixed bug in receiving non filled out zip

This commit is contained in:
Chris Cochrun 2024-01-09 21:37:18 -06:00
parent b09417eb32
commit 4004b1cf9d

View file

@ -19,11 +19,10 @@ struct HealthForm {
#[multipart(rename = "parentlastname")] #[multipart(rename = "parentlastname")]
parent_last_name: Option<Text<String>>, parent_last_name: Option<Text<String>>,
birthdate: Option<Text<String>>, birthdate: Option<Text<String>>,
gender: Option<Text<String>>,
street: Option<Text<String>>, street: Option<Text<String>>,
city: Option<Text<String>>, city: Option<Text<String>>,
state: Option<Text<String>>, state: Option<Text<String>>,
zip: Option<Text<i32>>, zip: Option<Text<String>>,
#[multipart(rename = "cellphone")] #[multipart(rename = "cellphone")]
parent_cellphone: Option<Text<String>>, parent_cellphone: Option<Text<String>>,
homephone: Option<Text<String>>, homephone: Option<Text<String>>,
@ -63,6 +62,7 @@ struct HealthForm {
#[post("/health-form")] #[post("/health-form")]
pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> HttpResponse { pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> HttpResponse {
log::info!("{:?}", form);
let first = form let first = form
.first_name .first_name
.as_ref() .as_ref()
@ -106,14 +106,6 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
}) })
.0 .0
.clone(); .clone();
let gender = form
.gender
.as_ref()
.unwrap_or(&Text {
0: String::from(""),
})
.0
.clone();
let street = form let street = form
.street .street
.as_ref() .as_ref()
@ -138,7 +130,14 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
}) })
.0 .0
.clone(); .clone();
let zip = form.zip.as_ref().unwrap_or(&Text { 0: 0 }).0.clone(); let zip = form
.zip
.as_ref()
.unwrap_or(&Text {
0: String::from(""),
})
.0
.clone();
let parent_cellphone = form let parent_cellphone = form
.parent_cellphone .parent_cellphone
.as_ref() .as_ref()
@ -330,10 +329,6 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
th { "Birthdate" } th { "Birthdate" }
td { @birthdate } td { @birthdate }
} }
tr {
th { "Gender" }
td { @gender }
}
tr { tr {
th { "Street" } th { "Street" }
td { @street } td { @street }
@ -479,7 +474,7 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
.unwrap(), .unwrap(),
) )
.to("Chris Cochrun <chris@tfcconnection.org>".parse().unwrap()) .to("Chris Cochrun <chris@tfcconnection.org>".parse().unwrap())
.to("Ethan Rose <ethan@tfcconnection.org>".parse().unwrap()) // .to("Ethan Rose <ethan@tfcconnection.org>".parse().unwrap())
.subject(email_subject) .subject(email_subject)
.multipart(multi) .multipart(multi)
{ {