Skip to content

Commit

Permalink
no pembroke no pickup
Browse files Browse the repository at this point in the history
  • Loading branch information
TomConner committed Nov 22, 2023
1 parent 5ea8582 commit 467fab5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions generator/content/register/stripe-payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ document.addEventListener('DOMContentLoaded', async () => {

// on address input, save address in localStorage
addressElement.on('change', (event) => {
console.debug(event);//TODO REMOVE
if (event.complete){
// Extract potentially complete address
const address = event.value;
console.debug("address complete");
console.debug(address);
setLocalItem("address", JSON.stringify(address));
setLocalItem("address", JSON.stringify(address));
}
if (event.error) {
Expand All @@ -136,10 +140,22 @@ document.addEventListener('DOMContentLoaded', async () => {
}
});

function validateAddress() {
const address = JSON.parse(getLocalItem("address"));
if (address.address.city != "Pembroke".toLowerCase()) {
showAddressMessage("Sorry, we can only pick up trees from Pembroke.");
return false;
}
return true;
}

// on register button, post address and then hand off to payment choices
const buttonRegister = document.getElementById('button-register');
buttonRegister.addEventListener('click', async (e) => {
e.preventDefault();
if (!validateAddress()) {
return;
}
const address = JSON.parse(getLocalItem("address"));
const flat_address = address.address;
flat_address.name = address.name;
Expand Down

0 comments on commit 467fab5

Please sign in to comment.