fixing merge conflicts
No files matched your search
@@ -84,7 +84,7 @@ module.exports = (users) => {
|
||||
financialData: false,
|
||||
}).then((results, err) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
console.error("Error creating user on signup: ", err);
|
||||
res.session.errMessage = "Internal server error";
|
||||
return res.status(status.InternalServerError).redirect("/signup");
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const status = require("../util/statuses");
|
||||
const session = require("express-session");
|
||||
|
||||
// Get all user routes names
|
||||
// Get all names of user routes
|
||||
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]);
|
||||
@@ -12,8 +12,9 @@ const userRoutes = userRouter.stack.map((layer) => layer.route.path.split("/")[1
|
||||
*/
|
||||
const createMiddleware = (users) => {
|
||||
return async (req, res, next) => {
|
||||
// Redirect not found pages to 404 page
|
||||
if (!userRoutes.includes(req.url.split("/")[1])) {
|
||||
// Check if incoming request route exists in user routes
|
||||
// redirect to 404 if not
|
||||
if (!userRoutes.includes(req.url.split("/")[1].split("?")[0])) {
|
||||
return res.status(status.NotFound).redirect("/notFound");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,12 @@ const assetForms = [
|
||||
* resetAll asset creation forms
|
||||
*/
|
||||
function resetAll() {
|
||||
document.getElementById("dropdown-icon-button").innerHTML = `
|
||||
<img src="/static/svgs/icons/Other.svg" class="h-4 w-4 me-2" alt="Other"> Other
|
||||
<svg class="w-2.5 h-2.5 ms-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
||||
</svg>
|
||||
`;
|
||||
document.getElementById("create-other-asset-form").reset();
|
||||
document.getElementById("create-saving-asset-form").reset();
|
||||
document.getElementById("create-stock-asset-form").reset();
|
||||
@@ -40,6 +46,7 @@ function resetRadio() {
|
||||
const assetKeys = {
|
||||
other: [
|
||||
"name",
|
||||
"dropdown-icon-button",
|
||||
"value",
|
||||
"description",
|
||||
"purchaseDate",
|
||||
@@ -59,8 +66,17 @@ const assetKeys = {
|
||||
/**
|
||||
* lockAsset prevents edits to asset view modal
|
||||
* @param {string} assetId
|
||||
* @param {string} icon to defualt to
|
||||
*/
|
||||
function lockAsset(assetId) {
|
||||
function lockAsset(assetId, icon) {
|
||||
let dropdown = document.getElementById(`dropdown-icon-button-${assetId}`);
|
||||
if (dropdown) dropdown.innerHTML = `
|
||||
<img src="/static/svgs/icons/${icon}.svg" class="h-4 w-4 me-2" alt="${icon}"> ${icon}
|
||||
<svg class="w-2.5 h-2.5 ms-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
||||
</svg>
|
||||
`;
|
||||
|
||||
document.getElementById(`${assetId}-form`).reset();
|
||||
|
||||
const type = document.getElementById(`type-${assetId}`).value;
|
||||
@@ -74,14 +90,15 @@ function lockAsset(assetId) {
|
||||
document.getElementById(`save-${assetId}`).classList.add("cursor-not-allowed");
|
||||
|
||||
document.getElementById(`edit-${assetId}`).innerHTML = "Edit";
|
||||
document.getElementById(`edit-${assetId}`).onclick = () => { unlockAsset(assetId) };
|
||||
document.getElementById(`edit-${assetId}`).onclick = () => { unlockAsset(assetId, icon) };
|
||||
}
|
||||
|
||||
/**
|
||||
* unlockAsset allows edits to asset view modal
|
||||
* @param {string} assetId
|
||||
* @param {string} icon to defualt to
|
||||
*/
|
||||
function unlockAsset(assetId) {
|
||||
function unlockAsset(assetId, icon) {
|
||||
const type = document.getElementById(`type-${assetId}`).value;
|
||||
|
||||
assetKeys[type].forEach((key) => {
|
||||
@@ -92,8 +109,40 @@ function unlockAsset(assetId) {
|
||||
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) };
|
||||
document.getElementById(`edit-${assetId}`).innerHTML = "Cancel";
|
||||
document.getElementById(`edit-${assetId}`).onclick = () => { lockAsset(assetId, icon) };
|
||||
}
|
||||
|
||||
/**
|
||||
* autoOpenCreate checks if popup param
|
||||
* in url to auto open create popup
|
||||
*/
|
||||
function autoOpenCreate() {
|
||||
const query = window.location.search;
|
||||
const params = new URLSearchParams(query);
|
||||
|
||||
if (params.has("popup")) {
|
||||
document.getElementById('create-asset-modal').showModal();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* selectIcon updated selected icon while creating
|
||||
* or modifying assets.
|
||||
* @param {button element} selectedIcon
|
||||
* @param {string} assetId
|
||||
*/
|
||||
function selectIcon(selectedIcon, assetId="") {
|
||||
document.getElementById(`dropdown-icon-button${assetId != "" ? "-" : ""}${assetId}`).value = selectedIcon.value;
|
||||
document.getElementById(`icon${assetId != "" ? "-" : ""}${assetId}`).value = selectedIcon.value
|
||||
|
||||
document.getElementById(`dropdown-icon-button${assetId != "" ? "-" : ""}${assetId}`).innerHTML = selectedIcon.innerHTML +
|
||||
`
|
||||
<svg class="w-2.5 h-2.5 ms-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
||||
</svg>
|
||||
`;
|
||||
}
|
||||
|
||||
resetRadio();
|
||||
autoOpenCreate();
|
||||
@@ -37,8 +37,6 @@ function update(data) {
|
||||
|
||||
dropdown.appendChild(listItem);
|
||||
});
|
||||
|
||||
console.log(data);
|
||||
}
|
||||
|
||||
function switchButton(clickedButton) {
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M312 32c-13.3 0-24 10.7-24 24s10.7 24 24 24l25.7 0 34.6 64-149.4 0-27.4-38C191 99.7 183.7 96 176 96l-56 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l43.7 0 22.1 30.7-26.6 53.1c-10-2.5-20.5-3.8-31.2-3.8C57.3 224 0 281.3 0 352s57.3 128 128 128c65.3 0 119.1-48.9 127-112l49 0c8.5 0 16.3-4.5 20.7-11.8l84.8-143.5 21.7 40.1C402.4 276.3 384 312 384 352c0 70.7 57.3 128 128 128s128-57.3 128-128s-57.3-128-128-128c-13.5 0-26.5 2.1-38.7 6L375.4 48.8C369.8 38.4 359 32 347.2 32L312 32zM458.6 303.7l32.3 59.7c6.3 11.7 20.9 16 32.5 9.7s16-20.9 9.7-32.5l-32.3-59.7c3.6-.6 7.4-.9 11.2-.9c39.8 0 72 32.2 72 72s-32.2 72-72 72s-72-32.2-72-72c0-18.6 7-35.5 18.6-48.3zM133.2 368l65 0c-7.3 32.1-36 56-70.2 56c-39.8 0-72-32.2-72-72s32.2-72 72-72c1.7 0 3.4 .1 5.1 .2l-24.2 48.5c-9 18.1 4.1 39.4 24.3 39.4zm33.7-48l50.7-101.3 72.9 101.2-.1 .1-123.5 0zm90.6-128l108.5 0L317 274.8 257.4 192z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M96 0C43 0 0 43 0 96L0 416c0 53 43 96 96 96l288 0 32 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l0-64c17.7 0 32-14.3 32-32l0-320c0-17.7-14.3-32-32-32L384 0 96 0zm0 384l256 0 0 64L96 448c-17.7 0-32-14.3-32-32s14.3-32 32-32zm32-240c0-8.8 7.2-16 16-16l192 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-192 0c-8.8 0-16-7.2-16-16zm16 48l192 0c8.8 0 16 7.2 16 16s-7.2 16-16 16l-192 0c-8.8 0-16-7.2-16-16s7.2-16 16-16z"/></svg>
|
||||
|
After Width: | Height: | Size: 626 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M149.1 64.8L138.7 96 64 96C28.7 96 0 124.7 0 160L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-256c0-35.3-28.7-64-64-64l-74.7 0L362.9 64.8C356.4 45.2 338.1 32 317.4 32L194.6 32c-20.7 0-39 13.2-45.5 32.8zM256 192a96 96 0 1 1 0 192 96 96 0 1 1 0-192z"/></svg>
|
||||
|
After Width: | Height: | Size: 489 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M135.2 117.4L109.1 192l293.8 0-26.1-74.6C372.3 104.6 360.2 96 346.6 96L165.4 96c-13.6 0-25.7 8.6-30.2 21.4zM39.6 196.8L74.8 96.3C88.3 57.8 124.6 32 165.4 32l181.2 0c40.8 0 77.1 25.8 90.6 64.3l35.2 100.5c23.2 9.6 39.6 32.5 39.6 59.2l0 144 0 48c0 17.7-14.3 32-32 32l-32 0c-17.7 0-32-14.3-32-32l0-48L96 400l0 48c0 17.7-14.3 32-32 32l-32 0c-17.7 0-32-14.3-32-32l0-48L0 256c0-26.7 16.4-49.6 39.6-59.2zM128 288a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zm288 32a32 32 0 1 0 0-64 32 32 0 1 0 0 64z"/></svg>
|
||||
|
After Width: | Height: | Size: 713 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M512 80c0 18-14.3 34.6-38.4 48c-29.1 16.1-72.5 27.5-122.3 30.9c-3.7-1.8-7.4-3.5-11.3-5C300.6 137.4 248.2 128 192 128c-8.3 0-16.4 .2-24.5 .6l-1.1-.6C142.3 114.6 128 98 128 80c0-44.2 86-80 192-80S512 35.8 512 80zM160.7 161.1c10.2-.7 20.7-1.1 31.3-1.1c62.2 0 117.4 12.3 152.5 31.4C369.3 204.9 384 221.7 384 240c0 4-.7 7.9-2.1 11.7c-4.6 13.2-17 25.3-35 35.5c0 0 0 0 0 0c-.1 .1-.3 .1-.4 .2c0 0 0 0 0 0s0 0 0 0c-.3 .2-.6 .3-.9 .5c-35 19.4-90.8 32-153.6 32c-59.6 0-112.9-11.3-148.2-29.1c-1.9-.9-3.7-1.9-5.5-2.9C14.3 274.6 0 258 0 240c0-34.8 53.4-64.5 128-75.4c10.5-1.5 21.4-2.7 32.7-3.5zM416 240c0-21.9-10.6-39.9-24.1-53.4c28.3-4.4 54.2-11.4 76.2-20.5c16.3-6.8 31.5-15.2 43.9-25.5l0 35.4c0 19.3-16.5 37.1-43.8 50.9c-14.6 7.4-32.4 13.7-52.4 18.5c.1-1.8 .2-3.5 .2-5.3zm-32 96c0 18-14.3 34.6-38.4 48c-1.8 1-3.6 1.9-5.5 2.9C304.9 404.7 251.6 416 192 416c-62.8 0-118.6-12.6-153.6-32C14.3 370.6 0 354 0 336l0-35.4c12.5 10.3 27.6 18.7 43.9 25.5C83.4 342.6 135.8 352 192 352s108.6-9.4 148.1-25.9c7.8-3.2 15.3-6.9 22.4-10.9c6.1-3.4 11.8-7.2 17.2-11.2c1.5-1.1 2.9-2.3 4.3-3.4l0 3.4 0 5.7 0 26.3zm32 0l0-32 0-25.9c19-4.2 36.5-9.5 52.1-16c16.3-6.8 31.5-15.2 43.9-25.5l0 35.4c0 10.5-5 21-14.9 30.9c-16.3 16.3-45 29.7-81.3 38.4c.1-1.7 .2-3.5 .2-5.3zM192 448c56.2 0 108.6-9.4 148.1-25.9c16.3-6.8 31.5-15.2 43.9-25.5l0 35.4c0 44.2-86 80-192 80S0 476.2 0 432l0-35.4c12.5 10.3 27.6 18.7 43.9 25.5C83.4 438.6 135.8 448 192 448z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M192 64C86 64 0 150 0 256S86 448 192 448l256 0c106 0 192-86 192-192s-86-192-192-192L192 64zM496 168a40 40 0 1 1 0 80 40 40 0 1 1 0-80zM392 304a40 40 0 1 1 80 0 40 40 0 1 1 -80 0zM168 200c0-13.3 10.7-24 24-24s24 10.7 24 24l0 32 32 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-32 0 0 32c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-32-32 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l32 0 0-32z"/></svg>
|
||||
|
After Width: | Height: | Size: 602 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M64 0C28.7 0 0 28.7 0 64L0 352c0 35.3 28.7 64 64 64l176 0-10.7 32L160 448c-17.7 0-32 14.3-32 32s14.3 32 32 32l256 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-69.3 0L336 416l176 0c35.3 0 64-28.7 64-64l0-288c0-35.3-28.7-64-64-64L64 0zM512 64l0 224L64 288 64 64l448 0z"/></svg>
|
||||
|
After Width: | Height: | Size: 491 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M176 24c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40c-35.3 0-64 28.7-64 64l-40 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l40 0 0 56-40 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l40 0 0 56-40 0c-13.3 0-24 10.7-24 24s10.7 24 24 24l40 0c0 35.3 28.7 64 64 64l0 40c0 13.3 10.7 24 24 24s24-10.7 24-24l0-40 56 0 0 40c0 13.3 10.7 24 24 24s24-10.7 24-24l0-40 56 0 0 40c0 13.3 10.7 24 24 24s24-10.7 24-24l0-40c35.3 0 64-28.7 64-64l40 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-40 0 0-56 40 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-40 0 0-56 40 0c13.3 0 24-10.7 24-24s-10.7-24-24-24l-40 0c0-35.3-28.7-64-64-64l0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40-56 0 0-40c0-13.3-10.7-24-24-24s-24 10.7-24 24l0 40-56 0 0-40zM160 128l192 0c17.7 0 32 14.3 32 32l0 192c0 17.7-14.3 32-32 32l-192 0c-17.7 0-32-14.3-32-32l0-192c0-17.7 14.3-32 32-32zm192 32l-192 0 0 192 192 0 0-192z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.0 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M349.4 44.6c5.9-13.7 1.5-29.7-10.6-38.5s-28.6-8-39.9 1.8l-256 224c-10 8.8-13.6 22.9-8.9 35.3S50.7 288 64 288l111.5 0L98.6 467.4c-5.9 13.7-1.5 29.7 10.6 38.5s28.6 8 39.9-1.8l256-224c10-8.8 13.6-22.9 8.9-35.3s-16.6-20.7-30-20.7l-111.5 0L349.4 44.6z"/></svg>
|
||||
|
After Width: | Height: | Size: 477 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M575.8 255.5c0 18-15 32.1-32 32.1l-32 0 .7 160.2c0 2.7-.2 5.4-.5 8.1l0 16.2c0 22.1-17.9 40-40 40l-16 0c-1.1 0-2.2 0-3.3-.1c-1.4 .1-2.8 .1-4.2 .1L416 512l-24 0c-22.1 0-40-17.9-40-40l0-24 0-64c0-17.7-14.3-32-32-32l-64 0c-17.7 0-32 14.3-32 32l0 64 0 24c0 22.1-17.9 40-40 40l-24 0-31.9 0c-1.5 0-3-.1-4.5-.2c-1.2 .1-2.4 .2-3.6 .2l-16 0c-22.1 0-40-17.9-40-40l0-112c0-.9 0-1.9 .1-2.8l0-69.7-32 0c-18 0-32-14-32-32.1c0-9 3-17 10-24L266.4 8c7-7 15-8 22-8s15 2 21 7L564.8 231.5c8 7 12 15 11 24z"/></svg>
|
||||
|
After Width: | Height: | Size: 715 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M128 32C92.7 32 64 60.7 64 96l0 256 64 0 0-256 384 0 0 256 64 0 0-256c0-35.3-28.7-64-64-64L128 32zM19.2 384C8.6 384 0 392.6 0 403.2C0 445.6 34.4 480 76.8 480l486.4 0c42.4 0 76.8-34.4 76.8-76.8c0-10.6-8.6-19.2-19.2-19.2L19.2 384z"/></svg>
|
||||
|
After Width: | Height: | Size: 459 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 576 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M0 112.5L0 422.3c0 18 10.1 35 27 41.3c87 32.5 174 10.3 261-11.9c79.8-20.3 159.6-40.7 239.3-18.9c23 6.3 48.7-9.5 48.7-33.4l0-309.9c0-18-10.1-35-27-41.3C462 15.9 375 38.1 288 60.3C208.2 80.6 128.4 100.9 48.7 79.1C25.6 72.8 0 88.6 0 112.5zM128 416l-64 0 0-64c35.3 0 64 28.7 64 64zM64 224l0-64 64 0c0 35.3-28.7 64-64 64zM448 352c0-35.3 28.7-64 64-64l0 64-64 0zm64-192c-35.3 0-64-28.7-64-64l64 0 0 64zM384 256c0 61.9-43 112-96 112s-96-50.1-96-112s43-112 96-112s96 50.1 96 112zM252 208c0 9.7 6.9 17.7 16 19.6l0 48.4-4 0c-11 0-20 9-20 20s9 20 20 20l24 0 24 0c11 0 20-9 20-20s-9-20-20-20l-4 0 0-68c0-11-9-20-20-20l-16 0c-11 0-20 9-20 20z"/></svg>
|
||||
|
After Width: | Height: | Size: 860 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M280 32c-13.3 0-24 10.7-24 24s10.7 24 24 24l57.7 0 16.4 30.3L256 192l-45.3-45.3c-12-12-28.3-18.7-45.3-18.7L64 128c-17.7 0-32 14.3-32 32l0 32 96 0c88.4 0 160 71.6 160 160c0 11-1.1 21.7-3.2 32l70.4 0c-2.1-10.3-3.2-21-3.2-32c0-52.2 25-98.6 63.7-127.8l15.4 28.6C402.4 276.3 384 312 384 352c0 70.7 57.3 128 128 128s128-57.3 128-128s-57.3-128-128-128c-13.5 0-26.5 2.1-38.7 6L418.2 128l61.8 0c17.7 0 32-14.3 32-32l0-32c0-17.7-14.3-32-32-32l-20.4 0c-7.5 0-14.7 2.6-20.5 7.4L391.7 78.9l-14-26c-7-12.9-20.5-21-35.2-21L280 32zM462.7 311.2l28.2 52.2c6.3 11.7 20.9 16 32.5 9.7s16-20.9 9.7-32.5l-28.2-52.2c2.3-.3 4.7-.4 7.1-.4c35.3 0 64 28.7 64 64s-28.7 64-64 64s-64-28.7-64-64c0-15.5 5.5-29.7 14.7-40.8zM187.3 376c-9.5 23.5-32.5 40-59.3 40c-35.3 0-64-28.7-64-64s28.7-64 64-64c26.9 0 49.9 16.5 59.3 40l66.4 0C242.5 268.8 190.5 224 128 224C57.3 224 0 281.3 0 352s57.3 128 128 128c62.5 0 114.5-44.8 125.8-104l-66.4 0zM128 384a32 32 0 1 0 0-64 32 32 0 1 0 0 64z"/></svg>
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M184 48l144 0c4.4 0 8 3.6 8 8l0 40L176 96l0-40c0-4.4 3.6-8 8-8zm-56 8l0 40L64 96C28.7 96 0 124.7 0 160l0 96 192 0 128 0 192 0 0-96c0-35.3-28.7-64-64-64l-64 0 0-40c0-30.9-25.1-56-56-56L184 0c-30.9 0-56 25.1-56 56zM512 288l-192 0 0 32c0 17.7-14.3 32-32 32l-64 0c-17.7 0-32-14.3-32-32l0-32L0 288 0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-128z"/></svg>
|
||||
|
After Width: | Height: | Size: 584 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M16 64C16 28.7 44.7 0 80 0L304 0c35.3 0 64 28.7 64 64l0 384c0 35.3-28.7 64-64 64L80 512c-35.3 0-64-28.7-64-64L16 64zM224 448a32 32 0 1 0 -64 0 32 32 0 1 0 64 0zM304 64L80 64l0 320 224 0 0-320z"/></svg>
|
||||
|
After Width: | Height: | Size: 423 B |
@@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--><path d="M470.7 9.4c3 3.1 5.3 6.6 6.9 10.3s2.4 7.8 2.4 12.2c0 0 0 .1 0 .1c0 0 0 0 0 0l0 96c0 17.7-14.3 32-32 32s-32-14.3-32-32l0-18.7L310.6 214.6c-11.8 11.8-30.8 12.6-43.5 1.7L176 138.1 84.8 216.3c-13.4 11.5-33.6 9.9-45.1-3.5s-9.9-33.6 3.5-45.1l112-96c12-10.3 29.7-10.3 41.7 0l89.5 76.7L370.7 64 352 64c-17.7 0-32-14.3-32-32s14.3-32 32-32l96 0s0 0 0 0c8.8 0 16.8 3.6 22.6 9.3l.1 .1zM0 304c0-26.5 21.5-48 48-48l416 0c26.5 0 48 21.5 48 48l0 160c0 26.5-21.5 48-48 48L48 512c-26.5 0-48-21.5-48-48L0 304zM48 416l0 48 48 0c0-26.5-21.5-48-48-48zM96 304l-48 0 0 48c26.5 0 48-21.5 48-48zM464 416c-26.5 0-48 21.5-48 48l48 0 0-48zM416 304c0 26.5 21.5 48 48 48l0-48-48 0zm-96 80a64 64 0 1 0 -128 0 64 64 0 1 0 128 0z"/></svg>
|
||||
|
After Width: | Height: | Size: 926 B |
@@ -1,9 +1,12 @@
|
||||
const getRates = require("../util/exchangeRate");
|
||||
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 path = require("path");
|
||||
const joi = require("joi");
|
||||
const fs = require("fs");
|
||||
const salt = 12;
|
||||
|
||||
/**
|
||||
@@ -19,6 +22,7 @@ const getAssetSchema = (type) => {
|
||||
case "other":
|
||||
assetSchema = joi.object({
|
||||
type: joi.string().valid("other", "stock", "saving").required(),
|
||||
icon: joi.string().alphanum().required(),
|
||||
name: joi.string().alphanum().min(3).max(30).required(),
|
||||
value: joi.number().min(0).required(),
|
||||
purchaseDate: joi.date().required(),
|
||||
@@ -60,6 +64,10 @@ const getAssetSchema = (type) => {
|
||||
module.exports = (middleware, users, plans, assets) => {
|
||||
const router = require("express").Router();
|
||||
|
||||
// Create list of icon filenames
|
||||
let icons = fs.readdirSync(path.join(__dirname, "../public/svgs/icons"));
|
||||
icons = icons.map((icon) => icon.split(".")[0]);
|
||||
|
||||
router.use(middleware);
|
||||
|
||||
router.get('/home', async (req, res) => {
|
||||
@@ -82,19 +90,28 @@ module.exports = (middleware, users, plans, assets) => {
|
||||
user: req.session.user,
|
||||
errMessage: req.session.errMessage,
|
||||
assets: userAssets,
|
||||
geoData: req.session.geoData
|
||||
geoData: req.session.geoData,
|
||||
icons: icons,
|
||||
});
|
||||
return res.status(status.Ok);
|
||||
});
|
||||
|
||||
router.get('/plans', async (req, res) => {
|
||||
try {
|
||||
// console.log(new ObjectId(req.session.user._id));
|
||||
const userPlans = await plans.find({ userId: new ObjectId(req.session.user._id) }).toArray();
|
||||
// console.log(userPlans);
|
||||
const userPlansFromDB = await plans.find({ userId: new ObjectId(req.session.user._id) }).toArray();
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
// Re-fetch plans to get updated progress for rendering
|
||||
const updatedUserPlans = await plans.find({ userId: new ObjectId(req.session.user._id) }).toArray();
|
||||
|
||||
res.render('plans', {
|
||||
user: req.session.user,
|
||||
plans: userPlans,
|
||||
plans: updatedUserPlans, // Send the most up-to-date plans
|
||||
geoData: req.session.geoData
|
||||
});
|
||||
} catch (err) {
|
||||
@@ -108,6 +125,7 @@ module.exports = (middleware, users, plans, assets) => {
|
||||
|
||||
try {
|
||||
const planId = req.params.id;
|
||||
let userAssets = await assets.find({ userId: new ObjectId(req.session.user._id) }).toArray();
|
||||
|
||||
|
||||
if (!ObjectId.isValid(planId)) {
|
||||
@@ -122,11 +140,19 @@ module.exports = (middleware, users, plans, assets) => {
|
||||
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.session.user,
|
||||
plan: plan,
|
||||
geoData: req.session.geoData
|
||||
plan: plan, // This plan object will have the progress from the database
|
||||
geoData: req.session.geoData,
|
||||
assets: userAssets,
|
||||
});
|
||||
|
||||
} catch (err) {
|
||||
@@ -175,7 +201,7 @@ module.exports = (middleware, users, plans, assets) => {
|
||||
retirementExpenses: value.retirementExpenses,
|
||||
retirementAssets: value.retirementAssets,
|
||||
retirementLiabilities: value.retirementLiabilities,
|
||||
progress: "0%"
|
||||
progress: "0"
|
||||
};
|
||||
|
||||
try {
|
||||
@@ -226,8 +252,6 @@ module.exports = (middleware, users, plans, 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(),
|
||||
@@ -368,6 +392,7 @@ module.exports = (middleware, users, plans, assets) => {
|
||||
newAsset.name = `${newAsset.ticker} Stock`;
|
||||
}
|
||||
newAsset.value = parseFloat(newAsset.value);
|
||||
newAsset.icon = type == "stock" ? "Stock" : type == "saving" ? "Coins" : newAsset.icon;
|
||||
|
||||
assets.insertOne(newAsset, (err, _) => {
|
||||
if (err) {
|
||||
@@ -413,7 +438,8 @@ module.exports = (middleware, users, plans, assets) => {
|
||||
update.name = `${update.ticker} Stock`;
|
||||
}
|
||||
update.value = parseFloat(update.value);
|
||||
delete update.id
|
||||
delete update.id;
|
||||
delete update.userId;
|
||||
|
||||
assets.updateOne(
|
||||
{ "_id": new ObjectId(req.body.id) },
|
||||
@@ -504,9 +530,10 @@ module.exports = (middleware, users, plans, assets) => {
|
||||
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;
|
||||
|
||||
@@ -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 };
|
||||
@@ -2,7 +2,6 @@
|
||||
<%- include("./partials/header") %>
|
||||
|
||||
<main>
|
||||
|
||||
<!-- 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">
|
||||
@@ -38,7 +37,31 @@
|
||||
|
||||
<!-- Create other asset form -->
|
||||
<form method="POST" action="/createAsset" id="create-other-asset-form">
|
||||
<input style="display: none;" value="other" name="type" type="text">
|
||||
<input style="display: none;" id="type" value="other" name="type" type="text">
|
||||
<input style="display: none;" id="icon" value="other" name="icon" type="text">
|
||||
|
||||
<label for="name" class="block text-sm font-medium text-gray-700 mt-2">Select an Icon</label>
|
||||
<div class="flex items-center">
|
||||
<button id="dropdown-icon-button" value="" data-dropdown-toggle="dropdown-icons" class="shrink-0 z-10 inline-flex items-center py-2.5 px-4 text-sm font-medium text-center border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" type="button">
|
||||
<img src="/static/svgs/icons/Other.svg" class="h-4 w-4 me-2" alt="Other"> Other
|
||||
<svg class="w-2.5 h-2.5 ms-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
||||
</svg>
|
||||
</button>
|
||||
<div id="dropdown-icons" class="overflow-y-auto h-40 z-10 hidden bg-white divide-y divide-gray-100 rounded-lg shadow-sm w-32 dark:bg-gray-700">
|
||||
<ul id="dropdown" class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdown-icon-button">
|
||||
<% icons.forEach(icon => { %>
|
||||
<li>
|
||||
<button onclick="selectIcon(this)" type="button" value="<%= icon %>" class="inline-flex w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-600 dark:hover:text-white" role="menuitem">
|
||||
<span class="inline-flex items-center">
|
||||
<img src="/static/svgs/icons/<%= icon %>.svg" class="h-4 w-4 me-2" alt="<%= icon %>"> (<%= icon %>)
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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">
|
||||
@@ -178,7 +201,9 @@
|
||||
<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">
|
||||
<img src="/static/svgs/icons/<%= asset.icon %>.svg" class="h-6 w-6 me-2" alt="<%= asset.icon %>">
|
||||
</div>
|
||||
<div class="mx-2"><h3><%= asset.name %></h3></div>
|
||||
</div>
|
||||
<div>
|
||||
@@ -237,7 +262,7 @@
|
||||
<form method="dialog" style="width: 100%;">
|
||||
<button
|
||||
style="width: 100%;"
|
||||
onclick="lockAsset('<%= asset._id %>')"
|
||||
onclick="lockAsset('<%= asset._id %>', '<%= asset.icon %>')"
|
||||
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"
|
||||
>
|
||||
@@ -259,24 +284,52 @@
|
||||
<br>
|
||||
|
||||
<div class="flex flex-row justify-between">
|
||||
<div>
|
||||
ICON
|
||||
</div>
|
||||
<% if (asset.type == "other") { %>
|
||||
<div class="flex items-center">
|
||||
<button id="dropdown-icon-button-<%= asset._id %>" value="" data-dropdown-toggle="dropdown-icons-<%= asset._id %>" class="shrink-0 z-10 inline-flex items-center py-2.5 px-4 text-sm font-medium text-center 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" type="button">
|
||||
<img src="/static/svgs/icons/<%= asset.icon %>.svg" class="h-4 w-4 me-2" alt="<%= asset.icon %>"> <%= asset.icon %>
|
||||
<svg class="w-2.5 h-2.5 ms-2.5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 10 6">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 4 4 4-4"/>
|
||||
</svg>
|
||||
</button>
|
||||
<div id="dropdown-icons-<%= asset._id %>" class="overflow-y-auto h-40 z-10 hidden bg-white divide-y divide-gray-100 rounded-lg shadow-sm w-32 dark:bg-gray-700">
|
||||
<ul id="dropdown-<%= asset._id %>" class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="dropdown-icon-button-<%= asset._id %>">
|
||||
<% icons.forEach(icon => { %>
|
||||
<li>
|
||||
<button onclick="selectIcon(this, '<%= asset._id %>')" type="button" value="<%= icon %>" class="inline-flex w-full px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-200 dark:hover:bg-gray-600 dark:hover:text-white" role="menuitem">
|
||||
<span class="inline-flex items-center">
|
||||
<img src="/static/svgs/icons/<%= icon %>.svg" class="h-4 w-4 me-2" alt="<%= icon %>"> (<%= icon %>)
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
<% }); %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<% } else { %>
|
||||
<button disabled class="inline-flex items-center py-2.5 px-10 text-sm font-medium text-center 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" type="button">
|
||||
<img src="/static/svgs/icons/<%= asset.icon %>.svg" class="h-4 w-4" alt="<%= asset.icon %>">
|
||||
</button>
|
||||
<% } %>
|
||||
|
||||
<h2 class="text-xl font-medium tracking-tight leading-none mt-3"><%= String(asset.type).charAt(0).toUpperCase() + String(asset.type).slice(1); %> Asset</h2>
|
||||
<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"
|
||||
class="py-3 px-8 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>
|
||||
<br>
|
||||
|
||||
<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 %>">
|
||||
<input id="icon-<%= asset._id %>" name="icon" type="text" hidden value="<%= asset.icon %>">
|
||||
|
||||
<% if (asset.type != "stock") { %>
|
||||
<label for="name" class="block text-sm font-medium text-gray-700 mt-6">Name</label>
|
||||
@@ -328,16 +381,12 @@
|
||||
|
||||
<script src="/static/scripts/assetManager.js"></script>
|
||||
<script>
|
||||
// Ensure all assets popup modals are locked and reset on page load
|
||||
let assetIds = [];
|
||||
// Ensure all assets popup modals are locked and reset on page load
|
||||
<% assets.forEach((asset) => { %>
|
||||
assetIds.push("<%= asset._id %>");
|
||||
lockAsset("<%= asset._id %>", "<%= asset.icon %>");
|
||||
<% }) %>
|
||||
// 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/scriptLoader") %>
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -1,15 +1,26 @@
|
||||
<%- include("./partials/fileHeader") %>
|
||||
<%- include("./partials/header") %>
|
||||
|
||||
<main>
|
||||
<!-- 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>
|
||||
<main>
|
||||
<!-- Buttons -->
|
||||
<div class="flex justify-end gap-4 px-5 py-6">
|
||||
<a href="/assets?popup" class="text-center cursor-pointer min-w-[150px] bg-green-600 px-4 py-2 text-white rounded hover:bg-green-800" type="button">Add Asset</a>
|
||||
<a href="/newPlan" class="text-center 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>
|
||||
<!--This is the cards for plans and other things-->
|
||||
<div class="mt-12">
|
||||
@@ -99,15 +110,6 @@
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.js"></script>
|
||||
<script src="/static/scripts/geolocation.js"></script>
|
||||
<!-- <script src="/static/scripts/calcExchange.js"></script> -->
|
||||
<script>
|
||||
// If no geoData provided thorugh EJS, send update request to backend
|
||||
let country = "<%= geoData.country %>";
|
||||
if (!country) getLocation();
|
||||
</script>
|
||||
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/footer") %>
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/scriptLoader") %>
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -6,5 +6,6 @@
|
||||
</main>
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/scriptLoader") %>
|
||||
<%- include("./partials/footer") %>
|
||||
|
||||
@@ -37,4 +37,6 @@
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/scriptLoader") %>
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -6,5 +6,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -0,0 +1,8 @@
|
||||
<!-- Get geolocation if not in session and load conversion rates -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.js"></script>
|
||||
<script src="/static/scripts/geolocation.js"></script>
|
||||
<script>
|
||||
// If no geoData provided thorugh EJS, send update request to backend
|
||||
let country = "<%= geoData.country %>";
|
||||
if (!country) getLocation();
|
||||
</script>
|
||||
@@ -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>
|
||||
@@ -71,4 +71,5 @@
|
||||
</main>
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/scriptLoader") %>
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -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>
|
||||
@@ -21,4 +21,5 @@
|
||||
</main>
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/scriptLoader") %>
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -138,4 +138,5 @@
|
||||
<script src="/static/scripts/profile.js"></script>
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/scriptLoader") %>
|
||||
<%- include("./partials/footer") %>
|
||||
@@ -68,4 +68,6 @@
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<%- include("./partials/navBar") %>
|
||||
<%- include("./partials/scriptLoader") %>
|
||||
<%- include("./partials/footer") %>
|
||||