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

Add two small refactorings.

parent f921955d
......@@ -45,7 +45,7 @@
<h5 class="mb-1"></h5>
</div>
<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="time">Time:</th><td></td></tr>
<tr><th id="owner">Owner:</th><td></td></tr>
......
......@@ -5,8 +5,8 @@ async function displayCurrentRoster() {
let currentUser = await getCurrentUser();
for (let athleteUrl of currentUser.athletes) {
let response = await sendRequest("GET", athleteUrl);
let athlete = await response.json();
let athleteResponse = await sendRequest("GET", athleteUrl);
let athlete = await athleteResponse.json();
createFilledRow(templateFilledAthlete, athlete.username, controls, false);
}
......@@ -22,8 +22,8 @@ async function displayCurrentRoster() {
let offers = await response.json();
for (let offer of offers.results) {
let response = await sendRequest("GET", offer.recipient);
let recipient = await response.json();
let resultResponse = await sendRequest("GET", offer.recipient);
let recipient = await resultResponse.json();
createFilledRow(templateFilledAthlete, `${recipient.username} (pending)`, controls, true);
}
}
......@@ -302,9 +302,9 @@ async function submitRoster() {
body.athletes.push(athlete.id);
} else {
// create offer
let body = { 'status': 'p', 'recipient': athlete.url };
let response = await sendRequest("POST", `${HOST}/api/offers/`, body);
if (!response.ok) {
let offerBody = { 'status': 'p', 'recipient': athlete.url };
let offerResponse = await sendRequest("POST", `${HOST}/api/offers/`, offerBody);
if (!offerResponse.ok) {
let data = await response.json();
let alert = createAlert("Could not create offer!", data);
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