-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from djangocon/add-invitation
Starts in on invitation page
- Loading branch information
Showing
3 changed files
with
227 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
const form = document.getElementById("inviteForm"); | ||
form.addEventListener("submit", start); | ||
|
||
const loader = document.getElementById("loader"); | ||
|
||
function displayLoading() { | ||
loader.hidden = false; | ||
} | ||
|
||
function hideLoading() { | ||
loader.hidden = true; | ||
} | ||
|
||
async function start(ev) { | ||
ev.preventDefault(); | ||
|
||
console.log("start form"); | ||
|
||
// Show in progress message | ||
const inProgressMsg = document.getElementById("inProgressMsg"); | ||
inProgressMsg.hidden = false; | ||
|
||
const form = new FormData(ev.target);; | ||
|
||
const { | ||
fullname, | ||
address, | ||
email, | ||
dob, | ||
letterselection: lettertype, | ||
og, | ||
talk: speaker, | ||
passport_no | ||
} = Object.fromEntries(form); | ||
|
||
let data; | ||
|
||
displayLoading(); | ||
|
||
if (lettertype == "none") { | ||
data = { | ||
"fullname": fullname, | ||
"address": address, | ||
"email": email, | ||
"dob": dob, | ||
"passport_no": passport_no | ||
} | ||
} else if (lettertype == "og") { | ||
data = { | ||
"fullname": fullname, | ||
"address": address, | ||
"email": email, | ||
"dob": dob, | ||
"passport_no": passport_no, | ||
"letteropt": { | ||
"key": "og", | ||
"value": og | ||
} | ||
}; | ||
} else if (lettertype == "speaker") { | ||
data = { | ||
"fullname": fullname, | ||
"address": address, | ||
"email": email, | ||
"dob": dob, | ||
"passport_no": passport_no, | ||
"letteropt": { | ||
"key": "speaker", | ||
"value": speaker | ||
} | ||
}; | ||
} | ||
|
||
displayLoading(); | ||
|
||
const formElem = document.getElementById("inviteForm"); | ||
formElem.hidden = true; | ||
|
||
await fetch('https://djc-invitation-letter-api-noahalorwu.vercel.app/invitation', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
body: JSON.stringify(data) | ||
}).then(res => res.json()).then(data => { | ||
hideLoading(); | ||
console.log(data); | ||
inProgressMsg.hidden = true; | ||
document.getElementById("readyMsg").hidden = false; | ||
}); | ||
} | ||
|
||
// Update fields shown dependent upon attendee type | ||
document.addEventListener("DOMContentLoaded", function() { | ||
document.getElementById("letterselection").addEventListener("change", function() { | ||
let selected = this.value; | ||
|
||
const ogElem = document.getElementById("og"); | ||
const speakerElem = document.getElementById("speaker"); | ||
|
||
if (selected == "none") { | ||
ogElem.hidden = true; | ||
speakerElem.hidden = true; | ||
} | ||
else if (selected == "og") { | ||
ogElem.hidden = false; | ||
speakerElem.hidden = true; | ||
} | ||
else if (selected == "speaker") { | ||
ogElem.hidden = true; | ||
speakerElem.hidden = false; | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
layout: default | ||
|
||
description: > | ||
Request your visa invitation letter for DjangoCon US 2024 here. | ||
|
||
title: Visa Invitation Letter | ||
|
||
permalink: /invitation/ | ||
--- | ||
|
||
<div class="bg-gray-100 block-container"> | ||
<div class="wrapper"> | ||
<h1 class="mb-6 text-center pageheading">{{ title }}</h1> | ||
<form | ||
class="max-w-2xl p-4 mx-auto bg-white rounded lg:p-12" | ||
id="inviteForm" | ||
method="POST" | ||
enctype="multipart/form-data"> | ||
<ul class="space-y-8"> | ||
<li> | ||
<label for="fullname">Full name (as it appears on your passport)</label> | ||
<input type="text" name="fullname" id="fullname" placeholder="Noah Doe" required> | ||
</li> | ||
<li> | ||
<label for="address">Address</label> | ||
<input type="text" name="address" id="address" placeholder="125 32nd Street, Durham, North Carolina, USA" required> | ||
</li> | ||
<li> | ||
<label for="dob">Date of Birth</label> | ||
<input type="text" name="dob" id="dob" placeholder="July 09 1990" required> | ||
</li> | ||
<li> | ||
<label for="email">Email</label> | ||
<input type="email" name="email" id="email" placeholder="[email protected]" required> | ||
</li> | ||
<li> | ||
<label for="passport_no">Passport Number</label> | ||
<input type="text" name="passport_no" id="passport_no" placeholder="A01923459B" required> | ||
</li> | ||
<li> | ||
<label for="letterselection">Are you a Speaker, an Opportunity Grant recipient, or a general attendee?</label> | ||
<select name="letterselection" id="letterselection" required> | ||
<option value="none">Attendee</option> | ||
<option value="og">Opportunity Grant recipient</option> | ||
<option value="speaker">Speaker</option> | ||
</select> | ||
</li> | ||
<li id="og" hidden> | ||
<label for="og">Grant Amount (if applicable)</label> | ||
<input type="number" name="og" id="og" placeholder="2000.00"> | ||
</li> | ||
<li id="speaker" hidden> | ||
<label for="talk">Talk/Tutorial Title</label> | ||
<input type="text" name="talk" id="talk" placeholder="DjangoCon US is the best!"> | ||
</li> | ||
</ul> | ||
|
||
<div class="mt-8"> | ||
<button id="submit" type="submit" class="button bg-mosaic-blue">Submit</button> | ||
</div> | ||
</form> | ||
|
||
<div> | ||
<div id="loader" hidden></div> | ||
<p id="inProgressMsg" hidden class="max-w-2xl p-4 mx-auto text-lg bg-white border-4 rounded lg:p-12 text-medium lg:text-xl border-central-park-green"> | ||
Thank you for your interest in DjangoCon US 2024! We're generating your invitation letter. | ||
</p> | ||
<p id="readyMsg" hidden class="max-w-2xl p-4 mx-auto text-lg bg-white border-4 rounded lg:p-12 text-medium lg:text-xl border-central-park-green">Your invitation letter has been sent to the DjangoCon US organizers for review. Once they approve it, they will email it to you. Thanks for your interest!</p> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<script src="/assets/js/invitation.js"></script> |