diff --git a/src/api/mt_form.rs b/src/api/mt_form.rs index 9d9455d..48d7bc3 100644 --- a/src/api/mt_form.rs +++ b/src/api/mt_form.rs @@ -67,14 +67,40 @@ struct MtForm { #[post("/mt-form")] pub async fn mt_form(MultipartForm(form): MultipartForm) -> HttpResponse { - let first = form.first_name.as_ref().unwrap().0.clone(); - let last = form.last_name.as_ref().unwrap().0.clone(); + let first = form + .first_name + .as_ref() + .unwrap_or(&Text { + 0: String::from(""), + }) + .0 + .clone(); + let last = form + .last_name + .as_ref() + .unwrap_or(&Text { + 0: String::from(""), + }) + .0 + .clone(); let email_subject = format!("{} {} signed up for mission trip!", first, last); let filename_noext = String::from(format!("{}_{}", first, last)); let parent = format!( "{} {}", - form.parent_first_name.as_ref().unwrap().0.clone(), - form.parent_last_name.as_ref().unwrap().0.clone() + form.parent_first_name + .as_ref() + .unwrap_or(&Text { + 0: String::from("") + }) + .0 + .clone(), + form.parent_last_name + .as_ref() + .unwrap_or(&Text { + 0: String::from("") + }) + .0 + .clone() ); let birthdate = form .birthdate