Commit 3178869a authored by ibooking-sigurd's avatar ibooking-sigurd
Browse files

Add two small refactorings.

parent f921955d
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
<h5 class="mb-1"></h5> <h5 class="mb-1"></h5>
</div> </div>
<div class="d-flex"> <div class="d-flex">
<table class="mb-1 text-start"> <table aria-label="diet-table" class="mb-1 text-start">
<tr><th id="date">Date:</th><td></td></tr> <tr><th id="date">Date:</th><td></td></tr>
<tr><th id="time">Time:</th><td></td></tr> <tr><th id="time">Time:</th><td></td></tr>
<tr><th id="owner">Owner:</th><td></td></tr> <tr><th id="owner">Owner:</th><td></td></tr>
......
...@@ -5,8 +5,8 @@ async function displayCurrentRoster() { ...@@ -5,8 +5,8 @@ async function displayCurrentRoster() {
let currentUser = await getCurrentUser(); let currentUser = await getCurrentUser();
for (let athleteUrl of currentUser.athletes) { for (let athleteUrl of currentUser.athletes) {
let response = await sendRequest("GET", athleteUrl); let athleteResponse = await sendRequest("GET", athleteUrl);
let athlete = await response.json(); let athlete = await athleteResponse.json();
createFilledRow(templateFilledAthlete, athlete.username, controls, false); createFilledRow(templateFilledAthlete, athlete.username, controls, false);
} }
...@@ -22,8 +22,8 @@ async function displayCurrentRoster() { ...@@ -22,8 +22,8 @@ async function displayCurrentRoster() {
let offers = await response.json(); let offers = await response.json();
for (let offer of offers.results) { for (let offer of offers.results) {
let response = await sendRequest("GET", offer.recipient); let resultResponse = await sendRequest("GET", offer.recipient);
let recipient = await response.json(); let recipient = await resultResponse.json();
createFilledRow(templateFilledAthlete, `${recipient.username} (pending)`, controls, true); createFilledRow(templateFilledAthlete, `${recipient.username} (pending)`, controls, true);
} }
} }
...@@ -302,9 +302,9 @@ async function submitRoster() { ...@@ -302,9 +302,9 @@ async function submitRoster() {
body.athletes.push(athlete.id); body.athletes.push(athlete.id);
} else { } else {
// create offer // create offer
let body = { 'status': 'p', 'recipient': athlete.url }; let offerBody = { 'status': 'p', 'recipient': athlete.url };
let response = await sendRequest("POST", `${HOST}/api/offers/`, body); let offerResponse = await sendRequest("POST", `${HOST}/api/offers/`, offerBody);
if (!response.ok) { if (!offerResponse.ok) {
let data = await response.json(); let data = await response.json();
let alert = createAlert("Could not create offer!", data); let alert = createAlert("Could not create offer!", data);
document.body.prepend(alert); document.body.prepend(alert);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment