Compare commits
28
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c0c560441 | ||
|
|
5763f03288
|
||
|
|
ed06b8731d
|
||
|
|
345cbd2bf2
|
||
|
|
c4a90ceb15
|
||
|
|
ac66323a78
|
||
|
|
32437a6e36 | ||
|
|
cec777d1bf | ||
|
|
605c7b3734 | ||
|
|
ddf07eee11
|
||
|
|
640ae859e5 | ||
|
|
54024bd7a2
|
||
|
|
821843088d
|
||
|
|
04a7fa428c | ||
|
|
cadbc2187d
|
||
|
|
f417ac00fb | ||
|
|
b2e795427d
|
||
|
|
7ff74b8bbd
|
||
|
|
700ded35e4
|
||
|
|
dbffe122a2
|
||
|
|
d85a4120e2
|
||
|
|
3ad4e20588
|
||
|
|
aedfc17c36
|
||
|
|
4c6945ecbc
|
||
|
|
78946bb6ca
|
||
|
|
1f8579a052
|
||
|
|
47fc1983f8
|
||
|
|
803330b174
|
No files matched your search
+6
-3
@@ -1,4 +1,7 @@
|
||||
mongoURI='mongodb://localhost:27017/'
|
||||
database='nameOfDatabase'
|
||||
MONGO_URI='mongodb://localhost:27017/'
|
||||
DATABASE='nameOfDatabase'
|
||||
PORT=8000
|
||||
secret='123456789'
|
||||
SECRET='123456789'
|
||||
GEOLOCATION_API='api_key'
|
||||
EMAIL_USER=mail@example.com
|
||||
EMAIL_PASS='password'
|
||||
@@ -6,3 +6,6 @@ node_modules/
|
||||
|
||||
# Sync
|
||||
*.sync-conflict*
|
||||
|
||||
# VSCode
|
||||
.vscode/
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
{
|
||||
"editor.fontFamily": "Monocraft",
|
||||
"editor.fontLigatures": true
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
Team Name: BBY-14
|
||||
Team Members:
|
||||
<ul>
|
||||
<li> Joaquin Paredes </li>
|
||||
<li> Nicolas Agostini </li>
|
||||
<li> Mitchell Schaeffer </li>
|
||||
<li> Braeden Sowinski </li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
||||
@@ -9,9 +9,9 @@ require('dotenv').config();
|
||||
const app = express();
|
||||
const port = process.env.PORT || 3000;
|
||||
|
||||
const mongoURI = process.env.mongoURI;
|
||||
const database = process.env.database; // Database name
|
||||
const secret = process.env.secret || "123-secret-xyz";
|
||||
const mongoURI = process.env.MONGO_URI;
|
||||
const database = process.env.DATABASE; // Database name
|
||||
const secret = process.env.SECRET || "123-secret-xyz";
|
||||
|
||||
/*** Sessions ***/
|
||||
app.use(session({
|
||||
@@ -33,11 +33,14 @@ app.use(express.json());
|
||||
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");
|
||||
}
|
||||
|
||||
@@ -70,6 +73,13 @@ app.get('/aboutUs', (req, res) => {
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
// 404 handler - keep the actual notFound route please
|
||||
// REALLY DONT DELETE THIS
|
||||
app.get('/notFound', (req, res) => {
|
||||
res.render('notFound');
|
||||
return res.status(status.NotFound);
|
||||
});
|
||||
|
||||
// Initialize database and start app
|
||||
initDatabase().then(() => {
|
||||
console.log("Successfully connected to MongoDB");
|
||||
@@ -78,12 +88,12 @@ initDatabase().then(() => {
|
||||
app.use(require("./src/auth/authentication")(users));
|
||||
|
||||
// Import middleware & apply to user routes
|
||||
const middleware = require("./src/auth/middleware")(users, plans);
|
||||
app.use(require('./src/router/user')(middleware, users, plans));
|
||||
const middleware = require("./src/auth/middleware")(users);
|
||||
app.use(require('./src/router/user')(middleware, users, plans, assets));
|
||||
|
||||
// 404 handler
|
||||
app.get('/*splat', (req, res) => {
|
||||
res.send('404 Not Found');
|
||||
res.render('notFound');
|
||||
return res.status(status.NotFound);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
const status = require("../util/statuses");
|
||||
const session = require("express-session");
|
||||
const bcrypt = require('bcrypt');
|
||||
const joi = require("joi");
|
||||
const salt = 12;
|
||||
|
||||
/**
|
||||
* @param {MongoClient.collection} users db collection
|
||||
* @returns {express.Router} authentication router
|
||||
*/
|
||||
module.exports = (users) => {
|
||||
const router = require("express").Router();
|
||||
|
||||
|
||||
+17
-5
@@ -1,19 +1,29 @@
|
||||
const status = require("../util/statuses");
|
||||
const session = require("express-session");
|
||||
|
||||
// Get all user routes names
|
||||
let userRouter = require("../router/user")((req, res, next) => next(), null, null, null);
|
||||
userRouter.stack.shift();
|
||||
const userRoutes = userRouter.stack.map((layer) => layer.route.path.split("/")[1]);
|
||||
|
||||
/**
|
||||
* createMiddleware returns a middleware function for express.
|
||||
* @param {MongoClient.collection} users
|
||||
* @return {async function}
|
||||
*/
|
||||
* @param {MongoClient.collection} users db collection
|
||||
* @returns {async function} middleware handler function
|
||||
*/
|
||||
const createMiddleware = (users) => {
|
||||
return async (req, res, next) => {
|
||||
// Redirect not found pages to 404 page
|
||||
if (!userRoutes.includes(req.url.split("/")[1])) {
|
||||
return res.status(status.NotFound).redirect("/notFound");
|
||||
}
|
||||
|
||||
if (!req.session.authenticated || !req.session.email) {
|
||||
req.session.errMessage = "Please login to view that resource";
|
||||
res.redirect("/login");
|
||||
return res.status(status.Unauthorized);
|
||||
}
|
||||
|
||||
if (!req.session.user) {
|
||||
let user = await users.findOne({ "email": req.session.email }).then((user) => user);
|
||||
|
||||
if (!user) {
|
||||
@@ -22,7 +32,9 @@ const createMiddleware = (users) => {
|
||||
return res.status(status.Unauthorized);
|
||||
}
|
||||
|
||||
req.user = user;
|
||||
req.session.user = user;
|
||||
}
|
||||
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
const assetForms = [
|
||||
"create-other-asset-form",
|
||||
"create-saving-asset-form",
|
||||
"create-stock-asset-form"
|
||||
];
|
||||
|
||||
/**
|
||||
* resetAll asset creation forms
|
||||
*/
|
||||
function resetAll() {
|
||||
document.getElementById("create-other-asset-form").reset();
|
||||
document.getElementById("create-saving-asset-form").reset();
|
||||
document.getElementById("create-stock-asset-form").reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* selectAssetForm changes which form is displayed
|
||||
* to create specified assets.
|
||||
* @param {string} assetFormId
|
||||
*/
|
||||
function selectAssetForm(assetFormId) {
|
||||
for (let i = 0; i < assetForms.length; i++) {
|
||||
if (assetForms[i] == assetFormId) {
|
||||
document.getElementById(assetFormId).style.display = "block";
|
||||
} else {
|
||||
document.getElementById(assetForms[i]).style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* resetRadio to default to other asset type.
|
||||
*/
|
||||
function resetRadio() {
|
||||
document.getElementById("asset-other").checked = true;
|
||||
document.getElementById("asset-saving").checked = false;
|
||||
document.getElementById("asset-stock").checked = false;
|
||||
}
|
||||
|
||||
const assetKeys = {
|
||||
other: [
|
||||
"name",
|
||||
"value",
|
||||
"description",
|
||||
"purchaseDate",
|
||||
],
|
||||
saving: [
|
||||
"name",
|
||||
"value",
|
||||
],
|
||||
stock: [
|
||||
"ticker",
|
||||
"price",
|
||||
"quantity",
|
||||
"purchaseDate",
|
||||
],
|
||||
}
|
||||
|
||||
/**
|
||||
* lockAsset prevents edits to asset view modal
|
||||
* @param {string} assetId
|
||||
*/
|
||||
function lockAsset(assetId) {
|
||||
document.getElementById(`${assetId}-form`).reset();
|
||||
|
||||
const type = document.getElementById(`type-${assetId}`).value;
|
||||
|
||||
assetKeys[type].forEach((key) => {
|
||||
document.getElementById(`${key}-${assetId}`).disabled = true;
|
||||
});
|
||||
|
||||
document.getElementById(`save-${assetId}`).disabled = true;
|
||||
document.getElementById(`save-${assetId}`).classList.remove("cursor-pointer");
|
||||
document.getElementById(`save-${assetId}`).classList.add("cursor-not-allowed");
|
||||
|
||||
document.getElementById(`edit-${assetId}`).innerHTML = "Edit";
|
||||
document.getElementById(`edit-${assetId}`).onclick = () => { unlockAsset(assetId) };
|
||||
}
|
||||
|
||||
/**
|
||||
* unlockAsset allows edits to asset view modal
|
||||
* @param {string} assetId
|
||||
*/
|
||||
function unlockAsset(assetId) {
|
||||
const type = document.getElementById(`type-${assetId}`).value;
|
||||
|
||||
assetKeys[type].forEach((key) => {
|
||||
document.getElementById(`${key}-${assetId}`).disabled = false;
|
||||
});
|
||||
|
||||
document.getElementById(`save-${assetId}`).disabled = false;
|
||||
document.getElementById(`save-${assetId}`).classList.remove("cursor-not-allowed");
|
||||
document.getElementById(`save-${assetId}`).classList.add("cursor-pointer");
|
||||
|
||||
document.getElementById(`edit-${assetId}`).innerHTML = "Cancel changes";
|
||||
document.getElementById(`edit-${assetId}`).onclick = () => { lockAsset(assetId) };
|
||||
}
|
||||
|
||||
resetRadio();
|
||||
@@ -38,7 +38,7 @@ function update(data) {
|
||||
dropdown.appendChild(listItem);
|
||||
});
|
||||
|
||||
console.log(data);
|
||||
// console.log(data);
|
||||
}
|
||||
|
||||
function switchButton(clickedButton) {
|
||||
@@ -54,7 +54,7 @@ function switchButton(clickedButton) {
|
||||
}
|
||||
|
||||
function updateExchange(exRate) {
|
||||
document.getElementById("exchange1").innerHTML = "$1.00 = $" +`${(1 * exRate).toFixed(2)}`;
|
||||
document.getElementById("exchange").innerHTML = "$1.00 = $" +`${(1 * exRate).toFixed(2)}`;
|
||||
}
|
||||
|
||||
async function getLatestExchange(position) {
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="flag-icons-eu" viewBox="0 0 640 480">
|
||||
<defs>
|
||||
<g id="eu-d">
|
||||
<g id="eu-b">
|
||||
<path id="eu-a" d="m0-1-.3 1 .5.1z"/>
|
||||
<use xlink:href="#eu-a" transform="scale(-1 1)"/>
|
||||
</g>
|
||||
<g id="eu-c">
|
||||
<use xlink:href="#eu-b" transform="rotate(72)"/>
|
||||
<use xlink:href="#eu-b" transform="rotate(144)"/>
|
||||
</g>
|
||||
<use xlink:href="#eu-c" transform="scale(-1 1)"/>
|
||||
</g>
|
||||
</defs>
|
||||
<path fill="#039" d="M0 0h640v480H0z"/>
|
||||
<g fill="#fc0" transform="translate(320 242.3)scale(23.7037)">
|
||||
<use xlink:href="#eu-d" width="100%" height="100%" y="-6"/>
|
||||
<use xlink:href="#eu-d" width="100%" height="100%" y="6"/>
|
||||
<g id="eu-e">
|
||||
<use xlink:href="#eu-d" width="100%" height="100%" x="-6"/>
|
||||
<use xlink:href="#eu-d" width="100%" height="100%" transform="rotate(-144 -2.3 -2.1)"/>
|
||||
<use xlink:href="#eu-d" width="100%" height="100%" transform="rotate(144 -2.1 -2.3)"/>
|
||||
<use xlink:href="#eu-d" width="100%" height="100%" transform="rotate(72 -4.7 -2)"/>
|
||||
<use xlink:href="#eu-d" width="100%" height="100%" transform="rotate(72 -5 .5)"/>
|
||||
</g>
|
||||
<use xlink:href="#eu-e" width="100%" height="100%" transform="scale(-1 1)"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.3 KiB |
+295
-69
@@ -1,41 +1,69 @@
|
||||
const status = require("../util/statuses");
|
||||
const getRates = require("../util/exchangeRate");
|
||||
const bcrypt = require('bcrypt');
|
||||
const { calculatePlanProgress, updatePlanProgressInDB } = require("../util/calculations");
|
||||
const status = require("../util/statuses");
|
||||
const ObjectId = require('mongodb').ObjectId;
|
||||
const session = require("express-session");
|
||||
const bcrypt = require("bcrypt");
|
||||
const joi = require("joi");
|
||||
const { ObjectId } = require('mongodb');
|
||||
const salt = 12;
|
||||
|
||||
module.exports = (middleware, users, plans) => {
|
||||
/**
|
||||
* getAssetSchema returns correct joi object
|
||||
* to validate req.body depending on asset type
|
||||
* @param {string} type of asset
|
||||
* @returns {joi.object} schema
|
||||
*/
|
||||
const getAssetSchema = (type) => {
|
||||
let assetSchema;
|
||||
|
||||
switch (type) {
|
||||
case "other":
|
||||
assetSchema = joi.object({
|
||||
type: joi.string().valid("other", "stock", "saving").required(),
|
||||
name: joi.string().alphanum().min(3).max(30).required(),
|
||||
value: joi.number().min(0).required(),
|
||||
purchaseDate: joi.date().required(),
|
||||
description: joi.string().alphanum().max(240),
|
||||
id: joi.string().alphanum(), // May be passed when updating existing asset
|
||||
});
|
||||
break;
|
||||
case "saving":
|
||||
assetSchema = joi.object({
|
||||
type: joi.string().valid("other", "stock", "saving").required(),
|
||||
name: joi.string().alphanum().min(3).max(30).required(),
|
||||
value: joi.number().min(0).required(),
|
||||
id: joi.string().alphanum(), // May be passed when updating existing asset
|
||||
});
|
||||
break;
|
||||
case "stock":
|
||||
assetSchema = joi.object({
|
||||
type: joi.string().valid("other", "stock", "saving").required(),
|
||||
ticker: joi.string().alphanum().min(3).max(5).required(),
|
||||
price: joi.number().min(0).required(),
|
||||
quantity: joi.number().min(1).required(),
|
||||
purchaseDate: joi.date().required(),
|
||||
id: joi.string().alphanum(), // May be passed when updating existing asset
|
||||
});
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
};
|
||||
|
||||
return assetSchema;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {function} middleware handler
|
||||
* @param {MongoClient.collection} users db collection
|
||||
* @param {MongoClient.collection} assets db collection
|
||||
* @returns {express.Router} user protected routes router
|
||||
*/
|
||||
module.exports = (middleware, users, plans, assets) => {
|
||||
const router = require("express").Router();
|
||||
|
||||
router.use(middleware);
|
||||
|
||||
router.get('/home', async (req, res) => {
|
||||
|
||||
|
||||
/*
|
||||
|
||||
<% if (countryRates.length == 0) { %>
|
||||
render loading icon
|
||||
<% } else { %>
|
||||
render exchange
|
||||
<% } %>
|
||||
|
||||
stuff
|
||||
|
||||
<script>
|
||||
|
||||
if (countryRates.length == 0) {
|
||||
get geo
|
||||
|
||||
receive exchange
|
||||
|
||||
replace loading with exchange
|
||||
}
|
||||
|
||||
</script>
|
||||
*/
|
||||
|
||||
// if no session with geoData
|
||||
if (!req.session.geoData) {
|
||||
req.session.geoData = {
|
||||
@@ -49,26 +77,36 @@ module.exports = (middleware, users, plans) => {
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
router.get('/assets', (req, res) => {
|
||||
res.render('assets', { user: req.user });
|
||||
router.get('/assets', async (req, res) => {
|
||||
let userAssets = await assets.find({ userId: new ObjectId(req.session.user._id) }).toArray();
|
||||
res.render('assets', {
|
||||
user: req.session.user,
|
||||
errMessage: req.session.errMessage,
|
||||
assets: userAssets,
|
||||
geoData: req.session.geoData });
|
||||
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(new ObjectId(req.session.user._id));
|
||||
const userPlansFromDB = await plans.find({userId: new ObjectId(req.session.user._id) }).toArray();
|
||||
// console.log(userPlansFromDB);
|
||||
|
||||
// Use a for...of loop for proper async/await behavior in series for updates
|
||||
for (const plan of userPlansFromDB) {
|
||||
const percentage = await calculatePlanProgress(plan, assets, req.session.user._id);
|
||||
await updatePlanProgressInDB(plan._id, percentage, plans); // Pass the 'plans' collection
|
||||
}
|
||||
|
||||
try {
|
||||
// Re-fetch plans to get updated progress for rendering
|
||||
const updatedUserPlans = await plans.find({ userId: new ObjectId(req.session.user._id) }).toArray();
|
||||
|
||||
// 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
|
||||
user: req.session.user,
|
||||
plans: updatedUserPlans, // Send the most up-to-date plans
|
||||
geoData: req.session.geoData
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
console.error("Error fetching plans:", err);
|
||||
req.session.errMessage = "Could not load your plans. Please try again.";
|
||||
@@ -77,12 +115,10 @@ module.exports = (middleware, users, plans) => {
|
||||
});
|
||||
|
||||
router.get('/plans/:id', async (req, res) => {
|
||||
if (!req.session.email) {
|
||||
return res.status(status.Unauthorized).redirect('/login');
|
||||
}
|
||||
|
||||
try {
|
||||
const planId = req.params.id;
|
||||
let userAssets = await assets.find({ userId: new ObjectId(req.session.user._id) }).toArray();
|
||||
|
||||
|
||||
if (!ObjectId.isValid(planId)) {
|
||||
@@ -90,17 +126,27 @@ module.exports = (middleware, users, plans) => {
|
||||
return res.status(status.BadRequest).redirect('/plans');
|
||||
}
|
||||
|
||||
const plan = await plans.findOne({ userEmail: req.user.email, _id: new ObjectId(planId) });
|
||||
const plan = await plans.findOne({ userId: new ObjectId(req.session.user._id), _id: new ObjectId(planId) });
|
||||
|
||||
if (!plan) {
|
||||
console.log(`Plan not found with ID: ${planId} for user: ${req.user.email}`);
|
||||
console.log(`Plan not found with ID: ${planId} for user: ${req.session.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);
|
||||
|
||||
// The plan.progress should be up-to-date from the database as it was updated in the /plans route
|
||||
// or when assets/plans are modified. If an immediate recalculation for this specific view is absolutely needed,
|
||||
// (e.g., if assets were modified without an immediate plan progress update elsewhere),
|
||||
// you could do it here:
|
||||
// const currentProgress = await calculatePlanProgress(plan, assets, req.session.user._id);
|
||||
// plan.progress = currentProgress; // This would only update the 'plan' object for this render, not in DB
|
||||
|
||||
res.render('planDetail', {
|
||||
user: req.user,
|
||||
plan: plan
|
||||
user: req.session.user,
|
||||
plan: plan, // This plan object will have the progress from the database
|
||||
geoData: req.session.geoData,
|
||||
assets: userAssets,
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
@@ -111,23 +157,20 @@ module.exports = (middleware, users, plans) => {
|
||||
});
|
||||
|
||||
router.get('/newPlan', (req, res) => {
|
||||
if (!req.session.email) {
|
||||
return res.status(status.Unauthorized).redirect('/login');
|
||||
}
|
||||
if(!req.user.financialData){
|
||||
if(!req.session.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 });
|
||||
res.render('newPlan', {
|
||||
user: req.session.user,
|
||||
errMessage: errMessage,
|
||||
geoData: req.session.geoData
|
||||
});
|
||||
});
|
||||
|
||||
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(),
|
||||
@@ -146,17 +189,17 @@ module.exports = (middleware, users, plans) => {
|
||||
return;
|
||||
}
|
||||
const newPlan = {
|
||||
userEmail: req.user.email,
|
||||
userId: new ObjectId(req.session.user._id),
|
||||
name: value.name,
|
||||
retirementAge: value.retirementAge,
|
||||
retirementExpenses: value.retirementExpenses,
|
||||
retirementAssets: value.retirementAssets,
|
||||
retirementLiabilities: value.retirementLiabilities,
|
||||
progress: "0%"
|
||||
progress: "0"
|
||||
};
|
||||
|
||||
try{
|
||||
await plans.insertOne(newPlan);
|
||||
await plans.insertOne({userId: new ObjectId(req.session.user._id), ...newPlan});
|
||||
req.session.errMessage = "";
|
||||
res.redirect('/plans');
|
||||
}
|
||||
@@ -168,24 +211,38 @@ module.exports = (middleware, users, plans) => {
|
||||
});
|
||||
|
||||
router.get('/more', (req, res) => {
|
||||
res.render('more', { user: req.user });
|
||||
res.render('more', {
|
||||
user: req.session.user,
|
||||
geoData: req.session.geoData
|
||||
});
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
router.get('/profile', (req, res) => {
|
||||
res.render('profile', { user: req.user, errMessage: req.session.errMessage });
|
||||
res.render('profile', {
|
||||
user: req.session.user,
|
||||
errMessage: req.session.errMessage,
|
||||
geoData: req.session.geoData
|
||||
});
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
router.get('/settings', (req, res) => {
|
||||
res.render('settings', { user: req.user });
|
||||
res.render('settings', {
|
||||
user: req.session.user,
|
||||
geoData: req.session.geoData
|
||||
});
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
router.get('/questionnaire', (req, res) => {
|
||||
const errMessage = req.session.errMessage;
|
||||
req.session.errMessage = "";
|
||||
res.render('questionnaire', { user: req.user, errMessage: errMessage });
|
||||
res.render('questionnaire', {
|
||||
user: req.session.user,
|
||||
errMessage: errMessage,
|
||||
geoData: req.session.geoData
|
||||
});
|
||||
});
|
||||
|
||||
router.post('/questionnaire', (req, res) => {
|
||||
@@ -212,7 +269,7 @@ module.exports = (middleware, users, plans) => {
|
||||
}
|
||||
|
||||
users.updateOne(
|
||||
{ email: req.session.email },
|
||||
{ _id: new ObjectId(req.session.user._id) },
|
||||
{
|
||||
$set: {
|
||||
financialData: true,
|
||||
@@ -227,15 +284,16 @@ module.exports = (middleware, users, plans) => {
|
||||
}
|
||||
).then((result) => {
|
||||
if (result.matchedCount === 0) {
|
||||
console.log(`User not found during questionnaire update: ${req.session.email}`);
|
||||
console.log(`User not found during questionnaire update: ${req.session.user.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}`);
|
||||
console.log(`User questionnaire data unchanged (already up-to-date): ${req.session.user.email}`);
|
||||
}
|
||||
|
||||
req.session.user.financialData = true;
|
||||
req.session.errMessage = "";
|
||||
res.status(status.Ok).redirect("/home");
|
||||
|
||||
@@ -263,7 +321,6 @@ module.exports = (middleware, users, plans) => {
|
||||
}
|
||||
|
||||
let update = {
|
||||
// email: req.body.email,
|
||||
name: req.body.name,
|
||||
};
|
||||
|
||||
@@ -299,16 +356,185 @@ module.exports = (middleware, users, plans) => {
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/createAsset", async (req, res) => {
|
||||
// Create asset, each asset has different data structure based on type
|
||||
const type = req.body.type;
|
||||
const assetSchema = getAssetSchema(type);
|
||||
|
||||
if (!assetSchema) {
|
||||
console.error("Modified asset type, rejected");
|
||||
req.session.errMessage = "Invalid input";
|
||||
return res.status(status.BadRequest).redirect("/assets");
|
||||
}
|
||||
|
||||
const valid = assetSchema.validate(req.body);
|
||||
|
||||
if (valid.err) {
|
||||
req.session.errMessage = "Invalid input",
|
||||
res.status(status.BadRequest);
|
||||
return res.redirect("/assets");
|
||||
}
|
||||
|
||||
let newAsset = {
|
||||
userId: new ObjectId(req.session.user._id),
|
||||
...req.body,
|
||||
updatedAt: new Date(),
|
||||
};
|
||||
|
||||
if (type == "stock") {
|
||||
newAsset.quantity = parseInt(newAsset.quantity);
|
||||
newAsset.price = parseFloat(newAsset.price)
|
||||
newAsset.value = newAsset.quantity * newAsset.price;
|
||||
newAsset.name = `${newAsset.ticker} Stock`;
|
||||
}
|
||||
newAsset.value = parseFloat(newAsset.value);
|
||||
|
||||
assets.insertOne(newAsset, (err, _) => {
|
||||
if (err) {
|
||||
console.error("Error creating asset: ", err);
|
||||
req.session.errMessage = "Internal server error";
|
||||
return res.status(status.InternalServerError).redirect("/assets");
|
||||
}
|
||||
});
|
||||
|
||||
req.session.errMessage = "";
|
||||
return res.status(status.Ok).redirect("/assets");
|
||||
});
|
||||
|
||||
router.post("/updateAsset", async (req, res) => {
|
||||
const type = req.body.type;
|
||||
const assetSchema = getAssetSchema(type);
|
||||
|
||||
if (!assetSchema) {
|
||||
console.error("Modified asset type, rejected");
|
||||
req.session.errMessage = "Invalid input";
|
||||
return res.status(status.BadRequest).redirect("/assets");
|
||||
}
|
||||
|
||||
const valid = assetSchema.validate(req.body);
|
||||
|
||||
if (valid.err) {
|
||||
req.session.errMessage = "Invalid input",
|
||||
res.status(status.BadRequest);
|
||||
return res.redirect("/assets");
|
||||
}
|
||||
|
||||
if (req.body.userId != req.session.user._id) {
|
||||
req.session.errMessage = "Cannot change asset owner",
|
||||
res.status(status.BadRequest);
|
||||
return res.redirect("/assets");
|
||||
}
|
||||
|
||||
let update = { ...req.body, updatedAt: new Date() };
|
||||
if (type == "stock") {
|
||||
update.quantity = parseInt(update.quantity);
|
||||
update.price = parseFloat(update.price)
|
||||
update.value = update.quantity * update.price;
|
||||
update.name = `${update.ticker} Stock`;
|
||||
}
|
||||
update.value = parseFloat(update.value);
|
||||
delete update.id
|
||||
|
||||
assets.updateOne(
|
||||
{ "_id": new ObjectId(req.body.id) },
|
||||
{ $set: update },
|
||||
).then((result) => {
|
||||
if (result.matchedCount === 0) {
|
||||
console.log(`Asset not found: ${req.body.id}`);
|
||||
req.session.errMessage = "Unable to update asset";
|
||||
return res.status(status.NotFound).redirect("/assets");
|
||||
}
|
||||
if (result.modifiedCount === 0 && result.matchedCount === 1) {
|
||||
console.log(`Asset data unchanged (already up-to-date): ${req.body.id}`);
|
||||
}
|
||||
|
||||
req.session.errMessage = "";
|
||||
return res.status(status.Ok).redirect("/assets");
|
||||
|
||||
}).catch((err) => {
|
||||
console.error("Error updating asset: ", err);
|
||||
req.session.errMessage = "An error occurred while saving your information. Please try again.";
|
||||
return res.status(status.InternalServerError).redirect("/assets");
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/deleteAsset", (req, res) => {
|
||||
const id = new ObjectId(req.body.id);
|
||||
|
||||
assets.deleteOne(
|
||||
{ "_id": id }
|
||||
).then((result) => {
|
||||
if (result.deletedCount === 0) {
|
||||
console.error(`Asset not found: ${req.body.id}`);
|
||||
req.session.errMessage = "Unable to delete asset. Please try again.";
|
||||
return res.status(status.NotFound).redirect("/assets");
|
||||
}
|
||||
|
||||
if (!result.acknowledged) {
|
||||
console.error("Error deleting asset: ", err);
|
||||
req.session.errMessage = "An error occurred while deleting an asset. Please try again.";
|
||||
return res.status(status.InternalServerError).redirect("/assets");
|
||||
}
|
||||
|
||||
req.session.errMessage = "";
|
||||
return res.status(status.Ok).redirect("/assets");
|
||||
|
||||
}).catch((err) => {
|
||||
console.error("Error deleting asset: ", err);
|
||||
req.session.errMessage = "An error occurred while deleting an asset. Please try again.";
|
||||
return res.status(status.InternalServerError).redirect("/assets");
|
||||
});
|
||||
});
|
||||
|
||||
router.post("/deleteUser", (req, res) => {
|
||||
// not as critical if results aren't as expected only if crashing
|
||||
assets.deleteMany({ userId: new ObjectId(req.session.user._id) }).catch((err) => {
|
||||
console.error("Error deleting user assets: ", err);
|
||||
req.session.errMessage = "An error occured while deleting your account. Please try again.";
|
||||
return res.status(status.InternalServerError).redirect("/profile");
|
||||
});
|
||||
|
||||
plans.deleteMany({ userId: new ObjectId(req.session.user._id) }).catch((err) => {
|
||||
console.error("Error deleting user assets: ", err);
|
||||
req.session.errMessage = "An error occured while deleting your account. Please try again.";
|
||||
return res.status(status.InternalServerError).redirect("/profile");
|
||||
});
|
||||
|
||||
users.deleteOne(
|
||||
{ _id: new ObjectId(req.session.user._id) },
|
||||
).then((result) => {
|
||||
if (result.deletedCount === 0) {
|
||||
console.error(`User not found: ${req.body.id}`);
|
||||
req.session.errMessage = "Unabled to delete account. Please try again.";
|
||||
return res.status(status.NotFound).redirect("/profile");
|
||||
}
|
||||
|
||||
if (!result.acknowledged) {
|
||||
console.error("Error deleting user: ", err);
|
||||
req.session.errMessage = "An error occured while deleting your account. Please try again.";
|
||||
return res.status(status.InternalServerError).redirect("/profile");
|
||||
}
|
||||
|
||||
// Direct to logout to destroy session
|
||||
req.session.destroy();
|
||||
return res.status(status.Ok).redirect("/signup");
|
||||
}).catch((err) => {
|
||||
console.error("Error deleting user: ", err);
|
||||
req.session.errMessage = "An error occured while deleting your account. Please try again.";
|
||||
return res.status(status.InternalServerError).redirect("/profile");
|
||||
});
|
||||
});
|
||||
router.get("/exRates/:lat/:lon", async (req, res) => {
|
||||
if (!req.session.geoData.country) {
|
||||
const response = await fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${req.params.lat},${req.params.lon}&result_type=country&key=${process.env.geolocation_api}`);
|
||||
const response = await fetch(`https://maps.googleapis.com/maps/api/geocode/json?latlng=${req.params.lat},${req.params.lon}&result_type=country&key=${process.env.GEOLOCATION_API}`);
|
||||
const data = await response.json();
|
||||
|
||||
country = data.results[0].formatted_address;
|
||||
let results = await getRates(country);
|
||||
req.session.geoData = {
|
||||
country: results.abbreviation,
|
||||
toCurrencyRates: results.exRates
|
||||
toCurrencyRates: results.exRates,
|
||||
geoData: req.session.geoData
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
const ObjectId = require('mongodb').ObjectId;
|
||||
|
||||
async function calculatePlanProgress(plans, assets, userId) {
|
||||
if (!plans || typeof plans.retirementAssets === 'undefined') {
|
||||
console.error("Invalid plan document provided to calculatePlanProgress:", plans);
|
||||
return 0;
|
||||
}
|
||||
if (!assets || typeof assets.find !== 'function') {
|
||||
console.error("Invalid assetsCollection provided to calculatePlanProgress");
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
const userAssets = await assets.find({ userId: new ObjectId(userId) }).toArray();
|
||||
const totalUserAssetValue = userAssets.reduce((total, asset) => total + asset.value, 0);
|
||||
let percentage = 0;
|
||||
|
||||
if (plans.retirementAssets > 0) {
|
||||
percentage = (totalUserAssetValue / plans.retirementAssets) * 100;
|
||||
}
|
||||
return percentage;
|
||||
} catch (err) {
|
||||
console.error("Error in calculatePlanProgress:", err);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
async function updatePlanProgressInDB(planId, percentage, plans) {
|
||||
if (!plans || typeof plans.updateOne !== 'function') {
|
||||
console.error("Error with the plans collection");
|
||||
return;
|
||||
}
|
||||
if (typeof percentage !== 'number' || isNaN(percentage)) {
|
||||
console.error(`Error with the percentage: ${percentage}`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await plans.updateOne({ _id: new ObjectId(planId) }, { $set: { progress: parseFloat(percentage.toFixed(2)) } });
|
||||
} catch (err) {
|
||||
console.error("Error in updatePlanProgressInDB:", err);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { calculatePlanProgress, updatePlanProgressInDB };
|
||||
+335
-1
@@ -2,8 +2,342 @@
|
||||
<%- include("./partials/header") %>
|
||||
|
||||
<main>
|
||||
The Assets Page
|
||||
|
||||
<!-- Create Asset popup Modal -->
|
||||
<dialog id="create-asset-modal" class="w-lg mx-auto bg-white p-8 mt-10 rounded-lg shadow-md">
|
||||
<div class="flex flex-row justify-between">
|
||||
<h2 class="text-lg font-bold mb-2">Create New Asset</h2>
|
||||
<form method="dialog">
|
||||
<button
|
||||
onclick="resetAll()"
|
||||
type="submit"
|
||||
class="text-center py-2 mx-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-pointer"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="my-4">
|
||||
<label class="block text-sm font-medium text-gray-700">Asset Type</label>
|
||||
<div class="mt-1 space-x-4">
|
||||
<label class="inline-flex items-center">
|
||||
<input checked onclick="selectAssetForm('create-other-asset-form')" id="asset-other" type="radio" name="type" value="other" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 cursor-pointer">
|
||||
<span class="ml-2 text-sm text-gray-700">Other Assets</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center">
|
||||
<input onclick="selectAssetForm('create-saving-asset-form')" id="asset-saving" type="radio" name="type" value="saving" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 cursor-pointer">
|
||||
<span class="ml-2 text-sm text-gray-700">Savings</span>
|
||||
</label>
|
||||
<label class="inline-flex items-center">
|
||||
<input onclick="selectAssetForm('create-stock-asset-form')" id="asset-stock" type="radio" name="type" value="stock" class="form-radio h-4 w-4 text-indigo-600 border-gray-300 focus:ring-indigo-500 cursor-pointer">
|
||||
<span class="ml-2 text-sm text-gray-700">Stocks</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Create other asset form -->
|
||||
<form method="POST" action="/createAsset" id="create-other-asset-form">
|
||||
<input style="display: none;" value="other" name="type" type="text">
|
||||
|
||||
<label for="name" class="block text-sm font-medium text-gray-700 mt-2">Asset Name</label>
|
||||
<input required id="name" type="text" name="name" minlength="3" maxlength="30" 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">
|
||||
|
||||
<label for="value" class="block text-sm font-medium text-gray-700 mt-2">Asset Value</label>
|
||||
<input required placeholder="CAD" min="0" id="value" type="number" name="value" 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">
|
||||
|
||||
<label for="purchaseDate" class="block text-sm font-medium text-gray-700 mt-2">Date of Purchase</label>
|
||||
<input required type="date" id="purchaseDate" name="purchaseDate" 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">
|
||||
|
||||
<label for="description" class="block text-sm font-medium text-gray-700 mt-2">Description</label>
|
||||
<textarea maxlength="240" id="description" name="description" rows="4" cols="50" 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"></textarea>
|
||||
|
||||
<div class="mt-6 flex flex-row justify-between">
|
||||
<button
|
||||
type="reset"
|
||||
onclick="document.getElementById('create-other-asset-form').reset()"
|
||||
class="text-center w-sm py-2 mx-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-pointer"
|
||||
>
|
||||
Clear
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
class="text-center w-sm py-2 mx-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-pointer"
|
||||
>
|
||||
Create
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Create savings asset form -->
|
||||
<form style="display: none;" method="POST" action="/createAsset" id="create-saving-asset-form">
|
||||
<input style="display: none;" value="saving" name="type" type="text">
|
||||
|
||||
<label for="name" class="block text-sm font-medium text-gray-700 mt-2">Savings Name</label>
|
||||
<input required id="name" type="text" name="name" minlength="3" maxlength="30" 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">
|
||||
|
||||
<label for="value" class="block text-sm font-medium text-gray-700 mt-2">Savings Value</label>
|
||||
<input required placeholder="CAD" min="0" id="value" type="number" name="value" 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 class="mt-6 flex flex-row justify-between">
|
||||
<button
|
||||
type="reset"
|
||||
onclick="document.getElementById('create-saving-asset-form').reset()"
|
||||
class="text-center w-sm py-2 mx-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-pointer"
|
||||
>
|
||||
Clear
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
class="text-center w-sm py-2 mx-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-pointer"
|
||||
>
|
||||
Create
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Create stock asset form -->
|
||||
<form style="display: none;" method="POST" action="/createAsset" id="create-stock-asset-form">
|
||||
<input style="display: none;" value="stock" name="type" type="text">
|
||||
|
||||
<label for="ticker" class="block text-sm font-medium text-gray-700 mt-2">Stock Ticker</label>
|
||||
<input required id="ticker" type="text" name="ticker" minlength="3" maxlength="5" 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">
|
||||
|
||||
<label for="price" class="block text-sm font-medium text-gray-700 mt-2">Price per Share</label>
|
||||
<input required placeholder="CAD" min="0" id="price" type="number" name="price" 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">
|
||||
|
||||
<label for="quantity" class="block text-sm font-medium text-gray-700 mt-2">Quantity of Shares</label>
|
||||
<input required type="number" min="1" id="quantity" name="quantity" 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">
|
||||
|
||||
<label for="purchaseDate" class="block text-sm font-medium text-gray-700 mt-2">Date of Purchase</label>
|
||||
<input required type="date" id="purchaseDate" name="purchaseDate" 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 class="mt-6 flex flex-row justify-between">
|
||||
<button
|
||||
type="reset"
|
||||
onclick="document.getElementById('create-stock-asset-form').reset()"
|
||||
class="text-center w-sm py-2 mx-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-pointer"
|
||||
>
|
||||
Clear
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
class="text-center w-sm py-2 mx-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-pointer"
|
||||
>
|
||||
Create
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<% 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>
|
||||
<% } %>
|
||||
|
||||
<!-- Main display -->
|
||||
<section>
|
||||
<div class="mt-8 max-w-md mx-auto bg-white px-8 py-6 rounded-lg shadow-md flex flex-col justify-center">
|
||||
<div class="flex flex-row justify-between text-right">
|
||||
<h1 class="text-2xl font-bold tracking-tight leading-none">Assets:</h1>
|
||||
<h1 class="text-xl font-medium tracking-tight leading-none"><%= assets.length %></h1>
|
||||
</div>
|
||||
<div class="flex flex-row justify-between text-right mt-6">
|
||||
<h1 class="text-2xl font-bold tracking-tight leading-none">Total Value:</h1>
|
||||
<h1 class="text-xl font-medium tracking-tight leading-none">
|
||||
<!-- sum of assets array values and formated as proper dollar amount -->
|
||||
$<%= assets.reduce((total, e) => total + e.value, 0).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) %>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="w-md my-6 max-w-md mx-auto px-4 flex flex-row justify-between">
|
||||
<a href="/home" class="text-center w-sm py-2 mx-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">
|
||||
Back to Dashboard
|
||||
</a>
|
||||
<button
|
||||
class="text-center w-sm py-2 py-2 mx-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-pointer"
|
||||
onclick="document.getElementById('create-asset-modal').showModal()"
|
||||
>
|
||||
Add New Asset
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<hr class="h-px my-8 bg-gray-500 border-0 mx-10">
|
||||
|
||||
<!-- list each asset and create hidden popup modal for view/edit -->
|
||||
<section class="mt-6">
|
||||
<% if (assets.length == 0) { %>
|
||||
<div class="max-w-md mx-auto mb-10 rounded-lg shadow-md text-white font-bold bg-red-400 py-4 text-center">
|
||||
You have no assets, create a new asset.
|
||||
</div>
|
||||
<% } %>
|
||||
<% assets.forEach((asset) => { %>
|
||||
<!-- Clickable asset list item -->
|
||||
<div class="mt-4 max-w-md mx-auto bg-white rounded-lg shadow-md">
|
||||
<button onclick="document.getElementById('<%= asset._id %>-modal').showModal()" style="width: 100%; height: 100%;" class="px-4 py-4 cursor-pointer">
|
||||
<div class="flex flex-row justify-between">
|
||||
<div class="flex flex-row justify-between">
|
||||
<div class="mx-2">Icon</div>
|
||||
<div class="mx-2"><h3><%= asset.name %></h3></div>
|
||||
</div>
|
||||
<div>
|
||||
<h3><strong>
|
||||
$<%= asset.value.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}) %>
|
||||
</strong></h3>
|
||||
</div>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Confirm delete asset modal -->
|
||||
<dialog id="<%= asset._id %>-delete-modal" class="w-lg mx-auto bg-transparent p-8 mt-10 rounded-lg shadow-md">
|
||||
<div class="relative p-4 w-full max-w-md h-full md:h-auto">
|
||||
<!-- Modal content -->
|
||||
<div class="relative p-4 text-center bg-white rounded-lg shadow dark:bg-gray-800 sm:p-5">
|
||||
<form method="dialog">
|
||||
<button type="submit" class="text-gray-400 absolute top-2.5 right-2.5 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white">
|
||||
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
|
||||
<span class="sr-only">Close modal</span>
|
||||
</button>
|
||||
</form>
|
||||
<svg class="text-gray-400 dark:text-gray-500 w-11 h-11 mb-3.5 mx-auto" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd"></path></svg>
|
||||
<p class="mb-4 text-gray-500 dark:text-gray-300">Are you sure you want to delete this item?</p>
|
||||
<div class="flex justify-center items-center space-x-4">
|
||||
<div style="width: 100%;">
|
||||
<form method="dialog" style="width: 100%;">
|
||||
<button
|
||||
type="submit"
|
||||
class="py-2 px-3 text-sm font-medium text-gray-500 bg-white rounded-lg border border-gray-200 hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-primary-300 hover:text-gray-900 focus:z-10 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-gray-600"
|
||||
>
|
||||
No, cancel
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div style="width: 100%;">
|
||||
<form method="POST" action="/deleteAsset">
|
||||
<input id="id-delete-<%= asset._id %>" name="id" type="text" hidden value="<%= asset._id %>">
|
||||
<button
|
||||
type="submit"
|
||||
class="py-2 px-3 text-sm font-medium text-center text-white bg-red-600 rounded-lg hover:bg-red-700 focus:ring-4 focus:outline-none focus:ring-red-300 dark:bg-red-500 dark:hover:bg-red-600 dark:focus:ring-red-900"
|
||||
>
|
||||
Yes, I'm sure
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<!-- View/edit popup modal for asset -->
|
||||
<dialog id="<%= asset._id %>-modal" class="w-lg mx-auto bg-white p-8 mt-10 rounded-lg shadow-md">
|
||||
<div class="flex flex-row justify-between">
|
||||
<div style="width: 45%;">
|
||||
<form method="dialog" style="width: 100%;">
|
||||
<button
|
||||
style="width: 100%;"
|
||||
onclick="lockAsset('<%= asset._id %>')"
|
||||
type="submit"
|
||||
class="text-center w-sm py-2 py-2 mx-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-pointer"
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div style="width: 45%;">
|
||||
<button
|
||||
style="width: 100%;"
|
||||
type="submit"
|
||||
class="text-center w-sm py-2 py-2 mx-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 cursor-pointer"
|
||||
onclick="document.getElementById('<%= asset._id %>-delete-modal').showModal()"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
|
||||
<div class="flex flex-row justify-between">
|
||||
<div>
|
||||
ICON
|
||||
</div>
|
||||
<div>
|
||||
<button
|
||||
id="edit-<%= asset._id %>"
|
||||
onclick="unlockAsset('<%= asset._id %>')"
|
||||
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 cursor-pointer"
|
||||
>
|
||||
Edit
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="<%= asset._id %>-form" method="POST" action="/updateAsset">
|
||||
<input id="type-<%= asset._id %>" name="type" type="text" hidden value="<%= asset.type %>">
|
||||
<input id="id-<%= asset._id %>" name="id" type="text" hidden value="<%= asset._id %>">
|
||||
<input id="userId-<%= asset.userId %>" name="userId" type="text" hidden value="<%= asset.userId %>">
|
||||
|
||||
<% if (asset.type != "stock") { %>
|
||||
<label for="name" class="block text-sm font-medium text-gray-700 mt-6">Name</label>
|
||||
<input id="name-<%= asset._id %>" disabled type="text" name="name" value="<%= asset.name %>" class="mt-1 mb-2 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">
|
||||
<% } else { %>
|
||||
<label for="ticker" class="block text-sm font-medium text-gray-700 mt-2">Stock Ticker</label>
|
||||
<input id="ticker-<%= asset._id %>" disabled type="text" name="ticker" value="<%= asset.ticker %>" class="mt-1 mb-2 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">
|
||||
<% } %>
|
||||
|
||||
<hr class="h-px mt-6 mb-4 bg-gray-500 border-0 mx-10">
|
||||
|
||||
<% if (asset.type != "stock") { %>
|
||||
<label for="value" class="block text-sm font-medium text-gray-700">Value</label>
|
||||
<input id="value-<%= asset._id %>" disabled type="number" name="value" value="<%= asset.value %>" 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">
|
||||
<% } else { %>
|
||||
<label for="price" class="block text-sm font-medium text-gray-700 mt-2">Price per Share</label>
|
||||
<input id="price-<%= asset._id %>" disabled type="number" name="price" value="<%= asset.price %>" 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="quantity" class="block text-sm font-medium text-gray-700 mt-2">Quantity of Shares</label>
|
||||
<input id="quantity-<%= asset._id %>" disabled type="number" name="quantity" value="<%= asset.quantity %>" 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">
|
||||
<% } %>
|
||||
|
||||
<% if (asset.type == "other") { %>
|
||||
<label for="description" class="block text-sm font-medium text-gray-700 mt-2">Description</label>
|
||||
<textarea disabled maxlength="240" id="description-<%= asset._id %>" name="description" rows="4" cols="50" 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"><%= asset.description %></textarea>
|
||||
<% } %>
|
||||
|
||||
<% if (asset.type != "saving") { %>
|
||||
<label for="purchaseDate" class="block text-sm font-medium text-gray-700 mt-2">Purchased on</label>
|
||||
<input id="purchaseDate-<%= asset._id %>" disabled type="date" name="purchaseDate" value="<%= asset.purchaseDate %>" 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">
|
||||
<% } %>
|
||||
|
||||
<br>
|
||||
<small class="block text-sm font-medium text-gray-700">Last Modified: <%= asset.updatedAt %></small>
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<button id="save-<%= asset._id %>" 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>
|
||||
</dialog>
|
||||
<% }) %>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<div class="mt-20"></div>
|
||||
|
||||
<script src="/static/scripts/assetManager.js"></script>
|
||||
<script>
|
||||
// Ensure all assets popup modals are locked and reset on page load
|
||||
let assetIds = [];
|
||||
<% assets.forEach((asset) => { %>
|
||||
assetIds.push("<%= asset._id %>");
|
||||
<% }) %>
|
||||
// EJS or JS may say this is an error above.
|
||||
// I assure you its not, just leave it be.
|
||||
|
||||
assetIds.forEach((id) => lockAsset(id));
|
||||
</script>
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -2,7 +2,6 @@
|
||||
<%- 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>
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
<%- include("./partials/fileHeader") %>
|
||||
<%- include("./partials/headerStart") %>
|
||||
|
||||
<main>
|
||||
<section class="bg-center bg-no-repeat bg-cover bg-[url('/images/bg1.jpg')] bg-gray-400 bg-blend-multiply">
|
||||
<div class="px-4 mx-auto max-w-screen-xl text-center py-24 lg:py-56">
|
||||
<h1 class="mb-4 text-4xl font-extrabold tracking-tight leading-none text-white md:text-5xl lg:text-6xl">404 - Not found</h1>
|
||||
<p class="mb-8 text-lg font-normal text-gray-300 lg:text-xl sm:px-16 lg:px-48">It appears you stumbled accross a misleading page.</p>
|
||||
<div class="flex flex-col space-y-4 sm:flex-row sm:justify-center sm:space-y-0">
|
||||
<a href="/" class="inline-flex justify-center items-center py-3 px-5 text-base font-medium text-center text-white rounded-lg bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 dark:focus:ring-blue-900">
|
||||
Go home
|
||||
<svg class="w-3.5 h-3.5 ms-2 rtl:rotate-180" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 10">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M1 5h12m0 0L9 1m4 4L9 9"/>
|
||||
</svg>
|
||||
</a>
|
||||
<a href="/aboutUs" class="inline-flex justify-center hover:text-gray-900 items-center py-3 px-5 sm:ms-4 text-base font-medium text-center text-white rounded-lg border border-white hover:bg-gray-100 focus:ring-4 focus:ring-gray-400">
|
||||
Learn more
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -22,7 +22,7 @@
|
||||
<p id="flagTag"></p>
|
||||
</div>
|
||||
<div class="relative w-full">
|
||||
<p id="exchange1" class="block text-center p-2.5 w-30 z-20 text-sm text-gray-900 bg-gray-50 border-s-0 border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-s-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:border-blue-500">
|
||||
<p id="exchange" class="block text-center p-2.5 w-30 z-20 text-sm text-gray-900 bg-gray-50 border-s-0 border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-s-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:border-blue-500">
|
||||
</p>
|
||||
</div>
|
||||
<button id="dropdown-country-button" value="" data-dropdown-toggle="dropdown-country" class="shrink-0 z-10 inline-flex items-center py-2.5 px-4 text-sm font-medium text-center text-gray-900 bg-gray-100 border border-gray-300 rounded-e-lg hover:bg-gray-200 focus:ring-4 focus:outline-none focus:ring-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 dark:focus:ring-gray-700 dark:text-white dark:border-gray-600" type="button">
|
||||
@@ -45,7 +45,7 @@
|
||||
<p id="flagTag"></p>
|
||||
</div>
|
||||
<div class="relative w-full">
|
||||
<p class="block text-center p-2.5 w-30 z-20 text-sm text-gray-900 bg-gray-50 border-s-0 border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-s-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:border-blue-500">
|
||||
<p id="exchange" class="block text-center p-2.5 w-30 z-20 text-sm text-gray-900 bg-gray-50 border-s-0 border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-s-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:border-blue-500">
|
||||
$1.00 = $<%= (1 * geoData.toCurrencyRates["USD"]).toFixed(2) %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
<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>
|
||||
<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 class="bg-blue-600 h-3 rounded-full dark:bg-blue-500" style="width: <%= plan.progress %>%;"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -25,11 +25,11 @@
|
||||
<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>
|
||||
<p class="mt-1 text-md text-gray-900 dark:text-white"><%= assets.length %></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>
|
||||
<p class="mt-1 text-md text-gray-900 dark:text-white"><%= assets.reduce((total, asset) => total + asset.value, 0) %></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
<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 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>
|
||||
|
||||
@@ -2,6 +2,46 @@
|
||||
<%- include("./partials/header") %>
|
||||
|
||||
<main>
|
||||
<!-- Confirm delete account modal -->
|
||||
<dialog id="delete-warning-modal" class="w-lg mx-auto bg-transparent p-8 mt-10 rounded-lg shadow-md">
|
||||
<div class="relative p-4 w-full max-w-md h-full md:h-auto">
|
||||
<!-- Modal content -->
|
||||
<div class="relative p-4 text-center bg-white rounded-lg shadow dark:bg-gray-800 sm:p-5">
|
||||
<form method="dialog">
|
||||
<button type="submit" class="text-gray-400 absolute top-2.5 right-2.5 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white">
|
||||
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg>
|
||||
<span class="sr-only">Close modal</span>
|
||||
</button>
|
||||
</form>
|
||||
<svg class="text-gray-400 dark:text-gray-500 w-11 h-11 mb-3.5 mx-auto" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" clip-rule="evenodd"></path></svg>
|
||||
<p class="mb-4 text-gray-500 dark:text-gray-300">Are you sure you want to delete you account? This process cannot be undone.</p>
|
||||
<div class="flex justify-center items-center space-x-4">
|
||||
<div style="width: 100%;">
|
||||
<form method="dialog" style="width: 100%;">
|
||||
<button
|
||||
type="submit"
|
||||
class="py-2 px-3 text-sm font-medium text-gray-500 bg-white rounded-lg border border-gray-200 hover:bg-gray-100 focus:ring-4 focus:outline-none focus:ring-primary-300 hover:text-gray-900 focus:z-10 dark:bg-gray-700 dark:text-gray-300 dark:border-gray-500 dark:hover:text-white dark:hover:bg-gray-600 dark:focus:ring-gray-600"
|
||||
>
|
||||
No, cancel
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
<div style="width: 100%;">
|
||||
<form method="POST" action="/deleteUser">
|
||||
<input id="id" name="id" type="text" hidden value="<%= user._id %>">
|
||||
<button
|
||||
type="submit"
|
||||
class="py-2 px-3 text-sm font-medium text-center text-white bg-red-600 rounded-lg hover:bg-red-700 focus:ring-4 focus:outline-none focus:ring-red-300 dark:bg-red-500 dark:hover:bg-red-600 dark:focus:ring-red-900"
|
||||
>
|
||||
Yes, I'm sure
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<h2 class="ml-11 mt-5 mb-6 text-xl font-semibold mb-4 text-white">Welcome <%= user.name %></h2>
|
||||
|
||||
<% if (errMessage != "") { %>
|
||||
@@ -32,6 +72,17 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-row justify-center mx-auto p8">
|
||||
<button
|
||||
type="submit"
|
||||
class="w-xs p-3 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-red-600 hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 cursor-pointer"
|
||||
onclick="document.getElementById('delete-warning-modal').showModal()"
|
||||
>
|
||||
Delete Account
|
||||
</button>
|
||||
</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">
|
||||
|
||||
Reference in new issue
Block a user