45 lines
1.0 KiB
Plaintext
45 lines
1.0 KiB
Plaintext
---
|
|
import Base from "../partials/base.astro";
|
|
|
|
|
|
let email_error = false;
|
|
let addr_error = false;
|
|
|
|
// form submission
|
|
if (Astro.request.method === "POST") {
|
|
try {
|
|
const data = await Astro.request.formData()
|
|
const email = data.get("email")
|
|
const addr = data.get("address")
|
|
|
|
/*
|
|
some logic to process the order
|
|
...
|
|
*/
|
|
if (email == "") {
|
|
email_error = true
|
|
}
|
|
if (addr == "") {
|
|
addr_error = true
|
|
}
|
|
|
|
if (!email_error && !addr_error) {
|
|
console.log("Order from:", email, "who was in funnel:", Astro.locals.split);
|
|
return Astro.redirect("/thank_you")
|
|
}
|
|
} catch (error) {
|
|
console.log(error)
|
|
}
|
|
}
|
|
|
|
---
|
|
<Base title="Checkout" desc="$$$">
|
|
<h1>Checkout</h1>
|
|
|
|
<form method="post">
|
|
<input name="email" placeholder="Email" type="email">
|
|
<input name="address" placeholder="Mailing Address" type="text">
|
|
<button type="submit">Submit</button>
|
|
</form>
|
|
|
|
</Base> |