starting to move back to rust webserver

This commit is contained in:
Chris Cochrun 2024-06-21 12:27:39 -05:00
parent 4f3ca354dc
commit 412a9711d7
4 changed files with 19 additions and 5 deletions

View file

@ -3,7 +3,7 @@
<div id="mt-form" class="form text-lg w-full">
<form id='form' hx-post="https://api.tfcconnection.org/camp-form" 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>

View file

@ -1,9 +1,7 @@
use std::fs;
use actix_multipart::form::{tempfile::TempFile, text::Text, MultipartForm};
use actix_multipart::form::{text::Text, MultipartForm};
use actix_web::{post, HttpResponse};
use lettre::{
message::{header::ContentType, Attachment, MultiPart, SinglePart},
message::MultiPart,
transport::smtp::authentication::{Credentials, Mechanism},
Message, SmtpTransport, Transport,
};
@ -35,6 +33,7 @@ struct CampForm {
#[post("/camp-form")]
pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResponse {
log::info!("a new form");
let first = form
.first_name
.as_ref()
@ -166,6 +165,7 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
})
.0
.clone();
let reg = registration.clone().as_str();
log::info!("{first} {last} signed up for camp!");
let email = markup::new! {
@markup::doctype()
@ -282,5 +282,19 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
log::info!("Email incorrect");
}
match reg {
"now" => {
log::info!("Sending them to pay for registration now");
}
"full" => {
log::info!("Sending them to pay for the full registration now");
}
"later" => {
log::info!("They'd like to pay later");
}
_ => {
log::error!("Got registration error.....");
}
}
HttpResponse::Ok().body("thankyou")
}