From 715a997a1fc57724ced2d51d59ae73f787856b6e Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 9 Jan 2024 06:03:11 -0600 Subject: [PATCH] fixing bug in mt_form --- src/api/mt_form.rs | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) 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