Update userprofile.html

This commit is contained in:
xfarrow
2025-03-24 12:18:05 +01:00
parent d005193f63
commit 836fc822a9
9 changed files with 262 additions and 829 deletions

View File

@@ -34,7 +34,7 @@
return;
}
const response = await fetch(`${API_URL}/persons/me/activation`, {
const response = await fetch(`${API_URL}/people/me/activation`, {
method: 'POST',
headers: createHeaders(null),
body: JSON.stringify({

View File

@@ -109,7 +109,7 @@
const password = document.getElementById("password").value;
const response = await fetch(`${API_URL}/persons/me/token`, {
const response = await fetch(`${API_URL}/people/me/token`, {
method: "POST",
body: JSON.stringify({
email: email,

View File

@@ -147,14 +147,12 @@
}),
};
fetch(`${API_URL}/persons`, options)
fetch(`${API_URL}/people`, options)
.then(response => {
response.json().then(data => {
if (response.ok) {
clearInputFields();
if (!data
.enabled
) { // is the user already enabled or do they need email verification?
if (!data.enabled) { // is the user already enabled or do they need email verification?
showSuccessAlert(
"Congratulations! You've successfully registered to Blink. " +
"Please click on the e-mail we sent you to confirm your account"

View File

@@ -9,9 +9,31 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css"
integrity="sha512-DTOQO9RWCH3ppGqcWaEA1BIZOC6xxalwEsw9c2QQeAIftl+Vegovlnee1c9QX4TctnWMn13TZye+giMm8e2LwA=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="../css/profile.css">
</head>
<body style="background-color: #ecf2fa; display: none;">
<!-- Navbar items -->
<div id="navlist">
<a href="#">Home</a>
<a href="#">Your Applications</a>
<a href="#">Your organizations</a>
<!-- search bar right align -->
<div class="search">
<form action="#">
<input type="text" placeholder="Search Blink"
name="search">
<button>
<i class="fa fa-search"></i>
</button>
</form>
</div>
</div>
<div class="container py-5">
<!-- Person's name + profile picture card -->
@@ -24,7 +46,8 @@
<h5 class="my-3" id="display-name">John Doe</h5>
<p class="text-muted mb-2" id="qualification">Full Stack Developer</p>
<p class="text-muted mb-4" id="place-of-living">New York City, United States of America</p>
<p class="text-muted mb-4" id="about-me"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
<p class="text-muted mb-4" id="about-me"> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit
esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa
@@ -175,8 +198,8 @@
</div>
</div>
<script src="../../js/constants.js"></script>
<script src="../../js/utils.js"></script>
<script src="../js/constants.js"></script>
<script src="../js/utils.js"></script>
<script>
window.addEventListener("load", async function () {
loadProfile();
@@ -194,18 +217,21 @@
if (!token) {
window.location.href = 'login.html';
}
response = await fetch(`${API_URL}/persons/me`, {
response = await fetch(`${API_URL}/people/me`, {
headers: createHeaders(token)
});
} else {
response = await fetch(`${API_URL}/persons/${idToDisplay}/details`, {
}
// If it's someone else
else {
response = await fetch(`${API_URL}/people/${idToDisplay}/details`, {
headers: createHeaders(null)
});
}
const data = await response.json();
if (response.ok) {
populateFields(data.display_name, data.email, data.about_me, data.qualification, data.place_of_living);
populateFields(data.display_name, data.about_me, data.qualification, data.place_of_living);
document.body.style.display = 'block'; // Show page
} else if (response.status == 401) {
window.location.href = 'login.html';
@@ -214,10 +240,9 @@
}
}
function populateFields(displayName, email, aboutMe, qualification, placeOfLiving) {
function populateFields(displayName, aboutMe, qualification, placeOfLiving) {
document.getElementById('display-name').textContent = displayName;
document.title = `${displayName} - Blink`
document.getElementById('email').textContent = email;
document.getElementById('about-me').textContent = aboutMe;
document.getElementById('qualification').textContent = qualification;
document.getElementById('place-of-living').textContent = placeOfLiving;