some updates to the rust server
This commit is contained in:
parent
400ad2ad5b
commit
9b70af3dba
4 changed files with 164 additions and 25 deletions
|
@ -8,13 +8,13 @@ use lettre::{
|
|||
|
||||
#[derive(Debug, MultipartForm, Default)]
|
||||
struct CampForm {
|
||||
#[multipart(rename = "firstname")]
|
||||
#[multipart(rename = "first-name")]
|
||||
first_name: Option<Text<String>>,
|
||||
#[multipart(rename = "lastname")]
|
||||
#[multipart(rename = "last-name")]
|
||||
last_name: Option<Text<String>>,
|
||||
#[multipart(rename = "parentfirstname")]
|
||||
#[multipart(rename = "parent-first-name")]
|
||||
parent_first_name: Option<Text<String>>,
|
||||
#[multipart(rename = "parentlastname")]
|
||||
#[multipart(rename = "parent-last-name")]
|
||||
parent_last_name: Option<Text<String>>,
|
||||
birthdate: Option<Text<String>>,
|
||||
gender: Option<Text<String>>,
|
||||
|
@ -22,8 +22,10 @@ struct CampForm {
|
|||
city: Option<Text<String>>,
|
||||
state: Option<Text<String>>,
|
||||
zip: Option<Text<i32>>,
|
||||
parentphone: Option<Text<String>>,
|
||||
parentemail: Option<Text<String>>,
|
||||
#[multipart(rename = "parent-phone")]
|
||||
parent_phone: Option<Text<String>>,
|
||||
#[multipart(rename = "parent-email")]
|
||||
parent_email: Option<Text<String>>,
|
||||
grade: Option<Text<String>>,
|
||||
shirt: Option<Text<String>>,
|
||||
allergies: Option<Text<String>>,
|
||||
|
@ -50,6 +52,7 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
|
|||
})
|
||||
.0
|
||||
.clone();
|
||||
let full_name = format!("{} {}", first, last);
|
||||
let email_subject = format!("{} {} signed up for camp!", first, last);
|
||||
let parent = format!(
|
||||
"{} {}",
|
||||
|
@ -109,16 +112,16 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
|
|||
.0
|
||||
.clone();
|
||||
let zip = form.zip.as_ref().unwrap_or(&Text { 0: 0 }).0.clone();
|
||||
let parentphone = form
|
||||
.parentphone
|
||||
let parent_phone = form
|
||||
.parent_phone
|
||||
.as_ref()
|
||||
.unwrap_or(&Text {
|
||||
0: String::from(""),
|
||||
})
|
||||
.0
|
||||
.clone();
|
||||
let parentemail = form
|
||||
.parentemail
|
||||
let parent_email = form
|
||||
.parent_email
|
||||
.as_ref()
|
||||
.unwrap_or(&Text {
|
||||
0: String::from(""),
|
||||
|
@ -219,11 +222,11 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
|
|||
}
|
||||
tr {
|
||||
th { "Parent Phone" }
|
||||
td { @parentphone }
|
||||
td { @parent_phone }
|
||||
}
|
||||
tr {
|
||||
th { "Parent Email" }
|
||||
td { @parentemail }
|
||||
td { @parent_email }
|
||||
}
|
||||
tr {
|
||||
th { "Grade" }
|
||||
|
@ -276,7 +279,7 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
|
|||
.build();
|
||||
match sender.send(&m) {
|
||||
Ok(res) => log::info!("{:?}", res),
|
||||
Err(e) => log::info!("{e}"),
|
||||
Err(e) => log::error!("{e}"),
|
||||
}
|
||||
} else {
|
||||
log::info!("Email incorrect");
|
||||
|
@ -285,16 +288,57 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
|
|||
match reg.as_str() {
|
||||
"now" => {
|
||||
log::info!("Sending them to pay for registration now");
|
||||
HttpResponse::Ok()
|
||||
.insert_header(("Access-Control-Expose-Headers", "*"))
|
||||
.insert_header((
|
||||
"HX-Redirect",
|
||||
"https://secure.myvanco.com/L-Z772/campaign/C-13JPJ",
|
||||
))
|
||||
.finish()
|
||||
}
|
||||
"full" => {
|
||||
log::info!("Sending them to pay for the full registration now");
|
||||
HttpResponse::Ok()
|
||||
.insert_header(("Access-Control-Expose-Headers", "*"))
|
||||
.insert_header((
|
||||
"HX-Redirect",
|
||||
"https://secure.myvanco.com/L-Z772/campaign/C-13JQE",
|
||||
))
|
||||
.finish()
|
||||
}
|
||||
"later" => {
|
||||
log::info!("They'd like to pay later");
|
||||
log::info!("{} would like to pay later", full_name);
|
||||
let html = markup::new! {
|
||||
div {
|
||||
class { "mt-8" }
|
||||
h2 {
|
||||
@format!("Thank you, {}!", full_name)
|
||||
}
|
||||
p { "Can't wait to see you at camp!" }
|
||||
p {
|
||||
class { "" }
|
||||
"If you'd like to pay for your registration go to the donate tab in the top right when you are ready and find the camp registration option."
|
||||
}
|
||||
}
|
||||
};
|
||||
HttpResponse::Ok().body(html.to_string())
|
||||
}
|
||||
_ => {
|
||||
log::error!("Got registration error.....");
|
||||
let html = markup::new! {
|
||||
div {
|
||||
class { "mt-8" }
|
||||
h2 {
|
||||
@format!("Thank you, {}!", full_name)
|
||||
}
|
||||
p { "Can't wait to see you at camp!" }
|
||||
p {
|
||||
class { "" }
|
||||
"If you'd like to pay for your registration go to the donate tab in the top right when you are ready and find the camp registration option."
|
||||
}
|
||||
}
|
||||
};
|
||||
HttpResponse::Ok().body(html.to_string())
|
||||
}
|
||||
}
|
||||
HttpResponse::Ok().body("thankyou")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue