Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
emyl3 committed Apr 1, 2024
1 parent 6dbe5d4 commit 9593897
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions pages/forms/waitlist-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ <h1 class="font-heading-xl text-primary-darker">{{ page.title }}</h1>
<div class="checkboxes" id="supported-diseases">
{% for disease in site.content.supported_diseases %}
<div class="usa-checkbox">
<input class="usa-checkbox__input form-input" type="checkbox" id="interested in {{disease}}" name="interested in {{disease}}" value="interested in {{disease}}">
<input class="usa-checkbox__input form-input" type="checkbox" id="interested in {{disease}}" name="interested in {{disease}}" value="{{disease}}">
<label class="usa-checkbox__label" for="interested in {{disease}}">{{disease}}</label>
</div>
{% endfor %}
</div>
<label class="usa-label" for="additional-conditions">If there are any additional conditions you would like to be able to report
<label class="usa-label" for="additional_conditions">If there are any additional conditions you would like to be able to report
using SimpleReport, please enter them below.</label>
<textarea
class="usa-textarea height-10 form-input"
id="additional-conditions"
name="additional-conditions"
id="additionalConditions"
name="additionalConditions"
></textarea>
<label class="usa-label" for="referral">How did you hear about us?</label>
<textarea
Expand Down Expand Up @@ -122,23 +122,28 @@ <h3 class="usa-alert__heading">Error</h3>

<script>
(function formLogic() {
console.log("form logic")
const form = document.getElementById("waitlist-form");
form.onsubmit = async (e) => {
e.preventDefault();
const fieldsToCheck = Array.from(document.getElementsByClassName("form-input"))
const data = {};
const diseaseInterest = [];
fieldsToCheck.forEach(
(element) => {
if(element.type === "checkbox"){
data[element.name] = element.checked;
}
if (element.type === "checkbox" && element.name.includes("interested in")){
if (element.checked) {
diseaseInterest.push(element.value);
}
}
else {
data[element.name] = element.value;
}
}
);

data.diseaseInterest = diseaseInterest;
try {
console.log(JSON.stringify(data));
let response = await fetch("/api/account-request/waitlist", {
method: "POST",
headers: {
Expand Down

0 comments on commit 9593897

Please sign in to comment.