2025-11-17 18:56:31 -05:00
|
|
|
import { postData, verifyLogin } from "./client.js";
|
|
|
|
|
|
|
|
|
|
verifyLogin();
|
|
|
|
|
const token = window.localStorage.getItem("token");
|
|
|
|
|
|
|
|
|
|
const infoForm = document.getElementById("infoForm");
|
|
|
|
|
|
|
|
|
|
async function fetchPersonalInformation() {
|
2025-11-17 19:06:17 -05:00
|
|
|
const userData = await postData("https://project.rochesterx.dev/getInfo", {}, token);
|
2025-11-17 18:56:31 -05:00
|
|
|
|
|
|
|
|
console.log(userData);
|
|
|
|
|
|
|
|
|
|
document.getElementById("usernameField").textContent = userData.Username;
|
|
|
|
|
document.getElementById("firstNameField").value = userData.FirstName;
|
|
|
|
|
document.getElementById("lastNameField").value = userData.LastName;
|
|
|
|
|
document.getElementById("dobField").value = userData.DOB.split("T")[0];
|
|
|
|
|
|
|
|
|
|
return userData
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const userData = fetchPersonalInformation();
|
|
|
|
|
|
|
|
|
|
async function updatePersonalInformation(e) {
|
|
|
|
|
console.log(verifyLogin());
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
const userData = {
|
|
|
|
|
firstName: document.getElementById("firstNameField").value,
|
|
|
|
|
lastName: document.getElementById("lastNameField").value,
|
|
|
|
|
dob: document.getElementById("dobField").value
|
|
|
|
|
}
|
|
|
|
|
console.log(userData.dob);
|
2025-11-17 19:06:17 -05:00
|
|
|
const resultObject = await postData("https://project.rochesterx.dev/setInfo", userData, token);
|
2025-11-17 18:56:31 -05:00
|
|
|
alert(resultObject.message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
infoForm.onsubmit = updatePersonalInformation;
|