From 033401dbf7d1decb9373e2b88fe14e92d24a4be2 Mon Sep 17 00:00:00 2001 From: SowinskiBraeden Date: Tue, 6 May 2025 11:15:18 -0700 Subject: [PATCH] update/profile page with user data --- src/public/scripts/profile.js | 57 +++++++++++++++++++++++ src/router/user.js | 2 +- src/views/profile.ejs | 85 +++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+), 1 deletion(-) create mode 100644 src/public/scripts/profile.js create mode 100644 src/views/profile.ejs diff --git a/src/public/scripts/profile.js b/src/public/scripts/profile.js new file mode 100644 index 0000000..f1406e6 --- /dev/null +++ b/src/public/scripts/profile.js @@ -0,0 +1,57 @@ +/** + * unlockAccount removes disabled from inputs and + * allows users to edit their profile. + */ +function unlockAccount() { + document.getElementById("save-account").disabled = false; + document.getElementById("email").disabled = false; + document.getElementById("name").disabled = false; + document.getElementById("password").disabled = false; + document.getElementById("repassword").disabled = false; + document.getElementById("save-account").classList.remove("cursor-not-allowed"); +} + +/** + * unlocPersonal removes disabled from inputs and + * allows users to edit their personal information. + */ +function unlockPersonal() { + document.getElementById("save-personal").disabled = false; + document.getElementById("dob").disabled = false; + document.getElementById("education").disabled = false; + document.getElementById("ms-single").disabled = false; + document.getElementById("ms-married").disabled = false; + document.getElementById("ms-divorced").disabled = false; + document.getElementById("ms-widowed").disabled = false; + document.getElementById("save-personal").classList.remove("cursor-not-allowed"); +} + +/** + * lockAll makes all inputs disabled on page load + */ +function lockAll() { + // Clear unsaved inputs on page load (refresh doesnt clear them) + document.getElementById("account-form").reset(); + document.getElementById("personal-form").reset(); + + // Account section + document.getElementById("save-account").disabled = true; + document.getElementById("email").disabled = true; + document.getElementById("name").disabled = true; + document.getElementById("password").disabled = true; + document.getElementById("repassword").disabled = true; + document.getElementById("save-account").classList.add("cursor-not-allowed"); + + // Personal info section + document.getElementById("save-personal").disabled = true; + document.getElementById("dob").disabled = true; + document.getElementById("education").disabled = true; + document.getElementById("ms-single").disabled = true; + document.getElementById("ms-married").disabled = true; + document.getElementById("ms-divorced").disabled = true; + document.getElementById("ms-widowed").disabled = true; + document.getElementById("save-personal").classList.add("cursor-not-allowed"); + +} + +lockAll() diff --git a/src/router/user.js b/src/router/user.js index dd8eaf6..314fdf8 100644 --- a/src/router/user.js +++ b/src/router/user.js @@ -27,7 +27,7 @@ module.exports = (middleware, users) => { }); router.get('/profile', (req, res) => { - res.render('profiles', { user: req.user }); + res.render('profile', { user: req.user }); return res.status(status.Ok); }); diff --git a/src/views/profile.ejs b/src/views/profile.ejs new file mode 100644 index 0000000..dbb8a41 --- /dev/null +++ b/src/views/profile.ejs @@ -0,0 +1,85 @@ +<%- include("./partials/fileHeader") %> +<%- include("./partials/header") %> + +
+

Welcome: <%= user.name %>

+
+
+

Account settings

+ +
+
+ + + + + + + + + + + + + +
+ +
+
+
+ +
+
+

Personal information

+ +
+
+
+ + +
+
+ + +
+ +
+ +
+ + + + +
+
+ +
+ +
+
+
+ +
+
+ + + +<%- include("./partials/navBar") %> +<%- include("./partials/footer") %> \ No newline at end of file