From 70c0a55386c2aaae85758c038f154237ce0e4375 Mon Sep 17 00:00:00 2001 From: singharaj usai Date: Tue, 8 Oct 2024 23:30:07 -0400 Subject: [PATCH] user profile stats --- client/js/user-profile.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/client/js/user-profile.js b/client/js/user-profile.js index 1bcc32f..8822eb9 100644 --- a/client/js/user-profile.js +++ b/client/js/user-profile.js @@ -122,6 +122,7 @@ $(document).ready(function () { }
${actionButton}
+ `; @@ -129,6 +130,22 @@ $(document).ready(function () { $("#user-info").html(userInfoHtml); + const statisticsHtml = ` +
+
+

User Statistics

+
+
+

Last Seen: ${formatDate(user.lastLoggedIn)}

+

Join Date: ${formatDate(user.signupDate)}

+

Place Visits:0

+
+
+ `; + + $("#user-info").append(statisticsHtml); + + // Fetch and display friends list fetchFriendsList(user.username); // Call the new function to display the items panel @@ -450,3 +467,15 @@ $(document).ready(function () { .replace(/'/g, "'"); } }); + +function formatDate(dateString) { + if (!dateString) return 'N/A'; + const date = new Date(dateString); + return date.toLocaleString('en-US', { + year: 'numeric', + month: 'long', + day: 'numeric', + hour: '2-digit', + minute: '2-digit' + }); +}