recreate project
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
// initials.js
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
function getInitials(firstName, lastName) {
|
||||
if (firstName && lastName) {
|
||||
return firstName.charAt(0) + lastName.charAt(0);
|
||||
}
|
||||
return 'N/A';
|
||||
}
|
||||
|
||||
fetchUserData()
|
||||
.then(data => {
|
||||
if (data.error) {
|
||||
document.getElementById('user-name').textContent = 'Guest';
|
||||
document.getElementById('profile-picture').textContent = 'G';
|
||||
} else {
|
||||
const firstName = data.firstname || 'N/A';
|
||||
const lastName = data.lastname || 'N/A';
|
||||
document.getElementById('user-name').textContent = firstName + ' ' + lastName;
|
||||
document.getElementById('profile-picture').textContent = getInitials(firstName, lastName);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching user data:', error);
|
||||
document.getElementById('user-name').textContent = 'Error loading user data';
|
||||
document.getElementById('profile-picture').textContent = 'E';
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user