This commit is contained in:
Guillem George 2026-05-16 13:38:37 +02:00
parent 02ac670fe1
commit 814e559ccd
5 changed files with 132 additions and 32 deletions

View file

@ -1,5 +1,35 @@
// FIXME: This file should handle the students API
// Functions may include:
// - getStudent (get a student from the API by its uid or login)
// - getUserUidFromToken (get the user's uid from the token in local storage)
// - updateStudent (update the student's profile through the API)
import { authedAPIRequest } from "../utils/auth";
//get a student from the API by its uid or login
async function getStudent(login) {
if (!login) {
console.error("Cannot fetch an undefined student");
return;
}
const response = await authedAPIRequest("/students/" + login, {
method: "GET",
});
if (!response.ok) {
console.error("Could not retrieve student: " + response.statusText);
console.debug(await response.text());
return;
}
const res = await response.json();
console.debug(`Retrieved student ${login}:`);
console.debug(res);
// Update HTML
// const roomNameElt = document.getElementById("room-name");
// roomNameElt.innerText = res.metadata.name
}
//// get the user's uid from the token in local storage
async function getUserUidFromToken() {}
// update the student's profile through the API
async function updateStudent() {}
export { getStudent, getUserUidFromToken, updateStudent };