Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03c3f9a610 | ||
|
|
9b998078b7 | ||
|
|
b944c37c02 | ||
|
|
6d91934229
|
||
|
|
97a1473e21
|
||
|
|
3bb9ede515
|
||
|
|
b350cdad9f
|
||
|
|
f0d324151d
|
||
|
|
b88333e3b4
|
||
|
|
75bc3bee8f
|
||
|
|
a2b4e8d36d
|
||
|
|
033401dbf7
|
||
|
|
1d8ec431b2
|
||
|
|
4050e95cc3 | ||
|
|
ae3ddbeaeb | ||
|
|
84cd8b0bae | ||
|
|
5684e96a79 | ||
|
|
1e32ccfa17 |
No files matched your search
@@ -3,8 +3,10 @@ const MongoStore = require("connect-mongo");
|
||||
const session = require("express-session");
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
const joi = require('joi');
|
||||
require('dotenv').config();
|
||||
|
||||
|
||||
const app = express();
|
||||
const port = process.env.PORT || 3000;
|
||||
|
||||
@@ -18,7 +20,7 @@ app.use(session({
|
||||
store: MongoStore.create({ mongoUrl: `${mongoURI}${database}`, crypto: { secret: secret } }),
|
||||
resave: true,
|
||||
saveUninitialized: false,
|
||||
cookie: { maxAge: 60000 },
|
||||
cookie: { maxAge: 3600000 },
|
||||
}));
|
||||
|
||||
app.set('view engine', 'ejs');
|
||||
@@ -36,6 +38,7 @@ async function initDatabase() {
|
||||
|
||||
// For any collection, init here
|
||||
users = await getCollection(db, "users");
|
||||
plans = await getCollection(db, "plans");
|
||||
}
|
||||
|
||||
/*** ROUTINGS ***/
|
||||
@@ -47,6 +50,8 @@ app.get('/', (req, res) => {
|
||||
});
|
||||
|
||||
app.get('/signup', (req, res) => {
|
||||
const ignore = ["User not found", "Incorrect password"];
|
||||
if (ignore.includes(req.session.errMessage)) req.session.errMessage = "";
|
||||
res.render('signup', { errMessage: req.session.errMessage });
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
@@ -74,8 +79,8 @@ initDatabase().then(() => {
|
||||
app.use(require("./src/auth/authentication")(users));
|
||||
|
||||
// Import middleware & apply to user routes
|
||||
const middleware = require("./src/auth/middleware")(users);
|
||||
app.use(require('./src/router/user')(middleware));
|
||||
const middleware = require("./src/auth/middleware")(users, plans);
|
||||
app.use(require('./src/router/user')(middleware, users, plans));
|
||||
|
||||
// 404 handler
|
||||
app.get('/*splat', (req, res) => {
|
||||
|
||||
@@ -8,17 +8,11 @@ module.exports = (users) => {
|
||||
|
||||
router.get("/logout", (req, res) => {
|
||||
req.session.destroy();
|
||||
// res.status(status.Unauthorized);
|
||||
return res.redirect('/login');
|
||||
});
|
||||
|
||||
router.post("/login", async (req, res) => {
|
||||
|
||||
if (req.session.authenticated) {
|
||||
res.redirect("/home");
|
||||
return res.status(status.Ok);
|
||||
}
|
||||
|
||||
|
||||
const credentialSchema = joi.object({
|
||||
email: joi.string().email().required(),
|
||||
password: joi.string().max(20).required(),
|
||||
@@ -46,8 +40,8 @@ module.exports = (users) => {
|
||||
}
|
||||
|
||||
req.session.authenticated = true;
|
||||
req.session.userId = user._id;
|
||||
req.session.email = req.body.email;
|
||||
|
||||
req.session.errMessage = "";
|
||||
res.redirect("/home");
|
||||
return res.status(status.Ok);
|
||||
@@ -57,7 +51,7 @@ module.exports = (users) => {
|
||||
router.post("/signup", async (req, res) => {
|
||||
const userSchema = joi.object({
|
||||
email: joi.string().email().required(),
|
||||
// name: joi.string().alphanum().max(20).required(),
|
||||
name: joi.string().alphanum().max(20).required(),
|
||||
password: joi.string().max(20).min(8).required(),
|
||||
repassword: joi.string().max(20).min(8).required(),
|
||||
});
|
||||
@@ -80,21 +74,21 @@ module.exports = (users) => {
|
||||
|
||||
users.insertOne({
|
||||
email: req.body.email,
|
||||
// name: req.body.name,
|
||||
name: req.body.name,
|
||||
password: hashedPassword,
|
||||
}).then((results, err) => {
|
||||
if (err) {
|
||||
res.status(status.InternalServerError);
|
||||
console.error(err);
|
||||
return res.send("Internal server error");
|
||||
res.session.errMessage = "Internal server error";
|
||||
return res.status(status.InternalServerError).redirect("/signup");
|
||||
}
|
||||
|
||||
req.session.authenticated = true;
|
||||
req.session.email = req.body.email;
|
||||
req.session.userId = results.insertedId;
|
||||
|
||||
req.session.errMessage = "";
|
||||
res.status(status.Ok);
|
||||
return res.redirect("/home");
|
||||
return res.status(status.Ok).redirect("/home");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const status = require("../util/statuses");
|
||||
const session = require("express-session");
|
||||
|
||||
/**
|
||||
* createMiddleware returns a middleware function for express.
|
||||
|
||||
@@ -16,6 +16,7 @@ const connectMongo = async (mongoURI, databaseName) => {
|
||||
* getCollection object to interact with MongoDB
|
||||
* @param {MongoClient} dbo
|
||||
* @param {string} collection
|
||||
* @return {MongoClient.collection}
|
||||
*/
|
||||
const getCollection = async (dbo, collection) => {
|
||||
return await dbo.collection(collection);
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* lockAccount resets inputs and disabled inputs
|
||||
*/
|
||||
function lockAccount() {
|
||||
// Clear unsaved inputs on page load (refresh doesnt clear them)
|
||||
document.getElementById("account-form").reset();
|
||||
|
||||
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");
|
||||
|
||||
document.getElementById("edit-account").innerHTML = "Edit";
|
||||
document.getElementById("edit-account").onclick = unlockAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* lockPersonal resets inputs and disabled inputs
|
||||
*/
|
||||
function lockPersonal() {
|
||||
// Clear unsaved inputs on page load (refresh doesnt clear them)
|
||||
document.getElementById("personal-form").reset();
|
||||
|
||||
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");
|
||||
|
||||
document.getElementById("edit-personal").innerHTML = "Edit";
|
||||
document.getElementById("edit-personal").onclick = unlockPersonal;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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");
|
||||
|
||||
document.getElementById("edit-account").innerHTML = "Cancel changes";
|
||||
document.getElementById("edit-account").onclick = lockAccount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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");
|
||||
|
||||
document.getElementById("edit-personal").innerHTML = "Cancel changes";
|
||||
document.getElementById("edit-personal").onclick = lockPersonal;
|
||||
}
|
||||
|
||||
// On page load, ensure forms are locked and reset
|
||||
lockAccount();
|
||||
// lockPersonal();
|
||||
+190
-8
@@ -1,6 +1,9 @@
|
||||
const status = require("../util/statuses");
|
||||
const bcrypt = require('bcrypt');
|
||||
const joi = require("joi");
|
||||
const salt = 12;
|
||||
|
||||
module.exports = (middleware) => {
|
||||
module.exports = (middleware, users, plans) => {
|
||||
const router = require("express").Router();
|
||||
|
||||
router.use(middleware);
|
||||
@@ -15,18 +18,85 @@ module.exports = (middleware) => {
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
router.get('/plans', (req, res) => {
|
||||
res.render('plans', { user: req.user });
|
||||
return res.status(status.Ok);
|
||||
router.get('/plans', async (req, res) => {
|
||||
if (!req.session.email) {
|
||||
return res.status(status.Unauthorized).redirect('/login');
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
// console.log(req.user.email);
|
||||
const userPlans = await plans.find({userEmail: req.user.email }).toArray();
|
||||
// console.log(userPlans);
|
||||
res.render('plans', {
|
||||
user: req.user,
|
||||
plans: userPlans
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
console.error("Error fetching plans:", err);
|
||||
req.session.errMessage = "Could not load your plans. Please try again.";
|
||||
res.status(status.InternalServerError).redirect('/home');
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/newPlan', (req, res) => {
|
||||
const errMessage = req.session.errMessage;
|
||||
req.session.errMessage = "";
|
||||
res.render('newPlan', { user: req.user, errMessage: errMessage });
|
||||
});
|
||||
|
||||
router.post('/newPlan', async (req, res) => {
|
||||
if (!req.session.email) {
|
||||
return res.status(status.Unauthorized).redirect('/login');
|
||||
}
|
||||
|
||||
const planSchema = joi.object({
|
||||
name: joi.string().min(3).max(100).required(),
|
||||
retirementAge: joi.number().min(18).max(120).required(),
|
||||
retirementExpenses: joi.number().min(0).required(),
|
||||
retirementAssets: joi.number().min(0).required(),
|
||||
retirementLiabilities: joi.number().min(0).required(),
|
||||
});
|
||||
|
||||
const validationOptions = { convert: true, abortEarly: false };
|
||||
const { error, value } = planSchema.validate(req.body, validationOptions);
|
||||
|
||||
if (error) {
|
||||
console.error("Plan validation error:", error.details);
|
||||
req.session.errMessage = "Invalid input: " + error.details.map(d => d.message.replace(/"/g, '')).join(', ');
|
||||
res.status(status.BadRequest).redirect("/newPlan");
|
||||
return;
|
||||
}
|
||||
const newPlan = {
|
||||
userEmail: req.user.email,
|
||||
name: value.name,
|
||||
retirementAge: value.retirementAge,
|
||||
retirementExpenses: value.retirementExpenses,
|
||||
retirementAssets: value.retirementAssets,
|
||||
retirementLiabilities: value.retirementLiabilities,
|
||||
progress: "0%"
|
||||
};
|
||||
|
||||
try{
|
||||
await plans.insertOne(newPlan);
|
||||
req.session.errMessage = "";
|
||||
res.redirect('/plans');
|
||||
}
|
||||
catch(err){
|
||||
console.error("Error saving plan:", err);
|
||||
req.session.errMessage = "An error occurred while saving your plan. Please try again.";
|
||||
res.status(status.InternalServerError).redirect("/newPlan");
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/more', (req, res) => {
|
||||
res.render('more', { user: req.user });
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
router.get('/profile', (req, res) => {
|
||||
res.render('profiles', { user: req.user });
|
||||
res.render('profile', { user: req.user, errMessage: req.session.errMessage });
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
@@ -35,9 +105,121 @@ module.exports = (middleware) => {
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
router.get('/logout', (req, res) => {
|
||||
req.session.destroy();
|
||||
return res.redirect('/login');
|
||||
router.get('/questionnaire', (req, res) => {
|
||||
const errMessage = req.session.errMessage;
|
||||
req.session.errMessage = "";
|
||||
res.render('questionnaire', { user: req.user, errMessage: errMessage });
|
||||
});
|
||||
|
||||
router.post('/questionnaire', (req, res) => {
|
||||
// console.log("Questionnaire POST body:", req.body);
|
||||
|
||||
const questionnaireSchema = joi.object({
|
||||
dob: joi.date().required(),
|
||||
education: joi.string().valid('primary', 'secondary', 'tertiary', 'postgraduate').required(),
|
||||
maritalStatus: joi.string().valid('single', 'married', 'divorced', 'widowed').required(),
|
||||
income: joi.number().min(0).required(),
|
||||
expenses: joi.number().min(0).required(),
|
||||
assets: joi.number().min(0).required(),
|
||||
liabilities: joi.number().min(0).required(),
|
||||
});
|
||||
|
||||
const validationOptions = { convert: true, abortEarly: false };
|
||||
const { error, value } = questionnaireSchema.validate(req.body, validationOptions);
|
||||
|
||||
if (error) {
|
||||
console.error("Questionnaire validation error:", error.details);
|
||||
req.session.errMessage = "Invalid input: " + error.details.map(d => d.message.replace(/"/g, '')).join(', ');
|
||||
res.status(status.BadRequest).redirect("/questionnaire");
|
||||
return;
|
||||
}
|
||||
|
||||
users.updateOne(
|
||||
{ email: req.session.email },
|
||||
{
|
||||
$set: {
|
||||
financialData: true,
|
||||
dob: value.dob,
|
||||
education: value.education,
|
||||
maritalStatus: value.maritalStatus,
|
||||
income: value.income,
|
||||
expenses: value.expenses,
|
||||
assets: value.assets,
|
||||
liabilities: value.liabilities,
|
||||
}
|
||||
}
|
||||
).then((result) => {
|
||||
if (result.matchedCount === 0) {
|
||||
console.log(`User not found during questionnaire update: ${req.session.email}`);
|
||||
req.session.errMessage = "User session invalid. Please log in again.";
|
||||
res.status(status.NotFound).redirect("/login");
|
||||
return;
|
||||
}
|
||||
if (result.modifiedCount === 0 && result.matchedCount === 1) {
|
||||
console.log(`User questionnaire data unchanged (already up-to-date): ${req.session.email}`);
|
||||
}
|
||||
|
||||
req.session.errMessage = "";
|
||||
res.status(status.Ok).redirect("/home");
|
||||
|
||||
}).catch(err => {
|
||||
console.error("Error updating questionnaire in database:", err);
|
||||
req.session.errMessage = "An error occurred while saving your information. Please try again.";
|
||||
res.status(status.InternalServerError).redirect("/questionnaire");
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/updateAccount", async (req, res) => {
|
||||
const accountSchema = joi.object({
|
||||
email: joi.string().email(),
|
||||
name: joi.string().alphanum().max(20),
|
||||
password: joi.string().max(20).min(8),
|
||||
repassword: joi.string().max(20).min(8),
|
||||
});
|
||||
|
||||
const valid = accountSchema.validate(req.body);
|
||||
|
||||
if (valid.err) {
|
||||
req.session.errMessage = "Invalid input",
|
||||
res.status(status.BadRequest);
|
||||
return res.redirect("/profile");
|
||||
}
|
||||
|
||||
let update = {
|
||||
// email: req.body.email,
|
||||
name: req.body.name,
|
||||
};
|
||||
|
||||
if ((req.body.password != "") && (req.body.password != req.body.repassword)) {
|
||||
req.session.errMessage = "New passwords must match";
|
||||
res.status(status.BadRequest);
|
||||
return res.redirect("/profile");
|
||||
} else if (req.body.password != "") {
|
||||
let hashedPassword = await bcrypt.hashSync(req.body.password, salt);
|
||||
update.password = hashedPassword;
|
||||
}
|
||||
|
||||
users.updateOne(
|
||||
{ email: req.session.email },
|
||||
{ $set: update }
|
||||
).then((result) => {
|
||||
if (result.matchedCount === 0) {
|
||||
console.log(`User not found during account update: ${req.session.email}`);
|
||||
req.session.errMessage = "User session invalid. Please log in again.";
|
||||
res.status(status.NotFound).redirect("/login");
|
||||
return;
|
||||
}
|
||||
if (result.modifiedCount === 0 && result.matchedCount === 1) {
|
||||
console.log(`User account data unchanged (already up-to-date): ${req.session.email}`);
|
||||
}
|
||||
|
||||
req.session.errMessage = "";
|
||||
return res.status(status.Ok).redirect("/profile");
|
||||
}).catch(err => {
|
||||
console.error("Error updating account in database:", err);
|
||||
req.session.errMessage = "An error occurred while saving your information. Please try again.";
|
||||
return res.status(status.InternalServerError).redirect("/profile");
|
||||
});
|
||||
});
|
||||
|
||||
return router;
|
||||
|
||||
+6
-1
@@ -2,9 +2,14 @@
|
||||
<%- include("./partials/header") %>
|
||||
|
||||
<main>
|
||||
<%- include("./partials/header") %>
|
||||
Welcome: <%= user.email %>
|
||||
The Dashboard Page
|
||||
<% if(user.authenticated) { %>
|
||||
<%= user.email %>
|
||||
<%= user.errMessage %>
|
||||
<% } %>
|
||||
</main>
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/footer") %>
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -0,0 +1,40 @@
|
||||
<%- include("./partials/fileHeader") %>
|
||||
<%- include("./partials/header") %>
|
||||
|
||||
<main class="container mx-auto p-4">
|
||||
<h2 class="text-xl font-semibold mb-4">Welcome: <%= user.email %></h2>
|
||||
<div class="max-w-md mx-auto bg-white p-8 mb-10 rounded-lg shadow-md">
|
||||
<h3 class="text-lg font-medium mb-6">Financial Questionnaire</h3>
|
||||
<form action="/newPlan" method="post" class="space-y-4">
|
||||
<div>
|
||||
<label for="name" class="block text-sm font-medium text-gray-700">Plan Name</label>
|
||||
<input type="text" name="name" placeholder="e.g., Retirement Plan" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label for="retirementAge" class="block text-sm font-medium text-gray-700">Desired Retirement Age</label>
|
||||
<input type="number" name="retirementAge" placeholder="e.g., 65" min="18" max="120" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="retirementExpenses" class="block text-sm font-medium text-gray-700">Estimated Monthly Retirement Expenses</label>
|
||||
<input type="number" name="retirementExpenses" min="0" placeholder="e.g., 3000" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="retirementAssets" class="block text-sm font-medium text-gray-700">Estimated Retirement Assets</label>
|
||||
<input type="number" name="retirementAssets" min="0" placeholder="e.g., 500000" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="retirementLiabilities" class="block text-sm font-medium text-gray-700">Estimated Retirement Liabilities</label>
|
||||
<input type="number" name="retirementLiabilities" min="0" placeholder="e.g., 50000" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">Save Plan</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<%- include("./partials/footer") %>
|
||||
+17
-2
@@ -1,8 +1,23 @@
|
||||
<%- include("./partials/fileHeader") %>
|
||||
<%- include("./partials/header") %>
|
||||
|
||||
<main>
|
||||
The Plans Page
|
||||
<main class="container mx-auto p-4">
|
||||
<h2 class="text-xl text-white font-semibold mb-4">Welcome: <%= user.email %></h2>
|
||||
<div class="max-w-md mx-auto bg-white p-8 mb-10 rounded-lg shadow-md space-y-4">
|
||||
<h3 class="text-lg font-medium mb-6">My Retirement Plans</h3>
|
||||
<a href="/newPlan" class="block max-w-sm p-2"><div class="border-2 text-center border-gray-600 bg-blue-600 text-white py-1 w-full rounded-md hover:bg-transparent hover:text-indigo-700 font-semibold">New Plan</div></a>
|
||||
<hr class="mt-3">
|
||||
<% plans.forEach(plan => { %>
|
||||
<a href="<%= plan.link %>" class="block max-w-sm p-6 bg-white border border-gray-200 rounded-lg shadow-sm hover:bg-gray-100 dark:bg-gray-800 dark:border-gray-700 dark:hover:bg-gray-700">
|
||||
<h5 class="mb-2 text-2xl font-bold tracking-tight text-gray-900 dark:text-white"><%= plan.name %></h5>
|
||||
<div class="w-full bg-gray-200 rounded-full h-2.5 mb-4 dark:bg-gray-700">
|
||||
<div class="bg-green-600 h-2.5 rounded-full dark:bg-green-500" style="width: <%= plan.progress %> "></div>
|
||||
</div>
|
||||
<p class="font-normal text-gray-700 dark:text-gray-400"><%= plan.description %></p>
|
||||
</a>
|
||||
<% }) %>
|
||||
</div>
|
||||
|
||||
</main>
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<%- include("./partials/fileHeader") %>
|
||||
<%- include("./partials/header") %>
|
||||
|
||||
<main>
|
||||
<h2 class="ml-11 mt-5 mb-6 text-xl font-semibold mb-4 text-white">Welcome <%= user.name %></h2>
|
||||
|
||||
<% if (errMessage != "") { %>
|
||||
<div class="max-w-md mx-auto mb-10 rounded-lg shadow-md text-white font-bold bg-red-400 py-4 text-center"><%= errMessage %></div>
|
||||
<% } %>
|
||||
|
||||
<div class="max-w-md mx-auto bg-white p-8 mb-10 rounded-lg shadow-md">
|
||||
<div class="flex flex-row justify-between">
|
||||
<h3 class="pt-2 pr-2 pb-2">Account settings</h3>
|
||||
<button id="edit-account" onclick="unlockAccount()" class="py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">Edit</button>
|
||||
</div>
|
||||
<form action="/updateAccount" method="post" class="space-y-4 mt-4" id="account-form">
|
||||
|
||||
<label for="email" class="block text-sm font-medium text-gray-700">Email</label>
|
||||
<input id="email" disabled type="text" name="email" value="<%= user.email %>" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||
|
||||
<label for="name" class="block text-sm font-medium text-gray-700">Name</label>
|
||||
<input id="name" disabled type="text" name="name" value="<%= user.name %>" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||
|
||||
<label for="password" class="block text-sm font-medium text-gray-700">New password</label>
|
||||
<input id="password" disabled type="password" name="password" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||
|
||||
<label for="repassword" class="block text-sm font-medium text-gray-700">Confirm new password</label>
|
||||
<input id="repassword" disabled type="password" name="repassword" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||
|
||||
<div>
|
||||
<button id="save-account" disabled type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 cursor-not-allowed">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!--
|
||||
<div class="mb-10 max-w-md mx-auto bg-white p-8 rounded-lg shadow-md">
|
||||
<div class="flex flex-row justify-between">
|
||||
<h3 class="pt-2 pr-2 pb-2">Personal information</h3>
|
||||
<button onclick="unlockPersonal()" class="py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">Edit</button>
|
||||
</div>
|
||||
<form action="/updatePersonal" method="post" class="space-y-4" id="personal-form">
|
||||
<div>
|
||||
<label for="dob" class="block text-sm font-medium text-gray-700">Date of Birth</label>
|
||||
<input id="dob" disabled type="date" name="dob" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||
</div>
|
||||
<div>
|
||||
<label for="education" class="block text-sm font-medium text-gray-700">Education</label>
|
||||
<select disabled name="education" id="education" class="mt-1 block w-full px-3 py-2 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||
<option value="primary">Primary (Elementary)</option>
|
||||
<option value="secondary">Secondary (High School)</option>
|
||||
<option value="tertiary">Tertiary (College/University)</option>
|
||||
<option value="postgraduate">Postgraduate (Master's/PhD)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Marital Status</label>
|
||||
<div class="mt-1 space-x-4">
|
||||
<label class="inline-flex items-center">
|
||||
<input disabled id="ms-single" type="radio" name="maritalStatus" value="single" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||
<span class="ml-2 text-sm text-gray-700">Single</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center">
|
||||
<input disabled id="ms-married" type="radio" name="maritalStatus" value="married" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||
<span class="ml-2 text-sm text-gray-700">Married</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center">
|
||||
<input disabled id="ms-divorced" type="radio" name="maritalStatus" value="divorced" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||
<span class="ml-2 text-sm text-gray-700">Divorced</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center">
|
||||
<input disabled id="ms-widowed" type="radio" name="maritalStatus" value="widowed" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 disabled:border-gray-200 disabled:bg-gray-50 disabled:text-gray-500 disabled:shadow-none">
|
||||
<span class="ml-2 text-sm text-gray-700">Widowed</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button id="save-personal" disabled type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 cursor-not-allowed">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div> -->
|
||||
|
||||
<div class="mt-24"></div>
|
||||
</main>
|
||||
|
||||
<script src="/static/scripts/profile.js"></script>
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -0,0 +1,71 @@
|
||||
<%- include("./partials/fileHeader") %>
|
||||
<%- include("./partials/header") %>
|
||||
|
||||
<main class="container mx-auto p-4">
|
||||
<h2 class="text-xl font-semibold mb-4">Welcome: <%= user.email %></h2>
|
||||
<div class="max-w-md mx-auto bg-white p-8 mb-10 rounded-lg shadow-md">
|
||||
<h3 class="text-lg font-medium mb-6">Financial Questionnaire</h3>
|
||||
<form action="/questionnaire" method="post" class="space-y-4">
|
||||
<div>
|
||||
<label for="dob" class="block text-sm font-medium text-gray-700">Date of Birth</label>
|
||||
<input type="date" name="dob" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label for="education" class="block text-sm font-medium text-gray-700">Education</label>
|
||||
<select name="education" id="education" class="mt-1 block w-full px-3 py-2 border border-gray-300 bg-white rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
<option value="primary">Primary (Elementary)</option>
|
||||
<option value="secondary">Secondary (High School)</option>
|
||||
<option value="tertiary">Tertiary (College/University)</option>
|
||||
<option value="postgraduate">Postgraduate (Master's/PhD)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Marital Status</label>
|
||||
<div class="mt-1 space-x-4">
|
||||
<label class="inline-flex items-center">
|
||||
<input type="radio" name="maritalStatus" value="single" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500">
|
||||
<span class="ml-2 text-sm text-gray-700">Single</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center">
|
||||
<input type="radio" name="maritalStatus" value="married" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500">
|
||||
<span class="ml-2 text-sm text-gray-700">Married</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center">
|
||||
<input type="radio" name="maritalStatus" value="divorced" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500">
|
||||
<span class="ml-2 text-sm text-gray-700">Divorced</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center">
|
||||
<input type="radio" name="maritalStatus" value="widowed" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500">
|
||||
<span class="ml-2 text-sm text-gray-700">Widowed</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="income" class="block text-sm font-medium text-gray-700">Annual Gross Income</label>
|
||||
<input type="number" name="income" min="0" placeholder="e.g., 50000" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="expenses" class="block text-sm font-medium text-gray-700">Monthly Expenses</label>
|
||||
<input type="number" name="expenses" min="0" placeholder="e.g., 2000" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="assets" class="block text-sm font-medium text-gray-700">Net Worth</label>
|
||||
<input type="number" name="assets" min="0" placeholder="Estimated Net Worth" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="liabilities" class="block text-sm font-medium text-gray-700">Liabilities</label>
|
||||
<input type="number" name="liabilities" min="0" placeholder="Estimated Liabilities" class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">Submit Questionnaire</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -13,6 +13,12 @@
|
||||
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
||||
placeholder="Enter Email" />
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<label for="name" class="block text-base mb-2">Name</label>
|
||||
<input type="text" id="name" name="name"
|
||||
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
|
||||
placeholder="Enter Name" />
|
||||
</div>
|
||||
<div class="mt-3">
|
||||
<label for="password" class="block text-base mb-2">Password</label>
|
||||
<input type="password" id="password" name="password"
|
||||
|
||||
Reference in new issue
Block a user