Compare commits

...

5 Commits

Author SHA1 Message Date
Aakash Mittal 68d81f8e1c a 2025-11-24 16:53:28 +05:30
Aakash Mittal 5f50082f87 Added projects in dashboard 2025-11-24 16:47:53 +05:30
=bhagwanSingh 599779ee8e a 2025-11-24 16:41:45 +05:30
=bhagwanSingh dcda1629ff Merge branch 'merge2' 2025-11-24 13:47:32 +05:30
=bhagwanSingh 52e4eb8133 s 2025-11-24 13:43:23 +05:30
16 changed files with 622 additions and 259 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules node_modules
logs logs
.env .env
public/builds

View File

@ -871,7 +871,6 @@ tr[data-vaid]:hover {
.project-name { .project-name {
font-weight: 600; font-weight: 600;
color: #1f2937;
font-size: 0.9rem; font-size: 0.9rem;
} }
@ -963,7 +962,6 @@ tr[data-vaid]:hover {
} }
} }
/* Modal Styles */
.modal-overlay { .modal-overlay {
display: none; display: none;
position: fixed; position: fixed;
@ -973,125 +971,332 @@ tr[data-vaid]:hover {
height: 100%; height: 100%;
background: rgba(0, 0, 0, 0.5); background: rgba(0, 0, 0, 0.5);
z-index: 1000; z-index: 1000;
justify-content: center; backdrop-filter: blur(5px);
align-items: center;
} }
.modal-content { .modal-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background: white; background: white;
border-radius: 8px; border-radius: 12px;
padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
max-width: 500px;
width: 90%; width: 90%;
max-width: 800px;
max-height: 80vh; max-height: 80vh;
overflow-y: auto; overflow: hidden;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); display: flex;
flex-direction: column;
} }
.modal-header { .modal-header {
padding: 20px 24px;
border-bottom: 1px solid #e5e7eb;
background: #f8fafc;
display: flex; display: flex;
justify-content: between; justify-content: between;
align-items: center; align-items: center;
margin-bottom: 15px;
border-bottom: 1px solid #e5e7eb;
padding-bottom: 10px;
} }
.modal-title { .modal-title {
font-size: 1.25rem; font-size: 1.5rem;
font-weight: 600; font-weight: 600;
color: #1f2937;
margin: 0; margin: 0;
} }
.close-modal { .modal-close {
background: none; background: none;
border: none; border: none;
font-size: 1.5rem; font-size: 1.5rem;
cursor: pointer; cursor: pointer;
color: #6b7280; color: #6b7280;
padding: 4px;
border-radius: 4px;
transition: all 0.2s;
} }
.close-modal:hover { .modal-close:hover {
color: #374151; color: #374151;
background: #e5e7eb;
} }
.va-list { .modal-body {
padding: 24px;
overflow-y: auto;
flex-grow: 1;
}
.project-info-section {
margin-bottom: 24px;
padding: 16px;
background: #f8fafc;
border-radius: 8px;
border-left: 4px solid #3b82f6;
}
.project-info-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 16px;
margin-bottom: 16px;
}
.project-info-item {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 10px;
} }
.va-item { .project-info-label {
font-size: 0.875rem;
color: #6b7280;
margin-bottom: 4px;
}
.project-info-value {
font-size: 1rem;
font-weight: 500;
color: #1f2937;
}
.va-section-title {
font-size: 1.25rem;
font-weight: 600;
color: #1f2937;
margin-bottom: 16px;
display: flex; display: flex;
justify-content: space-between;
align-items: center; align-items: center;
padding: 10px; gap: 8px;
border: 1px solid #e5e7eb; }
border-radius: 6px;
.va-count-badge {
background: #3b82f6;
color: white;
padding: 2px 8px;
border-radius: 12px;
font-size: 0.75rem;
font-weight: 500;
}
.va-table {
width: 100%;
border-collapse: collapse;
background: white;
border-radius: 8px;
overflow: hidden;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.va-table th {
background: #f8fafc;
padding: 12px 16px;
text-align: left;
font-weight: 600;
color: #374151;
border-bottom: 1px solid #e5e7eb;
font-size: 0.875rem;
}
.va-table td {
padding: 16px;
border-bottom: 1px solid #f3f4f6;
}
.va-table tr:last-child td {
border-bottom: none;
}
.va-table tr:hover {
background: #f9fafb; background: #f9fafb;
} }
.va-info-modal { .va-name {
display: flex;
align-items: center;
gap: 12px;
}
.va-avatar {
width: 40px;
height: 40px;
border-radius: 50%;
background: #3b82f6;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: 600;
font-size: 0.875rem;
text-transform: uppercase;
}
.va-details {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
.va-name-modal { .va-fullname {
font-weight: 600; font-weight: 500;
color: #374151; color: #1f2937;
text-transform: capitalize;
} }
.va-email-modal { .va-email {
font-size: 0.875rem; font-size: 0.875rem;
color: #6b7280; color: #6b7280;
} }
.va-status { .status-badge {
padding: 4px 8px; display: inline-flex;
border-radius: 12px; align-items: center;
font-size: 0.75rem; gap: 6px;
font-weight: 600; padding: 6px 12px;
border-radius: 20px;
font-size: 0.875rem;
font-weight: 500;
} }
.status-active { .status-badge.active {
background: #dcfce7; background: #dcfce7;
color: #166534; color: #166534;
} }
.status-inactive { .status-badge.inactive {
background: #f3f4f6; background: #f3f4f6;
color: #6b7280; color: #6b7280;
} }
/* Project row hover effect */ .status-dot {
.project-row { width: 8px;
cursor: pointer; height: 8px;
transition: background-color 0.2s ease; border-radius: 50%;
} }
.project-row:hover { .status-dot.active {
background-color: #f8fafc; background: #16a34a;
} }
/* Logout button styles */ .status-dot.inactive {
.logout-button { background: #9ca3af;
background: none;
border: none;
color: #ef4444;
cursor: pointer;
padding: 10px;
border-radius: 6px;
transition: background-color 0.2s ease;
text-align: left;
width: 100%;
} }
.logout-button:hover { .activity-status {
background-color: #fef2f2; display: flex;
align-items: center;
gap: 8px;
} }
.logout-container { .activity-dot {
margin-top: auto; width: 8px;
padding: 20px; height: 8px;
border-top: 1px solid #e5e7eb; border-radius: 50%;
animation: pulse 2s infinite;
}
.activity-dot.active {
background: #16a34a;
}
.activity-dot.inactive {
background: #9ca3af;
}
@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}
.no-vas-message {
text-align: center;
padding: 40px 20px;
color: #6b7280;
}
.no-vas-message i {
font-size: 3rem;
margin-bottom: 16px;
color: #d1d5db;
}
/* Responsive Design */
@media (max-width: 768px) {
.modal-content {
width: 95%;
max-height: 90vh;
}
.modal-body {
padding: 16px;
}
.project-info-grid {
grid-template-columns: 1fr;
}
.va-table {
font-size: 0.875rem;
}
.va-table th,
.va-table td {
padding: 12px 8px;
}
}
/* Dark theme support */
[data-theme="dark"] .modal-content {
background: #1f2937;
color: #f9fafb;
}
[data-theme="dark"] .modal-header {
background: #374151;
border-bottom-color: #4b5563;
}
[data-theme="dark"] .modal-title {
color: #f9fafb;
}
[data-theme="dark"] .project-info-section {
background: #374151;
border-left-color: #60a5fa;
}
[data-theme="dark"] .project-info-value {
color: #f9fafb;
}
[data-theme="dark"] .va-section-title {
color: #f9fafb;
}
[data-theme="dark"] .va-table {
background: #374151;
}
[data-theme="dark"] .va-table th {
background: #4b5563;
color: #f9fafb;
border-bottom-color: #6b7280;
}
[data-theme="dark"] .va-table td {
border-bottom-color: #4b5563;
color: #f9fafb;
}
[data-theme="dark"] .va-table tr:hover {
background: #4b5563;
}
[data-theme="dark"] .va-fullname {
color: #f9fafb;
}
[data-theme="dark"] .status-badge.inactive {
background: #4b5563;
color: #d1d5db;
} }

View File

@ -346,6 +346,14 @@
const email = document.getElementById('email').value; const email = document.getElementById('email').value;
const password = document.getElementById('password').value; const password = document.getElementById('password').value;
const confirmPassword = document.getElementById('confirmPassword').value; const confirmPassword = document.getElementById('confirmPassword').value;
if(!email && !password) {
showError('', 'email', step);
showError('', 'password', step);
showError('Please enter a valid email address and password', 'confirmPassword', step);
isValid = false;
return isValid;
}
// Email validation // Email validation
if (!validateEmail(email)) { if (!validateEmail(email)) {

View File

@ -15,7 +15,7 @@ function formatHoursToReadable(hours) {
} }
} }
// Getting client dashboard data - all VAs and projects // Getting client dashboard data - projects with assigned VA details
async function client_dashboard_projects(req, res) { async function client_dashboard_projects(req, res) {
try { try {
const accessToken = req.headers.token; const accessToken = req.headers.token;
@ -31,71 +31,137 @@ async function client_dashboard_projects(req, res) {
} }
const clientEmail = decoded.email; const clientEmail = decoded.email;
// STEP 1: Get client ID from token
const clientUser = await ClientModel.findOne({ "userDetails.email": clientEmail }); const clientUser = await ClientModel.findOne({ "userDetails.email": clientEmail });
if (!clientUser) { if (!clientUser) {
return res.status(404).json({ success: false, message: "Client not found" }); return res.status(404).json({ success: false, message: "Client not found" });
} }
// Get all VA IDs and Project IDs assigned to this client const clientId = clientUser._id;
const clientVaIds = clientUser.vaIds || [];
const clientProjectIds = clientUser.projectIds || [];
// Get all VAs assigned to this client (with required fields only) // STEP 2: Find all projects of this client
const allAssignedVAs = await VAModel.find({
_id: { $in: clientVaIds }
})
.select('userDetails.firstName userDetails.lastName userDetails.email')
.lean()
.exec();
// Get All Projects of client with required fields
const clientProjects = await ProjectModel.find({ const clientProjects = await ProjectModel.find({
_id: { $in: clientProjectIds } clientId: clientId
}) })
.select('name hourlyRate vaAssigned dedicatedHours status') .select('name hourlyRate vaAssigned dedicatedHours status')
.lean() .lean()
.exec(); .exec();
allAssignedVAs.forEach(async (va) => { // Get all VA IDs from all projects for activity check
const vaLogs = await LoggedModel.find({ const allProjectVaIds = [];
vaId: va._id, clientProjects.forEach(project => {
vaEmail: va.email if (project.vaAssigned && project.vaAssigned.length > 0) {
}) allProjectVaIds.push(...project.vaAssigned);
}
});
// STEP 3: Get all VAs assigned to these projects
const allAssignedVAs = await VAModel.find({
_id: { $in: allProjectVaIds }
}) })
.select('userDetails.firstName userDetails.lastName userDetails.email status')
.lean()
.exec();
// Format VAs with only required fields // Create a map for quick VA lookup
const vasFormatted = allAssignedVAs.map((va) => ({ const vaMap = allAssignedVAs.reduce((acc, va) => {
id: va._id, acc[va._id.toString()] = va;
firstName: va.userDetails?.firstName || '', return acc;
lastName: va.userDetails?.lastName || '', }, {});
email: va.userDetails?.email || '',
status: va.status || '' // STEP 4: Check VA activity per project
const currentTime = new Date();
// Format projects with assigned VA details
const projectsFormatted = await Promise.all(clientProjects.map(async (project) => {
const assignedVAIds = project.vaAssigned || [];
// Get VA details and check activity for each assigned VA
const assignedVADetails = await Promise.all(assignedVAIds.map(async (vaId) => {
const va = vaMap[vaId.toString()];
if (!va) return null;
// Check if this VA is currently active on THIS specific project
const latestLog = await LoggedModel.findOne({
vaId: vaId,
projectId: project._id,
loggedType: "LOGIN"
}).sort({ time: -1 }).lean();
let isActive = false;
if (latestLog) {
const loginTime = new Date(latestLog.time);
const hoursSinceLastActivity = (currentTime - loginTime) / (1000 * 60 * 60);
if (hoursSinceLastActivity <= 24) {
isActive = true;
}
}
return {
id: va._id,
firstName: va.userDetails?.firstName || '',
lastName: va.userDetails?.lastName || '',
email: va.userDetails?.email || '',
status: va.status || '',
isActive: isActive
};
}));
// Filter out null entries and count active VAs
const validVADetails = assignedVADetails.filter(Boolean);
const activeVAsCount = validVADetails.filter(va => va.isActive).length;
return {
id: project._id,
name: project.name,
hourlyRate: project.hourlyRate,
vaAssigned: validVADetails.length,
activeVAs: activeVAsCount,
dedicatedHours: formatHoursToReadable(project.dedicatedHours) || "0h",
status: project.status || '',
assignedVADetails: validVADetails
};
})); }));
// Format projects with only required fields // Calculate summary counts
const projectsFormatted = clientProjects.map((project) => ({ const totalProjects = projectsFormatted.length;
id: project._id,
name: project.name, // Count total unique VAs across all projects
hourlyRate: project.hourlyRate, const allVAsAcrossProjects = new Set();
vaAssigned: project.vaAssigned.length || 0, projectsFormatted.forEach(project => {
dedicatedHours: formatHoursToReadable(project.dedicatedHours) || 0, project.assignedVADetails.forEach(va => {
status: project.status || '' allVAsAcrossProjects.add(va.id);
})); });
});
// Count total active VAs (across all projects)
const totalActiveVAs = new Set();
projectsFormatted.forEach(project => {
project.assignedVADetails.forEach(va => {
if (va.isActive) {
totalActiveVAs.add(va.id);
}
});
});
const projectsWithActiveVAs = projectsFormatted.filter(project => project.activeVAs > 0).length;
return res.status(200).json({ return res.status(200).json({
success: true, success: true,
data: { data: {
vas: vasFormatted,
projects: projectsFormatted projects: projectsFormatted
}, },
counts: { counts: {
totalVAs: vasFormatted.length, totalProjects: totalProjects,
totalProjects: projectsFormatted.length totalVAs: allVAsAcrossProjects.size,
activeVAs: totalActiveVAs.size,
projectsWithActiveVAs: projectsWithActiveVAs
} }
}); });
} catch (error) { } catch (error) {
console.error("Client dashboard error:", error); console.error("Client dashboard projects error:", error);
return res.status(500).json({ return res.status(500).json({
success: false, success: false,
message: "Internal Server Error", message: "Internal Server Error",

View File

@ -1,17 +1,17 @@
import PasswordResetRepository from "../repository/passwordReset.repository.js"; import PasswordResetRepository from "../repository/passwordReset.repository.js";
import PasswordResetService from "../services/passwordReset.service.js"; import PasswordResetService from "../services/passwordReset.service.js";
import EmailService from "../services/email.service.js"; // import EmailService from "../services/email.service.js";
import logger from "../config/logger.js"; import logger from "../config/logger.js";
const passwordResetService = new PasswordResetService( const passwordResetService = new PasswordResetService(
new PasswordResetRepository(), new PasswordResetRepository(),
new EmailService({ // new EmailService({
host: process.env.SMTP_HOST, // host: process.env.SMTP_HOST,
port: process.env.SMTP_PORT, // port: process.env.SMTP_PORT,
user: process.env.SMTP_USER, // user: process.env.SMTP_USER,
pass: process.env.SMTP_PASS, // pass: process.env.SMTP_PASS,
from: process.env.EMAIL_FROM, // from: process.env.EMAIL_FROM,
}) // })
); );
// VA: Request password reset // VA: Request password reset

View File

@ -189,47 +189,47 @@ async function va_project_log_callback(req, res) {
const createdLog = await LoggedModel.create({ loggedType: type, vaId, vaEmail, projectId }) const createdLog = await LoggedModel.create({ loggedType: type, vaId, vaEmail, projectId })
// console.log(createdLog) // console.log(createdLog)
// try { try {
// const salesforceUrl = `${process.env.SF_DOCTRACKER_API_URL}services/apexrest/docva/api/va-project-log`; const salesforceUrl = `${process.env.SF_DOCTRACKER_API_URL}services/apexrest/docva/api/va-project-log`;
// const sfData = { const sfData = {
// "_id": createdLog._id, "_id": createdLog._id,
// "loggedType": type, "loggedType": type,
// "vaId": vaId, "vaId": vaId,
// "vaEmail": vaEmail, "vaEmail": vaEmail,
// "projectId": projectId, "projectId": projectId,
// "time": createdLog.time, "time": createdLog.time,
// } }
// const response = await fetch(salesforceUrl, { const response = await fetch(salesforceUrl, {
// method: 'POST', method: 'POST',
// headers: { headers: {
// 'Content-Type': 'application/json', 'Content-Type': 'application/json',
// // Add any required headers for Salesforce authentication // Add any required headers for Salesforce authentication
// // 'Authorization': 'Bearer ' + process.env.SF_ACCESS_TOKEN // 'Authorization': 'Bearer ' + process.env.SF_ACCESS_TOKEN
// }, },
// body: JSON.stringify(sfData) body: JSON.stringify(sfData)
// }); });
// if (!response.ok) { if (!response.ok) {
// const errorText = await response.text(); const errorText = await response.text();
// throw new Error(`Salesforce API responded with status ${response.status}: ${errorText}`); throw new Error(`Salesforce API responded with status ${response.status}: ${errorText}`);
// } }
// const result = await response.json(); const result = await response.json();
// // console.log("✅ Successfully synced VA data to Salesforce:", result); // console.log("✅ Successfully synced VA data to Salesforce:", result);
// res.status(201).json({ success: true, message: `${type} Successfully`, logId: createdLog._id, SyncSalesforce: result }); res.status(201).json({ success: true, message: `${type} Successfully`, logId: createdLog._id, SyncSalesforce: result });
// } catch (error) { } catch (error) {
// console.error("Failed to sync with Salesforce:", error.message); console.error("Failed to sync with Salesforce:", error.message);
// console.log(error) console.log(error)
// // Create a custom error to distinguish Salesforce errors // Create a custom error to distinguish Salesforce errors
// const salesforceError = new Error(`Salesforce sync failed: ${error.message}`); const salesforceError = new Error(`Salesforce sync failed: ${error.message}`);
// salesforceError.isSalesforceError = true; salesforceError.isSalesforceError = true;
// throw salesforceError; throw salesforceError;
// } }
return res.status(201).send({ success: true, message: `${type} Successfully`, logId: createdLog._id }); // return res.status(201).send({ success: true, message: `${type} Successfully`, logId: createdLog._id });
} catch (error) { } catch (error) {
return res.status(500).send("Internal Server Error"); return res.status(500).send("Internal Server Error");

View File

@ -234,7 +234,7 @@ async function removeEntityRelationships(data) {
}} }}
); );
} }
// Remove projectId from VAs // Remove projectId from VAs
if (vaId && Array.isArray(vaId)) { if (vaId && Array.isArray(vaId)) {
// await VAModel.updateMany( // await VAModel.updateMany(

View File

@ -26,19 +26,6 @@ const app = express();
const server = new createServer(app); const server = new createServer(app);
const io = new Server(server); const io = new Server(server);
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
console.log("⚠️ Certificate error:", url);
// Allow for ngrok only
if (url.includes("ngrok")) {
event.preventDefault();
callback(true); // approve the certificate
} else {
callback(false); // reject others
}
});
app.on('certificate-error', (event, webContents, url, error, certificate, callback) => { app.on('certificate-error', (event, webContents, url, error, certificate, callback) => {
console.log("⚠️ Certificate error:", url); console.log("⚠️ Certificate error:", url);
@ -90,10 +77,11 @@ app.get('/varegister/:sf_token?', (req, res) => {
const { sf_token } = req.params; const { sf_token } = req.params;
try { try {
const decoded = jwt.verify(sf_token, process.env.JWT_SECRET_SF_TOKEN); // const decoded = jwt.verify(sf_token, process.env.JWT_SECRET_SF_TOKEN);
if (decoded) { if (decoded) {
res.render('va_register', { title: "VA Registration" }); const email = decoded.email;
res.render('va_register', { title: "VA Registration", email });
} else { } else {
res.render('not_found', { title: "VA Registration" }); res.render('not_found', { title: "VA Registration" });
} }
@ -114,7 +102,8 @@ app.get('/clientregister/:sf_token?', (req, res) => {
const decoded = jwt.verify(sf_token, process.env.JWT_SECRET_SF_TOKEN); const decoded = jwt.verify(sf_token, process.env.JWT_SECRET_SF_TOKEN);
if (decoded) { if (decoded) {
res.render('va_client_register', { title: "Client Registration" }); const email = decoded.email;
res.render('va_client_register', { title: "Client Registration", email });
} else { } else {
res.render('not_found', { title: "Client Registration" }); res.render('not_found', { title: "Client Registration" });
} }

View File

@ -2,25 +2,26 @@ import jwt from "jsonwebtoken";
import bcrypt from "bcrypt"; import bcrypt from "bcrypt";
import { VAModel, ClientModel } from "../models/vaModel.js"; import { VAModel, ClientModel } from "../models/vaModel.js";
import logger from "../config/logger.js"; import logger from "../config/logger.js";
import axios from "axios";
class PasswordResetService { class PasswordResetService {
constructor(passwordResetRepository, emailService) { constructor(passwordResetRepository) {
this.passwordResetRepository = passwordResetRepository; this.passwordResetRepository = passwordResetRepository;
this.emailService = emailService; // this.emailService = emailService;
} }
async requestPasswordReset(email, userType) { async requestPasswordReset(email, userType) {
try { try {
// Determine which model to use // Determine which model to use
const userModel = userType === 'va' ? VAModel : ClientModel; const userModel = userType === 'va' ? VAModel : ClientModel;
// Check if user exists // Check if user exists
const user = await userModel.findOne({ "userDetails.email": email.toLowerCase() }); const user = await userModel.findOne({ "userDetails.email": email.toLowerCase() });
if (!user) { if (!user) {
logger.info(`Password reset requested for non-existent ${userType}: ${email}`); logger.info(`Password reset requested for non-existent ${userType}: ${email}`);
return { return {
success: false, success: false,
message: "Email not recognized. Please sign up to continue." message: "Email not recognized. Please sign up to continue."
}; };
} }
@ -29,7 +30,7 @@ class PasswordResetService {
// Generate JWT token // Generate JWT token
const token = jwt.sign( const token = jwt.sign(
{ {
email: email.toLowerCase(), email: email.toLowerCase(),
userType: userType, userType: userType,
type: 'password_reset' type: 'password_reset'
@ -60,9 +61,9 @@ class PasswordResetService {
await this.sendResetEmail(email, resetLink, userType); await this.sendResetEmail(email, resetLink, userType);
logger.info(`Password reset token created for ${userType}: ${email}`); logger.info(`Password reset token created for ${userType}: ${email}`);
return { return {
success: true, success: true,
message: "If the email exists, a reset link has been sent" message: "If the email exists, a reset link has been sent"
}; };
} catch (error) { } catch (error) {
@ -92,10 +93,10 @@ class PasswordResetService {
return { valid: false, message: "Invalid or expired token" }; return { valid: false, message: "Invalid or expired token" };
} }
return { return {
valid: true, valid: true,
email: decoded.email, email: decoded.email,
userType: decoded.userType userType: decoded.userType
}; };
} catch (error) { } catch (error) {
@ -129,7 +130,7 @@ class PasswordResetService {
const userModel = userType === 'va' ? VAModel : ClientModel; const userModel = userType === 'va' ? VAModel : ClientModel;
// Check if user exists and has matching token // Check if user exists and has matching token
const user = await userModel.findOne({ const user = await userModel.findOne({
"userDetails.email": decoded.email, "userDetails.email": decoded.email,
passwordResetToken: token passwordResetToken: token
}); });
@ -150,12 +151,12 @@ class PasswordResetService {
await resetRecord.save(); await resetRecord.save();
// Send confirmation email // Send confirmation email
await this.sendPasswordChangedEmail(decoded.email, userType); // await this.sendPasswordChangedEmail(decoded.email, userType);
logger.info(`Password successfully reset for ${userType}: ${decoded.email}`); logger.info(`Password successfully reset for ${userType}: ${decoded.email}`);
return { return {
success: true, success: true,
message: "Password has been reset successfully" message: "Password has been reset successfully"
}; };
} catch (error) { } catch (error) {
@ -166,16 +167,15 @@ class PasswordResetService {
async sendResetEmail(email, resetLink, userType) { async sendResetEmail(email, resetLink, userType) {
try { try {
const userTypeText = userType === 'va' ? 'Virtual Assistant' : 'Client'; const userTypeText = userType === 'va' ? 'VA' : 'CLIENT';
const emailData = {
to: email,
subject: `${userTypeText} - Password Reset Request`,
html: this.generateResetEmailTemplate(resetLink, userTypeText),
};
await this.emailService.sendEmail(emailData); await axios.post(`${process.env.SF_DOCTRACKER_API_URL}services/apexrest/docva/api/forgot-password`, {
logger.info(`Password reset email sent to ${userType}: ${email}`); data: {
email: email,
url: resetLink,
userType: userTypeText
}
});
} catch (error) { } catch (error) {
logger.error(`PasswordReset Service - sendResetEmail error for ${userType}: ${error.message}`); logger.error(`PasswordReset Service - sendResetEmail error for ${userType}: ${error.message}`);
@ -186,7 +186,7 @@ class PasswordResetService {
async sendPasswordChangedEmail(email, userType) { async sendPasswordChangedEmail(email, userType) {
try { try {
const userTypeText = userType === 'va' ? 'Virtual Assistant' : 'Client'; const userTypeText = userType === 'va' ? 'Virtual Assistant' : 'Client';
const emailData = { const emailData = {
to: email, to: email,
subject: `${userTypeText} - Password Changed Successfully`, subject: `${userTypeText} - Password Changed Successfully`,

View File

@ -272,7 +272,6 @@
<tr> <tr>
<td> <td>
<div class="status-indicator"> <div class="status-indicator">
<div class="status-dot ${statusClass}"></div>
<span class="status-text ${statusClass}">${statusText}</span> <span class="status-text ${statusClass}">${statusText}</span>
</div> </div>
</td> </td>
@ -329,14 +328,14 @@
vaEmptyState.style.display = 'none'; vaEmptyState.style.display = 'none';
// Add event listeners to view links // Add event listeners to view links
document.querySelectorAll('.view-link').forEach(link => { // document.querySelectorAll('.view-link').forEach(link => {
link.addEventListener('click', function(e) { // link.addEventListener('click', function(e) {
e.preventDefault(); // e.preventDefault();
const vaId = this.getAttribute('data-va-id'); // const vaId = this.getAttribute('data-va-id');
// You can update this link as needed // // You can update this link as needed
window.location.href = `/client/virtual-assistants/${vaId}`; // window.location.href = `/client/virtual-assistants/${vaId}`;
}); // });
}); // });
} else { } else {
vaTableBody.innerHTML = ''; vaTableBody.innerHTML = '';
vaTableBody.style.display = 'none'; vaTableBody.style.display = 'none';

View File

@ -132,10 +132,45 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</main> </main>
</div> </div>
<div id="projectModal" class="modal-overlay">
<div class="modal-content">
<div class="modal-header">
<h2 class="modal-title" id="modalProjectName">Project Details</h2>
</div>
<div class="modal-body">
<div class="va-details-section">
<h3 class="va-section-title">
<i class="fas fa-users"></i>
Virtual Assistants
<span class="va-count-badge" id="vaCountBadge">0</span>
</h3>
<div class="va-table-container">
<table class="va-table">
<thead>
<tr>
<th>Virtual Assistant</th>
<th>Status</th>
<th>Activity</th>
</tr>
</thead>
<tbody id="modalVATableBody">
<!-- VA details will be loaded here -->
</tbody>
</table>
<div id="modalNoVAs" class="no-vas-message" style="display: none;">
<i class="fas fa-user-friends"></i>
<h4>No Virtual Assistants</h4>
<p>No VAs are currently assigned to this project.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div> </div>
<script> <script>
// Theme management // Theme management
@ -202,16 +237,107 @@
} }
} }
function createProjectTableRow(project, allVAs) { // Modal management
const projectModal = document.getElementById('projectModal');
const modalClose = document.getElementById('modalClose');
const modalProjectName = document.getElementById('modalProjectName');
const modalVATableBody = document.getElementById('modalVATableBody');
const modalNoVAs = document.getElementById('modalNoVAs');
const vaCountBadge = document.getElementById('vaCountBadge');
function openProjectModal(project) {
// Set project name
modalProjectName.textContent = project.name || 'Unnamed Project';
// Set project info
const hourlyRate = project.hourlyRate ? `$${project.hourlyRate}/hr` : 'Not set';
const dedicatedHours = project.dedicatedHours || 'Not set';
const statusText = project.status === 'ACTIVE' ? 'Active' : 'Inactive';
const statusClass = project.status === 'ACTIVE' ? 'active' : 'inactive';
// Set VA details
const assignedVAs = project.assignedVADetails || [];
vaCountBadge.textContent = assignedVAs.length;
if (assignedVAs.length > 0) {
modalVATableBody.innerHTML = assignedVAs.map(va => createVATableRow(va)).join('');
modalVATableBody.style.display = '';
modalNoVAs.style.display = 'none';
} else {
modalVATableBody.innerHTML = '';
modalVATableBody.style.display = 'none';
modalNoVAs.style.display = 'block';
}
// Show modal
projectModal.style.display = 'block';
document.body.style.overflow = 'hidden';
}
function createVATableRow(va) {
const statusClass = va.status === 'FULLTIME' ? 'active' : 'inactive';
const statusText = va.status === 'FULLTIME' ? 'Full Time' :
va.status === 'PARTTIME' ? 'Part Time' : 'Inactive';
const activityClass = va.isActive ? 'active' : 'inactive';
const activityText = va.isActive ? 'Currently Active' : 'Not Active';
// Get initials for avatar
const initials = (va.firstName?.charAt(0) || '') + (va.lastName?.charAt(0) || '') || 'VA';
return `
<tr>
<td>
<div class="va-name">
<div class="va-avatar">${initials}</div>
<div class="va-details">
<span class="va-fullname">${va.firstName} ${va.lastName}</span>
<span class="va-email">${va.email}</span>
</div>
</div>
</td>
<td>
<div class=" ${statusClass}">
${statusText}
</div>
</td>
<td>
<div class="activity-status">
<div class="activity-dot ${activityClass}"></div>
<span>${activityText}</span>
</div>
</td>
</tr>
`;
}
function closeProjectModal() {
projectModal.style.display = 'none';
document.body.style.overflow = 'auto';
}
// Close modal when clicking outside
projectModal.addEventListener('click', (e) => {
if (e.target === projectModal) {
closeProjectModal();
}
});
// Close modal with escape key
document.addEventListener('keydown', (e) => {
if (e.key === 'Escape' && projectModal.style.display === 'block') {
closeProjectModal();
}
});
function createProjectTableRow(project) {
const statusClass = project.status === 'ACTIVE' ? 'active' : 'inactive'; const statusClass = project.status === 'ACTIVE' ? 'active' : 'inactive';
const statusText = project.status === 'ACTIVE' ? 'Active' : 'Inactive'; const statusText = project.status === 'ACTIVE' ? 'Active' : 'Inactive';
const hourlyRate = project.hourlyRate ? `$${project.hourlyRate}/hr` : '-'; const hourlyRate = project.hourlyRate ? `$${project.hourlyRate}/hr` : '-';
const dedicatedHours = project.dedicatedHours ? `${project.dedicatedHours}` : '-'; const dedicatedHours = project.dedicatedHours ? `${project.dedicatedHours}` : '-';
console.log(project)
console.log(allVAs)
return ` return `
<tr class="project-row" data-project-id="${project.id}" data-project-name="${project.name}"> <tr class="project-row" data-project-id="${project.id}">
<td> <td>
<div class="project-info"> <div class="project-info">
<div class="project-name">${project.name || 'Unnamed Project'}</div> <div class="project-name">${project.name || 'Unnamed Project'}</div>
@ -227,41 +353,15 @@
<span class="dedicated-hours">${dedicatedHours}</span> <span class="dedicated-hours">${dedicatedHours}</span>
</td> </td>
<td> <td>
<div class=""> <div class="status-badge ${statusClass}">
<div class="status-dot ${statusClass}"></div> <div class="status-dot ${statusClass}"></div>
<span class="status-text ${statusClass}">${statusText}</span> <span class="status-text">${statusText}</span>
</div> </div>
</td> </td>
</tr> </tr>
`; `;
} }
// Create VA table row HTML
// function createVATableRow(va) {
// const statusClass = va.status === 'active' ? 'active' : 'inactive';
// const statusText = va.status === 'active' ? 'Active' : 'Inactive';
// const fullName = `${va.firstName || ''} ${va.lastName || ''}`.trim() || 'Unknown';
// return `
// <tr>
// <td>
// <div class="va-info">
// <div class="va-name">${fullName}</div>
// </div>
// </td>
// <td>
// <span class="va-email">${va.email || 'N/A'}</span>
// </td>
// <td>
// <div class="status-indicator">
// <div class="status-dot ${statusClass}"></div>
// <span class="status-text ${statusClass}">${statusText}</span>
// </div>
// </td>
// </tr>
// `;
// }
// Load dashboard data // Load dashboard data
async function loadDashboardData() { async function loadDashboardData() {
try { try {
@ -269,7 +369,6 @@
if (!response) return; if (!response) return;
const result = await response.json(); const result = await response.json();
if (result.success) { if (result.success) {
const data = result.data; const data = result.data;
const counts = result.counts; const counts = result.counts;
@ -281,20 +380,17 @@
const projectsTableBody = document.getElementById('projectsTableBody'); const projectsTableBody = document.getElementById('projectsTableBody');
const projectsEmptyState = document.getElementById('projectsEmptyState'); const projectsEmptyState = document.getElementById('projectsEmptyState');
const projects = data.projects || []; const projects = data.projects || [];
const vas = data.vas || [];
if (projects.length > 0) { if (projects.length > 0) {
projectsTableBody.innerHTML = projects.map(project => createProjectTableRow(project, vas)).join(''); projectsTableBody.innerHTML = projects.map(project => createProjectTableRow(project)).join('');
projectsTableBody.style.display = ''; projectsTableBody.style.display = '';
projectsEmptyState.style.display = 'none'; projectsEmptyState.style.display = 'none';
// Add click event listeners to project rows // Add click event listeners to project rows
document.querySelectorAll('.project-row').forEach(row => { document.querySelectorAll('.project-row').forEach((row, index) => {
row.addEventListener('click', function() { row.addEventListener('click', function() {
const projectId = this.getAttribute('data-project-id'); const project = projects[index];
const projectName = this.getAttribute('data-project-name'); openProjectModal(project);
console.log(projectName)
}); });
}); });
} else { } else {

View File

@ -272,7 +272,6 @@
<tr> <tr>
<td> <td>
<div class="status-indicator"> <div class="status-indicator">
<div class="status-dot ${statusClass}"></div>
<span class="status-text ${statusClass}">${statusText}</span> <span class="status-text ${statusClass}">${statusText}</span>
</div> </div>
</td> </td>
@ -327,16 +326,6 @@
vaTableBody.innerHTML = allVAs.map(va => createVATableRow(va)).join(''); vaTableBody.innerHTML = allVAs.map(va => createVATableRow(va)).join('');
vaTableBody.style.display = ''; vaTableBody.style.display = '';
vaEmptyState.style.display = 'none'; vaEmptyState.style.display = 'none';
// Add event listeners to view links
document.querySelectorAll('.view-link').forEach(link => {
link.addEventListener('click', function(e) {
e.preventDefault();
const vaId = this.getAttribute('data-va-id');
// You can update this link as needed
window.location.href = `/client/virtual-assistants/${vaId}`;
});
});
} else { } else {
vaTableBody.innerHTML = ''; vaTableBody.innerHTML = '';
vaTableBody.style.display = 'none'; vaTableBody.style.display = 'none';

View File

@ -213,7 +213,7 @@
<body> <body>
<div class="logo"> <div class="logo">
<img src="/public/images/logo-white-vertical.svg" alt="DocVA Logo" /> <img id="logo-img" src="/public/images/logo-white-vertical.svg" alt="DocVA Logo" />
</div> </div>
<div class="login-card"> <div class="login-card">
@ -224,7 +224,7 @@
<input type="password" name="password" placeholder="Enter your password *" required /> <input type="password" name="password" placeholder="Enter your password *" required />
<a href="/client/forgot-password" class="forgot">Forgot password?</a> <a href="/client/forgot-password" class="forgot">Forgot password?</a>
<button type="submit" class="btn btn-primary">🔒 Log in using password</button> <button type="submit" class="btn btn-primary">Log in using password</button>
<!-- <div class="divider">OR</div> <!-- <div class="divider">OR</div>
@ -236,6 +236,10 @@
const root = document.documentElement; const root = document.documentElement;
function setTheme(theme) { function setTheme(theme) {
document.getElementById("logo-img").src =
theme === "dark"
? "/public/images/logo-white-vertical.svg"
: "/public/images/logo-colored-vertical.svg";
root.setAttribute("data-theme", theme); root.setAttribute("data-theme", theme);
} }
@ -276,7 +280,7 @@
if (!res.ok) { if (!res.ok) {
throw new Error(data.message || "Login failed"); throw new Error(data.message || "Login failed");
} }
if (data.success) { if (data.success) {
// 🟢 Save token // 🟢 Save token
localStorage.setItem("knoptpq", data.accessToken); localStorage.setItem("knoptpq", data.accessToken);

View File

@ -139,7 +139,7 @@
<script> <script>
const osButtons = document.querySelectorAll(".os-btn"); const osButtons = document.querySelectorAll(".os-btn");
const downloadBtn = document.getElementById("downloadBtn"); const downloadBtn = document.getElementById("downloadBtn");
const version = "<%= version || '3.2.1' %>"; const version = "<%= version || '1.1.1' %>";
let selectedOS = "windows"; let selectedOS = "windows";
@ -171,7 +171,13 @@
// -------- Download -------- // -------- Download --------
downloadBtn.addEventListener("click", () => { downloadBtn.addEventListener("click", () => {
window.location.href = `/download-file?os=${selectedOS}`;
const link = document.createElement("a");
link.href = `/public/builds/build-1.1.1.1/windows/VA Tracker-Setup-1.1.1.exe`;
link.setAttribute("download", "");
link.click()
// window.location.href = ``;
}); });
</script> </script>

View File

@ -107,7 +107,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<div class="input-container"> <div class="input-container">
<input type="email" id="email" class="input-field" placeholder=" " required> <input type="email" id="email" class="input-field" placeholder=" " value="<%= email %>" readonly disabled required>
<label for="email" class="input-label">Email *</label> <label for="email" class="input-label">Email *</label>
</div> </div>
</div> </div>

View File

@ -174,7 +174,7 @@
<form id="account-form"> <form id="account-form">
<div class="form-group"> <div class="form-group">
<div class="input-container"> <div class="input-container">
<input type="email" id="email" class="input-field" placeholder=" " required autocomplete="username"> <input type="email" id="email" class="input-field" placeholder=" " value="<%= email %>" readonly disabled required>
<label for="email" class="input-label">Email Address *</label> <label for="email" class="input-label">Email Address *</label>
</div> </div>
</div> </div>
@ -184,10 +184,6 @@
<input type="password" id="password" class="input-field" placeholder=" " required autocomplete="new-password"> <input type="password" id="password" class="input-field" placeholder=" " required autocomplete="new-password">
<label for="password" class="input-label">Create Password *</label> <label for="password" class="input-label">Create Password *</label>
</div> </div>
<div class="password-actions">
<button type="button" class="password-toggle" onclick="togglePasswordVisibility()">Show Password</button>
<button type="button" class="password-generate" onclick="generatePassword()">Generate Strong Password</button>
</div>
</div> </div>
<div class="form-group"> <div class="form-group">
@ -196,6 +192,10 @@
<label for="confirmPassword" class="input-label">Confirm Password *</label> <label for="confirmPassword" class="input-label">Confirm Password *</label>
</div> </div>
<div class="invalid-feedback" id="password-match-error" style="display: none; color: #dc3545; font-size: 12px; margin-top: 5px;">Passwords do not match</div> <div class="invalid-feedback" id="password-match-error" style="display: none; color: #dc3545; font-size: 12px; margin-top: 5px;">Passwords do not match</div>
<div class="password-actions">
<button type="button" class="password-toggle" onclick="togglePasswordVisibility()">Show Password</button>
<button type="button" class="password-generate" onclick="generatePassword()">Generate Strong Password</button>
</div>
</div> </div>
<div class="form-actions"> <div class="form-actions">
@ -263,7 +263,7 @@
<div class="form-group"> <div class="form-group">
<div class="input-container"> <div class="input-container">
<select id="country" class="select-field" required onchange="handleChangeSelect(this)"> <select id="country" class="select-field" required onchange="handleChangeSelect(this)">
<option value=""></option> <option value="" disabled selected></option>
</select> </select>
<label for="country" class="input-label">Country *</label> <label for="country" class="input-label">Country *</label>
</div> </div>
@ -273,7 +273,7 @@
<div class="form-group"> <div class="form-group">
<div class="input-container"> <div class="input-container">
<select id="state" class="select-field" required onchange="handleChangeSelect(this)"> <select id="state" class="select-field" required onchange="handleChangeSelect(this)">
<option value=""></option> <!-- <option value=""></option> -->
</select> </select>
<label for="state" class="input-label">State / Region *</label> <label for="state" class="input-label">State / Region *</label>
<div class="location-loading" id="state-loading">Loading states...</div> <div class="location-loading" id="state-loading">Loading states...</div>