Commit 30002907 authored by Erlend Ydse's avatar Erlend Ydse
Browse files

Remove unused functions

parent ef6e9a68
async function fetchFriendRequests() {
const response = await sendRequest("GET", `${HOST}/friends/friend-requests/`);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
} else {
let data = await response.json();
let friendRequests = data.results;
return friendRequests;
}
}
/**
*
* @param {String} username
......@@ -59,40 +46,6 @@ async function addFriend(url) {
}
}
/**
*
* @param {{name: String, id: Number, date: Date}[]} friendRequests
*/
function renderFriendRequests(friendRequests) {
const container = document.getElementById("div-friend-requests");
friendRequests.forEach((friendRequest) => {
const templateFriendRequest = document.getElementById(
"template-friend-request"
);
const cloneFriendRequest = templateFriendRequest.content.cloneNode(true);
const h5 = cloneFriendRequest.querySelector("h5");
h5.textContent = friendRequest.name;
const a = cloneFriendRequest.querySelector("a");
a.href = `profile.html?id=${friendRequest.id}`;
const acceptButton = cloneFriendRequest.getElementById("btn-accept");
acceptButton.id = `btn-accept-friend-${friendRequest.id}`;
acceptButton.addEventListener("click", async (event) =>
addFriend(friendRequest.id)
);
const rejectButton = cloneFriendRequest.getElementById("btn-reject");
rejectButton.id = `btn-reject-friend-${friendRequest.id}`;
rejectButton.addEventListener("click", (event) =>
rejectFriend(friendRequest.id)
);
container.appendChild(cloneFriendRequest);
});
}
/**
*
* @param {string[]} friends
......
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