Merge dev@latest into dev

This commit is contained in:
SowinskiBraeden committed 2025-05-07 10:49:37 -07:00
commit 700ded35e4
16 files changed
+445 -101

No files matched your search

+20 -8
View File
@@ -3,7 +3,7 @@ const MongoStore = require("connect-mongo");
const session = require("express-session");
const express = require('express');
const path = require('path');
const joi = require('joi');
const joi = require('joi');
require('dotenv').config();
@@ -12,7 +12,7 @@ const port = process.env.PORT || 3000;
const mongoURI = process.env.mongoURI || "mongodb://localhost:27017/";
const database = process.env.database || "knoldus"; // Database name
const secret = process.env.secret || "123-secret-xyz";
const secret = process.env.secret || "123-secret-xyz";
/*** Sessions ***/
app.use(session({
@@ -24,22 +24,25 @@ app.use(session({
}));
app.set('view engine', 'ejs');
app.set('views',path.join(__dirname, 'src/views'));
app.set('views', path.join(__dirname, 'src/views'));
app.use(express.urlencoded({ extended: true }));
app.use("/static", express.static("./src/public"));
app.use("/images", express.static("./src/public/images"));
app.use(express.json());
/*** Database ***/
const { connectMongo, getCollection } = require("./src/database/connection");
let users;
let assets;
let plans;
async function initDatabase() {
const db = await connectMongo(mongoURI, database);
// For any collection, init here
users = await getCollection(db, "users");
assets = await getCollection(db, "assets");
plans = await getCollection(db, "plans");
}
/*** ROUTINGS ***/
@@ -60,7 +63,7 @@ app.get('/signup', (req, res) => {
app.get('/login', (req, res) => {
if (req.session.authenticated) {
res.redirect("/home");
return res.status(status.Ok);
return res.status(status.Ok);
}
res.render('login', { errMessage: req.session.errMessage });
return res.status(status.Ok);
@@ -71,6 +74,15 @@ app.get('/aboutUs', (req, res) => {
return res.status(status.Ok);
});
app.post('/api/location', async (req,res) => {
const { latitude, longitude } = req.body;
const response = await fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${latitude},${longitude}&result_type=country&key=${process.env.geolocation_api}`);
const data = await response.json();
res.json(data);
});
// Initialize database and start app
initDatabase().then(() => {
@@ -81,16 +93,16 @@ initDatabase().then(() => {
// Import middleware & apply to user routes
const middleware = require("./src/auth/middleware")(users);
app.use(require('./src/router/user')(middleware, users, assets));
app.use(require('./src/router/user')(middleware, users, plans, assets));
// 404 handler
app.get('/*splat', (req, res) => {
res.send('404 Not Found');
return res.status(status.NotFound);
});
});
// Start app
app.listen(port, () => {
console.log(`Server listening on port ${port}`);
});
});
});
Generated Executable → Regular
+34 -32
View File
@@ -354,27 +354,6 @@
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/chalk/node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/chalk/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"license": "MIT",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/chokidar": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
@@ -549,6 +528,7 @@
"version": "16.5.0",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz",
"integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==",
"license": "BSD-2-Clause",
"engines": {
"node": ">=12"
},
@@ -580,6 +560,7 @@
"version": "3.1.10",
"resolved": "https://registry.npmjs.org/ejs/-/ejs-3.1.10.tgz",
"integrity": "sha512-UeJmFfOrAQS8OJWPZ4qtgHyWExa088/MtK5UEyoJGFH67cDEXkZSviOiKRCZ4Xij0zxI3JECgYs3oKx+AizQBA==",
"license": "Apache-2.0",
"dependencies": {
"jake": "^10.8.5"
},
@@ -969,13 +950,12 @@
}
},
"node_modules/has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
"dev": true,
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"license": "MIT",
"engines": {
"node": ">=4"
"node": ">=8"
}
},
"node_modules/has-symbols": {
@@ -1479,6 +1459,29 @@
"url": "https://opencollective.com/nodemon"
}
},
"node_modules/nodemon/node_modules/has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/nodemon/node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-flag": "^3.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/nopt": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz",
@@ -1976,16 +1979,15 @@
}
},
"node_modules/supports-color": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz",
"integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==",
"dev": true,
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"license": "MIT",
"dependencies": {
"has-flag": "^3.0.0"
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=4"
"node": ">=8"
}
},
"node_modules/tar": {
+3
View File
@@ -44,6 +44,7 @@ module.exports = (users) => {
}
req.session.authenticated = true;
req.session.userId = user._id;
req.session.email = req.body.email;
req.session.errMessage = "";
res.redirect("/home");
@@ -79,6 +80,7 @@ module.exports = (users) => {
email: req.body.email,
name: req.body.name,
password: hashedPassword,
financialData: false,
}).then((results, err) => {
if (err) {
console.error(err);
@@ -88,6 +90,7 @@ module.exports = (users) => {
req.session.authenticated = true;
req.session.email = req.body.email;
req.session.userId = results.insertedId;
req.session.errMessage = "";
return res.status(status.Ok).redirect("/home");
+24
View File
@@ -0,0 +1,24 @@
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(success, error);
}
}
function success(position) {
const { latitude, longitude } = position.coords;
fetch("api/location" , {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({ latitude, longitude })
}).then(res => res.json())
.then(data => {
console.log(data.results[0].formatted_address);
})
}
function error(err) {
console.error("Geolocation error: ", err);
}
+116 -13
View File
@@ -2,6 +2,7 @@ const status = require("../util/statuses");
const ObjectId = require('mongodb').ObjectId;
const bcrypt = require("bcrypt");
const joi = require("joi");
const { ObjectId } = require('mongodb');
const salt = 12;
/**
@@ -58,13 +59,13 @@ const getAssetSchema = (type) => {
* @param {MongoClient.collection} assets db collection
* @returns {express.Router} user protected routes router
*/
module.exports = (middleware, users, assets) => {
module.exports = (middleware, users, plans, assets) => {
const router = require("express").Router();
router.use(middleware);
router.get('/home', async (req, res) => {
res.render('home', { user: req.session.user });
res.render('dashboard', { user: req.session.user });
return res.status(status.Ok);
});
@@ -74,11 +75,119 @@ module.exports = (middleware, users, assets) => {
return res.status(status.Ok);
});
router.get('/plans', (req, res) => {
res.render('plans', { user: req.session.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('/plans/:id', async (req, res) => {
if (!req.session.email) {
return res.status(status.Unauthorized).redirect('/login');
}
try {
const planId = req.params.id;
if (!ObjectId.isValid(planId)) {
req.session.errMessage = "Invalid plan ID format.";
return res.status(status.BadRequest).redirect('/plans');
}
const plan = await plans.findOne({ userEmail: req.user.email, _id: new ObjectId(planId) });
if (!plan) {
console.log(`Plan not found with ID: ${planId} for user: ${req.user.email}`);
req.session.errMessage = "Plan not found or you do not have permission to view it.";
return res.status(status.NotFound).redirect('/plans');
}
// console.log("Found plan:", plan);
res.render('planDetail', {
user: req.user,
plan: plan
});
} catch (err) {
console.error("Error fetching plan:", err);
req.session.errMessage = "Could not load your plan. Please try again.";
res.status(status.InternalServerError).redirect('/home');
}
});
router.get('/newPlan', (req, res) => {
if (!req.session.email) {
return res.status(status.Unauthorized).redirect('/login');
}
if(!req.user.financialData){
req.session.errMessage = "Please complete your financial data before creating a plan.";
return res.status(status.Unauthorized).redirect('/questionnaire');
}
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.session.user });
return res.status(status.Ok);
@@ -101,6 +210,8 @@ module.exports = (middleware, users, assets) => {
});
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(),
@@ -109,10 +220,6 @@ module.exports = (middleware, users, assets) => {
expenses: joi.number().min(0).required(),
assets: joi.number().min(0).required(),
liabilities: joi.number().min(0).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 };
@@ -137,10 +244,6 @@ module.exports = (middleware, users, assets) => {
expenses: value.expenses,
assets: value.assets,
liabilities: value.liabilities,
retirementAge: value.retirementAge,
retirementExpenses: value.retirementExpenses,
retirementAssets: value.retirementAssets,
retirementLiabilities: value.retirementLiabilities,
}
}
).then((result) => {
+100
View File
@@ -0,0 +1,100 @@
<%- include("./partials/fileHeader") %>
<%- include("./partials/header") %>
<main>
<h2 class="text-xl text-white font-semibold mb-4">Welcome: <%= user.name %></h2>
<!-- Buttons -->
<div class="flex justify-end gap-4 px-5 py-6">
<button class="cursor-pointer min-w-[150px] bg-green-600 px-4 py-2 text-white rounded hover:bg-green-800" type="button">
Add Asset
</button>
<a href="/newPlan" class="cursor-pointer min-w-[150px] bg-green-600 px-4 py-2 text-white rounded hover:bg-green-800" type="button">
Create new plan
</a>
</div>
<!--This is the cards for plans and other things-->
<div class="mt-12">
<div class="mb-12 grid gap-y-10 gap-x-6 md:grid-cols-2 mr-3 ml-3 xl:grid-cols-4">
<!--box to put logo icon if we want on in a box-->
<div class=" relative flex flex-col bg-clip-border rounded-xl bg-white text-gray-700 shadow-md">
<!-- <div -->
<!-- class="bg-clip-border mx-4 rounded-xl overflow-hidden bg-gradient-to-tr from-blue-600 to-blue-400 text-white shadow-blue-500/40 shadow-lg absolute mt-2 grid h-16 w-16 place-items-center"> -->
<!-- </div> -->
<div class="p-4 flex items-center justify-between">
<p class="font-sans text-2xl leading-normal font-normal text-blue-gray-600">
Retirement goal</p>
<h4
class="block text-right antialiased tracking-normal font-sans text-2xl font-semibold leading-snug text-blue-gray-900">
$53k</h4>
</div>
<div class="border-t border-blue-gray-50 p-10">
<p class=" antialiased font-sans text-base leading-relaxed font-normal text-blue-gray-600">
<strong class="text-green-500">Make this percent bar or graph or something </strong>&nbsp;than last
week
</p>
</div>
</div>
<div class="relative flex flex-col bg-clip-border rounded-xl bg-white text-gray-700 shadow-md">
<div class="p-4 flex items-center justify-between">
<p class="font-sans text-2xl leading-normal font-normal text-blue-gray-600">
Retirement goal</p>
<h4
class="block text-right antialiased tracking-normal font-sans text-2xl font-semibold leading-snug text-blue-gray-900">
$53k</h4>
</div>
<div class="border-t border-blue-gray-50 p-10">
<p class=" antialiased font-sans text-base leading-relaxed font-normal text-blue-gray-600">
<strong class="text-green-500">Make this percent bar or graph or something </strong>&nbsp;than last
week
</p>
</div>
</div>
<div class="relative flex flex-col bg-clip-border rounded-xl bg-white text-gray-700 shadow-md">
<!-- <div -->
<!-- class="bg-clip-border mx-4 rounded-xl overflow-hidden bg-gradient-to-tr from-green-600 to-green-400 text-white shadow-green-500/40 shadow-lg absolute -mt-4 grid h-16 w-16 place-items-center"> -->
<!-- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor" aria-hidden="true" -->
<!-- class="w-6 h-6 text-white"> -->
<!-- <path -->
<!-- d="M6.25 6.375a4.125 4.125 0 118.25 0 4.125 4.125 0 01-8.25 0zM3.25 19.125a7.125 7.125 0 0114.25 0v.003l-.001.119a.75.75 0 01-.363.63 13.067 13.067 0 01-6.761 1.873c-2.472 0-4.786-.684-6.76-1.873a.75.75 0 01-.364-.63l-.001-.122zM19.75 7.5a.75.75 0 00-1.5 0v2.25H16a.75.75 0 000 1.5h2.25v2.25a.75.75 0 001.5 0v-2.25H22a.75.75 0 000-1.5h-2.25V7.5z"> -->
<!-- </path> -->
<!-- </svg> -->
<!-- </div> -->
<!-- we can use this later if needed not sure what it shoudl be for right now. -->
<!-- <div class="p-4 text-right"> -->
<!-- <p class="block antialiased font-sans text-sm leading-normal font-normal text-blue-gray-600">New Clients -->
<!-- </p> -->
<!-- <h4 -->
<!-- class="block antialiased tracking-normal font-sans text-2xl font-semibold leading-snug text-blue-gray-900"> -->
<!-- 3,462</h4> -->
<!-- </div> -->
<!-- <div class="border-t border-blue-gray-50 p-4"> -->
<!-- <p class="block antialiased font-sans text-base leading-relaxed font-normal text-blue-gray-600"> -->
<!-- <strong class="text-red-500">-2%</strong>&nbsp;than yesterday -->
<!-- </p> -->
<!-- </div> -->
<!-- </div> -->
<div class="relative flex flex-col bg-clip-border rounded-xl bg-white text-gray-700 shadow-md">
<div class="relative flex flex-col bg-clip-border rounded-xl bg-white text-gray-700 shadow-md">
<div class="p-4 flex items-center justify-between">
<p class="font-sans text-2xl leading-normal font-normal text-blue-gray-600">
Retirement goal</p>
<h4
class="block text-right antialiased tracking-normal font-sans text-2xl font-semibold leading-snug text-blue-gray-900">
$53k</h4>
</div>
<div class="border-t border-blue-gray-50 p-10">
<p class=" antialiased font-sans text-base leading-relaxed font-normal text-blue-gray-600">
<strong class="text-green-500">Make this percent bar or graph or something </strong>&nbsp;than last
week
</p>
</div>
</div>
</div>
</div>
</div>
<div class="text-blue-gray-600">
</div>
</main>
<%- include("./partials/navBar") %>
<%- include("./partials/footer") %>
-1
View File
@@ -2,7 +2,6 @@
<%- include("./partials/header") %>
<main>
<%- include("./partials/header") %>
Welcome: <%= user.email %>
The Dashboard Page
<% if(user.authenticated) { %>
-9
View File
@@ -1,9 +0,0 @@
<%- include("./partials/fileHeader") %>
<%- include("./partials/header") %>
<main>
The Index Page
</main>
<%- include("./partials/navBar") %>
<%- include("./partials/footer") %>
+3 -3
View File
@@ -4,18 +4,18 @@
<div class="flex justify-center items-center h-screen">
<form action="/login" method="POST">
<div class="w-96 p-6 shadow-1g bg-white rounded-md">
<h1 class="text-3xl block text-center font-semibold"> Login </h1>
<h1 class="text-3xl block text-center font-semibold">Login</h1>
<hr class="mt-3">
<div class="mt-3">
<label for="email" class="block text-base mb-2">Email</label>
<input type="text" id="email" name="email"
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
placeholder="Enter Email" />
</div>
<div class="mt-3">
<label for="password" class="block text-base mb-2">Password</label>
<input type="password" id="password" name="password"
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
placeholder="Enter Password" />
</div>
<div class="text-red-800 font-bold" id="forgor"> <%= errMessage %></div>
+40
View File
@@ -0,0 +1,40 @@
<%- include("./partials/fileHeader") %>
<%- include("./partials/header") %>
<main class="container mx-auto p-4">
<h2 class="text-xl text-white font-semibold mb-4">Welcome: <%= user.name %></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">Retirement Plan</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") %>
+2 -1
View File
@@ -1,10 +1,11 @@
<footer>
<footer class="mt-16">
<div class="fixed bottom-0 left-0 z-50 hidden lg:block w-full h-16 bg-gray-100 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 p-6 text-center text-gray-500 dark:text-gray-400 text-sm">
<div class="container mx-auto">
<p>&copy; 2025 RCalculator. All rights reserved.</p>
</div>
</div>
</footer>
<script src="/static/scripts/geolocation.js"></script>
</body>
</html>
+1 -1
View File
@@ -1,4 +1,4 @@
<div class="fixed bottom-0 left-0 z-50 lg:hidden w-full h-16 bg-gray-100 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 text-sm">
<div class="fixed bottom-0 z-50 lg:hidden w-full h-16 bg-gray-100 dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700 text-gray-500 dark:text-gray-400 text-sm">
<div class="grid h-16 max-w-lg grid-cols-4 mx-auto font-medium">
<a href="/home" class="inline-flex flex-col items-center justify-center px-5 hover:bg-gray-50 dark:hover:bg-gray-800 group">
<svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" fill="currentColor" viewBox="0 0 24 24">
+74
View File
@@ -0,0 +1,74 @@
<%- include("./partials/fileHeader") %>
<%- include("./partials/header") %>
<main class="container mx-auto p-4">
<h2 class="text-xl text-white font-semibold mb-4">Welcome: <%= user.name %></h2>
<div class="max-w-lg mx-auto bg-white p-6 sm:p-8 rounded-xl shadow-lg space-y-6 dark:bg-gray-800">
<div class="text-center">
<h3 class="text-2xl font-bold text-gray-800 dark:text-white"><%= plan.name %></h3>
</div>
<div>
<div class="flex justify-between mb-1">
<span class="text-sm font-medium text-blue-700 dark:text-blue-400">Progress</span>
<span class="text-sm font-medium text-blue-700 dark:text-blue-400"><%= plan.progress %></span>
</div>
<div class="w-full bg-gray-200 rounded-full h-3 dark:bg-gray-700">
<div class="bg-blue-600 h-3 rounded-full dark:bg-blue-500" style="width: <%= plan.progress %>;"></div>
</div>
</div>
<div class="border-t border-gray-200 dark:border-gray-700 pt-6 space-y-4">
<h4 class="text-lg font-semibold text-gray-700 dark:text-gray-300 mb-3">Assets:</h4>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-4">
<div>
<label class="block text-sm font-medium text-gray-600 dark:text-gray-400">Number of Assets:</label>
<p class="mt-1 text-md text-gray-900 dark:text-white">16 MOCK</p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600 dark:text-gray-400">Total Value:</label>
<p class="mt-1 text-md text-gray-900 dark:text-white">$165,000 MOCK</p>
</div>
</div>
</div>
<div class="border-t border-gray-200 dark:border-gray-700 pt-6 space-y-4">
<h4 class="text-lg font-semibold text-gray-700 dark:text-gray-300 mb-3">Plan Details:</h4>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-x-6 gap-y-4">
<div>
<label class="block text-sm font-medium text-gray-600 dark:text-gray-400">Retirement Age:</label>
<p class="mt-1 text-md text-gray-900 dark:text-white"><%= plan.retirementAge %></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600 dark:text-gray-400">Target Monthly Expenses:</label>
<p class="mt-1 text-md text-gray-900 dark:text-white"><%= plan.retirementExpenses %></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600 dark:text-gray-400">Target Retirement Assets:</label>
<p class="mt-1 text-md text-gray-900 dark:text-white"><%= plan.retirementAssets %></p>
</div>
<div>
<label class="block text-sm font-medium text-gray-600 dark:text-gray-400">Target Retirement Liabilities:</label>
<p class="mt-1 text-md text-gray-900 dark:text-white"><%= plan.retirementLiabilities %></p>
</div>
</div>
</div>
<div class="border-t border-gray-200 dark:border-gray-700 pt-6 space-y-4">
<h4 class="text-lg font-semibold text-gray-700 dark:text-gray-300 mb-3">Suggestions:</h4>
<div class="mt-6 p-4 bg-blue-50 border border-blue-200 rounded-lg dark:bg-gray-700 dark:border-gray-600">
<p class="text-sm text-blue-700 dark:text-blue-300">
USE YOUR HEAD MOCK
</p>
</div>
</div>
</div>
</main>
<%- include("./partials/navBar") %>
<%- include("./partials/footer") %>
+17 -2
View File
@@ -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.name %></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="text-center bg-blue-600 text-white py-1 w-full rounded-md hover:bg-blue-700 hover:text-white font-semibold">New Plan</div></a>
<hr class="mt-3">
<% plans.forEach(plan => { %>
<a href="/plans/<%= plan._id %>" 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") %>
+1 -21
View File
@@ -2,7 +2,7 @@
<%- include("./partials/header") %>
<main class="container mx-auto p-4">
<h2 class="text-xl font-semibold mb-4">Welcome: <%= user.email %></h2>
<h2 class="text-xl font-semibold mb-4">Welcome: <%= user.name %></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">
@@ -60,26 +60,6 @@
<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>
<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">Submit Questionnaire</button>
+10 -10
View File
@@ -5,28 +5,28 @@
<div class="flex justify-center items-center h-screen">
<form action="/signup" method="POST">
<div class="w-96 p-6 shadow-1g bg-white rounded-md">
<h1 class="text-3xl block text-center font-semibold"> Signup </h1>
<h1 class="text-3xl block text-center font-semibold">Signup</h1>
<hr class="mt-3">
<div class="mt-3">
<label for="email" class="block text-base mb-2">Email</label>
<input type="text" id="email" name="email"
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 "
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
placeholder="Enter Name" />
</div>
<div class="mt-3">
<label for="email" class="block text-base mb-2">Email</label>
<input type="text" id="email" name="email"
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
placeholder="Enter Email" />
</div>
<div class="mt-3">
<label for="password" class="block text-base mb-2">Password</label>
<input type="password" id="password" name="password"
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
placeholder="Enter Password" />
<label for="password" class="block text-base mb-2 mt-3">Re-type Password</label>
<input type="password" id="repassword" name="repassword"
class="border focus:border-gray-600 w-full text-base px-2 py-1 focus:outline-none focus:ring-0 "
class="border focus:border-gray-600 w-full rounded-md text-base px-2 py-1 focus:outline-none focus:ring-0 "
placeholder="Enter Password" />
</div>
<div class="text-red-800 font-bold " id="forgor"> <%= errMessage %></div>