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