working health form pieces too with much better logging
This commit is contained in:
parent
4a8325aa35
commit
a3fbdfae8b
|
@ -3,7 +3,14 @@
|
|||
|
||||
|
||||
<div id="mt-form" class="form text-lg w-full">
|
||||
<form id='form' hx-post="http://localhost:4242/camp-form" hx-encoding="multipart/form-data" autocomplete="on" method="post" target="_parent" class="w-full items-center flex flex-wrap">
|
||||
<form id='form'
|
||||
hx-post="http://localhost:4242/camp-form"
|
||||
hx-encoding="multipart/form-data"
|
||||
autocomplete="on"
|
||||
method="post"
|
||||
target="_parent"
|
||||
class="w-full items-center flex flex-wrap">
|
||||
|
||||
<h3 class="basis-full">Camp Form</h3>
|
||||
<div class="basis-full flex flex-wrap my-4">
|
||||
<label for="first-name" class="basis-full">What is your first and last name? <span class='inline-block text-[#f39] text-sm align-sub'>* required</span></label>
|
||||
|
|
|
@ -219,7 +219,8 @@
|
|||
<form id='form'
|
||||
hx-post="http://localhost:4242/health-form"
|
||||
hx-encoding="multipart/form-data"
|
||||
autocomplete="on" method="post"
|
||||
autocomplete="on"
|
||||
method="post"
|
||||
target="_parent"
|
||||
class="w-full items-center flex flex-wrap">
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ use lettre::{
|
|||
transport::smtp::authentication::{Credentials, Mechanism},
|
||||
Message, SmtpTransport, Transport,
|
||||
};
|
||||
use maud::html;
|
||||
|
||||
#[derive(Debug, MultipartForm, Default)]
|
||||
struct HealthForm {
|
||||
|
@ -18,6 +19,7 @@ struct HealthForm {
|
|||
parent_first_name: Option<Text<String>>,
|
||||
#[multipart(rename = "parent-last-name")]
|
||||
parent_last_name: Option<Text<String>>,
|
||||
#[multipart(rename = "birth-date")]
|
||||
birthdate: Option<Text<String>>,
|
||||
street: Option<Text<String>>,
|
||||
city: Option<Text<String>>,
|
||||
|
@ -25,13 +27,17 @@ struct HealthForm {
|
|||
zip: Option<Text<String>>,
|
||||
#[multipart(rename = "cell-phone")]
|
||||
parent_cellphone: Option<Text<String>>,
|
||||
#[multipart(rename = "home-phone")]
|
||||
homephone: Option<Text<String>>,
|
||||
#[multipart(rename = "additional-emergency-contact")]
|
||||
contact: Option<Text<String>>,
|
||||
#[multipart(rename = "addtional-emergency-contact-phone")]
|
||||
contact_phone: Option<Text<String>>,
|
||||
#[multipart(rename = "doctor-name")]
|
||||
doctorname: Option<Text<String>>,
|
||||
#[multipart(rename = "doctor-city")]
|
||||
doctorcity: Option<Text<String>>,
|
||||
#[multipart(rename = "doctor-phone")]
|
||||
doctorphone: Option<Text<String>>,
|
||||
#[multipart(rename = "medical-coverage")]
|
||||
medical: Option<Text<String>>,
|
||||
|
@ -248,11 +254,10 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
|
|||
.0
|
||||
.clone();
|
||||
log::info!("{first} {last} filled out a health form!");
|
||||
let email = markup::new! {
|
||||
@markup::doctype()
|
||||
let email = html! {
|
||||
html {
|
||||
head {
|
||||
title { @format!("{} {} filled out a health form!", first, last) }
|
||||
title { (first) " " (last) " filled out a health form!" }
|
||||
style {
|
||||
"table { border-collapse: collapse; width: 100% }"
|
||||
"td, th { padding: 8px }"
|
||||
|
@ -263,116 +268,116 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
|
|||
}
|
||||
}
|
||||
body {
|
||||
h1 { @format!("Health form for {} {}!", first, last) }
|
||||
h1 { "Health form for " (first) " " (last) "!" }
|
||||
hr;
|
||||
table {
|
||||
tr {
|
||||
th { "Name" }
|
||||
td { @format!("{} {}", first, last) }
|
||||
td { (first) " " (last) }
|
||||
}
|
||||
tr {
|
||||
th { "Parent" }
|
||||
td { @parent }
|
||||
td { (parent) }
|
||||
}
|
||||
tr {
|
||||
th { "Birthdate" }
|
||||
td { @birthdate }
|
||||
td { (birthdate) }
|
||||
}
|
||||
tr {
|
||||
th { "Street" }
|
||||
td { @street }
|
||||
td { (street) }
|
||||
}
|
||||
tr {
|
||||
th { "City" }
|
||||
td { @city }
|
||||
td { (city) }
|
||||
}
|
||||
tr {
|
||||
th { "State" }
|
||||
td { @state }
|
||||
td { (state) }
|
||||
}
|
||||
tr {
|
||||
th { "Zip" }
|
||||
td { @zip }
|
||||
td { (zip) }
|
||||
}
|
||||
tr {
|
||||
th { "Phone" }
|
||||
td { @parent_cellphone }
|
||||
td { (parent_cellphone) }
|
||||
}
|
||||
tr {
|
||||
th { "Home Phone" }
|
||||
td { @homephone }
|
||||
td { (homephone) }
|
||||
}
|
||||
tr {
|
||||
th { "Additional Emergency Contact" }
|
||||
td { @contact }
|
||||
td { (contact) }
|
||||
}
|
||||
tr {
|
||||
th { "Contact Phone" }
|
||||
td { @contact_phone }
|
||||
td { (contact_phone) }
|
||||
}
|
||||
tr {
|
||||
th { "Doctor" }
|
||||
td { @doctorname }
|
||||
td { (doctorname) }
|
||||
}
|
||||
tr {
|
||||
th { "Doctor City" }
|
||||
td { @doctorcity }
|
||||
td { (doctorcity) }
|
||||
}
|
||||
tr {
|
||||
th { "Doctor Phone" }
|
||||
td { @doctorphone }
|
||||
td { (doctorphone) }
|
||||
}
|
||||
tr {
|
||||
th { "Medical Coverage" }
|
||||
td { @medical }
|
||||
td { (medical) }
|
||||
}
|
||||
tr {
|
||||
th { "Insurance Provider" }
|
||||
td { @insurance }
|
||||
td { (insurance) }
|
||||
}
|
||||
tr {
|
||||
th { "Policy Number" }
|
||||
td { @policy_number }
|
||||
td { (policy_number) }
|
||||
}
|
||||
tr {
|
||||
th { "Allergies" }
|
||||
td { @allergies }
|
||||
td { (allergies) }
|
||||
}
|
||||
tr {
|
||||
th { "Other Allergies" }
|
||||
td { @allergies_other }
|
||||
td { (allergies_other) }
|
||||
}
|
||||
tr {
|
||||
th { "Specific Allergies" }
|
||||
td { @specific_allergies }
|
||||
td { (specific_allergies) }
|
||||
}
|
||||
tr {
|
||||
th { "Treatments" }
|
||||
td { @treatment }
|
||||
td { (treatment) }
|
||||
}
|
||||
tr {
|
||||
th { "Physical or mental conditions" }
|
||||
td { @conditions }
|
||||
td { (conditions) }
|
||||
}
|
||||
tr {
|
||||
th { "Last tetanus shot" }
|
||||
td { @tetanus }
|
||||
td { (tetanus) }
|
||||
}
|
||||
tr {
|
||||
th { "Swimming Ability" }
|
||||
td { @swimming }
|
||||
td { (swimming) }
|
||||
}
|
||||
tr {
|
||||
th { "Medication Schedule" }
|
||||
td { @medication }
|
||||
td { (medication) }
|
||||
}
|
||||
tr {
|
||||
th { "Other Relevant Info" }
|
||||
td { @notes }
|
||||
td { (notes) }
|
||||
}
|
||||
tr {
|
||||
th { "Final Agreement" }
|
||||
td { @agreement }
|
||||
td { (agreement) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -410,10 +415,10 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
|
|||
let attachment = Attachment::new(filename).body(filebody.unwrap(), content_type);
|
||||
log::info!("{:?}", attachment);
|
||||
MultiPart::mixed()
|
||||
.singlepart(SinglePart::html(email.to_string()))
|
||||
.singlepart(SinglePart::html(email.into_string()))
|
||||
.singlepart(attachment)
|
||||
} else {
|
||||
MultiPart::alternative_plain_html(String::from("Testing"), email.to_string())
|
||||
MultiPart::alternative_plain_html(String::from("Testing"), email.into_string())
|
||||
};
|
||||
|
||||
log::info!("{:?}", multi);
|
||||
|
@ -469,11 +474,11 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
|
|||
}
|
||||
"later" => {
|
||||
log::info!("{} would like to pay later", full_name);
|
||||
let html = markup::new! {
|
||||
let html = html! {
|
||||
div {
|
||||
class { "mt-8" }
|
||||
h2 {
|
||||
@format!("Thank you, {}!", full_name)
|
||||
"Thank you, " (full_name) "!"
|
||||
}
|
||||
p { "Can't wait to see you at camp!" }
|
||||
p {
|
||||
|
@ -482,15 +487,15 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
|
|||
}
|
||||
}
|
||||
};
|
||||
HttpResponse::Ok().body(html.to_string())
|
||||
HttpResponse::Ok().body(html.into_string())
|
||||
}
|
||||
_ => {
|
||||
log::error!("Got registration error.....");
|
||||
let html = markup::new! {
|
||||
let html = html! {
|
||||
div {
|
||||
class { "mt-8" }
|
||||
h2 {
|
||||
@format!("Thank you, {}!", full_name)
|
||||
"Thank you, " (full_name) "!"
|
||||
}
|
||||
p { "Can't wait to see you at camp!" }
|
||||
p {
|
||||
|
@ -499,7 +504,7 @@ pub async fn health_form(MultipartForm(form): MultipartForm<HealthForm>) -> Http
|
|||
}
|
||||
}
|
||||
};
|
||||
HttpResponse::Ok().body(html.to_string())
|
||||
HttpResponse::Ok().body(html.into_string())
|
||||
}
|
||||
}
|
||||
// HttpResponse::Ok().body("hi")
|
||||
|
|
Loading…
Reference in a new issue