2026-05-16 13:38:37 +02:00
|
|
|
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 };
|