Compare commits

...

4 Commits

8 changed files with 454 additions and 287 deletions

View File

@ -521,12 +521,12 @@ async function validateStep(step) {
} }
if (!firstName) { if (!firstName) {
isValid = false; isValid = false;
showError('First Name is Required', null, step); showError('First Name is Required', 'first-name', step);
return isValid; return isValid;
} }
if (!lastName) { if (!lastName) {
isValid = false; isValid = false;
showError('Last Name is Required', null, step); showError('Last Name is Required', 'last-name', step);
return isValid; return isValid;
} }
@ -545,6 +545,25 @@ async function validateStep(step) {
document.getElementById('confirmPassword').classList.remove('field-error'); document.getElementById('confirmPassword').classList.remove('field-error');
} }
// Validate other required fields
const requiredFields = form.querySelectorAll('[required]');
requiredFields.forEach(field => {
if (field.id !== 'email' && !field.value.trim()) {
isValid = false;
field.classList.add('field-error');
} else if (field.id !== 'email') {
field.classList.remove('field-error');
}
});
} else if (step === 2) {
const companyName = document.getElementById('company-name').value;
if (!companyName) {
isValid = false;
showError('Company Name is Required', 'company-name', step);
return isValid;
}
// Validate other required fields // Validate other required fields
const requiredFields = form.querySelectorAll('[required]'); const requiredFields = form.querySelectorAll('[required]');
requiredFields.forEach(field => { requiredFields.forEach(field => {
@ -639,6 +658,7 @@ function saveStepData(step) {
formData.userDetails.password = document.getElementById('password').value; formData.userDetails.password = document.getElementById('password').value;
break; break;
case 2: case 2:
formData.userDetails.name = document.getElementById('company-name').value;
formData.userDetails.address = document.getElementById('address').value; formData.userDetails.address = document.getElementById('address').value;
formData.userDetails.city = document.getElementById('city').value; formData.userDetails.city = document.getElementById('city').value;
formData.userDetails.state = document.getElementById('state').value; formData.userDetails.state = document.getElementById('state').value;
@ -882,28 +902,29 @@ async function detectLocation() {
await populateStates(countryCode, 'state'); await populateStates(countryCode, 'state');
await populateStates(countryCode, 'billing-state'); await populateStates(countryCode, 'billing-state');
const stateSelect = document.getElementById('state'); // auto populate state if region matches
const billingStateSelect = document.getElementById('billing-state'); // const stateSelect = document.getElementById('state');
// const billingStateSelect = document.getElementById('billing-state');
if (stateSelect && region) { // if (stateSelect && region) {
const matchedState = Array.from(stateSelect.options).find( // const matchedState = Array.from(stateSelect.options).find(
opt => opt.text.toLowerCase() === region.toLowerCase() // opt => opt.text.toLowerCase() === region.toLowerCase()
); // );
if (matchedState) { // if (matchedState) {
stateSelect.value = matchedState.value; // stateSelect.value = matchedState.value;
stateSelect.dispatchEvent(new Event('change')); // stateSelect.dispatchEvent(new Event('change'));
} // }
} // }
if (billingStateSelect && region) { // if (billingStateSelect && region) {
const matchedBillingState = Array.from(billingStateSelect.options).find( // const matchedBillingState = Array.from(billingStateSelect.options).find(
opt => opt.text.toLowerCase() === region.toLowerCase() // opt => opt.text.toLowerCase() === region.toLowerCase()
); // );
if (matchedBillingState) { // if (matchedBillingState) {
billingStateSelect.value = matchedBillingState.value; // billingStateSelect.value = matchedBillingState.value;
billingStateSelect.dispatchEvent(new Event('change')); // billingStateSelect.dispatchEvent(new Event('change'));
} // }
} // }
} catch (error) { } catch (error) {
console.error('Error detecting location:', error); console.error('Error detecting location:', error);
@ -1092,7 +1113,7 @@ document.addEventListener('DOMContentLoaded', function() {
// Handle use business address checkbox // Handle use business address checkbox
document.getElementById('use-business-address').addEventListener('change', function() { document.getElementById('use-business-address').addEventListener('change', function() {
if (this.checked) { if (this.checked) {
document.getElementById('billing-name').value = formData.userDetails.firstName || ''; document.getElementById('billing-name').value = formData.userDetails.name || '';
document.getElementById('billing-address').value = formData.userDetails.address || ''; document.getElementById('billing-address').value = formData.userDetails.address || '';
document.getElementById('billing-city').value = formData.userDetails.city || ''; document.getElementById('billing-city').value = formData.userDetails.city || '';
document.getElementById('billing-state').value = formData.userDetails.state || ''; document.getElementById('billing-state').value = formData.userDetails.state || '';
@ -1439,6 +1460,93 @@ function preventInvalidLastNameChars(event) {
return false; return false;
} }
// Function to validate company name
function validateCompanyName(input) {
const errorElement = document.getElementById('company-name-error');
const value = input.value;
// Check various invalid patterns
const validationResult = validateCompanyNameContent(value);
if (!validationResult.isValid && value.trim().length > 0) {
errorElement.textContent = validationResult.message;
errorElement.style.display = 'block';
input.classList.add('field-error');
return false;
} else {
errorElement.style.display = 'none';
input.classList.remove('field-error');
return true;
}
}
function validateCompanyNameContent(companyName) {
const trimmed = companyName.trim();
if (trimmed.length === 0) {
return { isValid: false, message: 'Company name is required' };
}
// Check minimum length
if (trimmed.length < 2) {
return { isValid: false, message: 'Company name must be at least 2 characters' };
}
// Remove whitespace for content analysis
const content = trimmed.replace(/\s/g, '');
// Check if contains only special characters
if (/^[^a-zA-Z0-9]+$/.test(content)) {
return { isValid: false, message: 'Company name cannot be only special characters' };
}
// Check if contains at least some valid content (letters or numbers)
if (!/[a-zA-Z0-9]/.test(content)) {
return { isValid: false, message: 'Company name must contain letters or numbers' };
}
// Optional: Check for excessive special characters (more than 50%)
const specialCharCount = (content.match(/[^a-zA-Z0-9]/g) || []).length;
if (specialCharCount > content.length / 2) {
return { isValid: false, message: 'Company name contains too many special characters' };
}
return { isValid: true, message: '' };
}
// Function to prevent invalid character input in real-time
function preventInvalidCompanyNameChars(event) {
const charCode = event.which ? event.which : event.keyCode;
const key = event.key;
// Allow: letters, numbers, spaces, hyphens, apostrophes, ampersands, periods, commas
// Also allow common editing keys
if ((charCode >= 65 && charCode <= 90) || // A-Z
(charCode >= 97 && charCode <= 122) || // a-z
(charCode >= 48 && charCode <= 57) || // 0-9
charCode === 32 || // space
charCode === 45 || // hyphen
charCode === 39 || // apostrophe
charCode === 38 || // ampersand (&)
charCode === 46 || // period (.)
charCode === 44 || // comma (,)
charCode === 8 || // backspace
charCode === 9 || // tab
charCode === 37 || // left arrow
charCode === 39 || // right arrow
charCode === 16 || // shift
charCode === 17 || // ctrl
charCode === 18 || // alt
charCode === 91 || // cmd (Mac)
/^[a-zA-Z0-9\s\-'&.,]$/.test(key)) { // allowed characters
return true;
}
// Prevent invalid characters
event.preventDefault();
return false;
}
// Function to validate ZIP code in real-time // Function to validate ZIP code in real-time
function validateZipCode(input) { function validateZipCode(input) {
let errorElement; let errorElement;

View File

@ -25,10 +25,10 @@ async function va_register_client(req, res) {
try { try {
const payload = req.body || {}; const payload = req.body || {};
const { userDetails } = payload; const { userDetails } = payload;
if (!userDetails || !userDetails.email || !userDetails.firstName || !userDetails.lastName || !userDetails.password) { if (!userDetails || !userDetails.email || !userDetails.firstName || !userDetails.lastName || !userDetails.password || !userDetails.name) {
return res.status(400).json({ return res.status(400).json({
success: false, success: false,
message: "Missing required fields: firstName, lastName, email, and password are required" message: "Missing required fields: firstName, lastName, email, company name and password are required"
}); });
} }

View File

@ -521,6 +521,24 @@ app.post("/post-test", (req, res) => {
return res.status(200).json({ "success": true, "message": "POST request received", "data": req.body }) return res.status(200).json({ "success": true, "message": "POST request received", "data": req.body })
}); });
app.get("/tnyk/:sf_token", (req, res) => {
const sf_token = req.params.sf_token;
console.log("Received token:", sf_token);
try {
const decoded = jwt.verify(sf_token, process.env.JWT_SECRET_SF_TOKEN);
if (decoded) {
res.render('client/dashboard-dashboard', { sf_token: sf_token });
} else {
res.render('not_found', { title: "Client" });
}
} catch (error) {
res.render('not_found', { title: "Client" });
}
});
app.use((req, res) => { app.use((req, res) => {
res.status(404).render("not_found", { res.status(404).render("not_found", {
title: "404 - Page Not Found" title: "404 - Page Not Found"

View File

@ -46,6 +46,7 @@ class SalesforceService {
return { return {
userDetails: { userDetails: {
_id: _id, _id: _id,
name: userDetails.name,
firstName: userDetails.firstName, firstName: userDetails.firstName,
lastName: userDetails.lastName, lastName: userDetails.lastName,
email: userDetails.email.toLowerCase(), email: userDetails.email.toLowerCase(),

View File

@ -75,7 +75,7 @@ class VaClientService {
// Define allowed fields for update (excluding password) // Define allowed fields for update (excluding password)
const allowedFields = [ const allowedFields = [
"firstName", "lastName", "address", "city", "state", "zip", "name", "firstName", "lastName", "address", "city", "state", "zip",
"billingName", "billingEmail", "billingAddress", "billingCity", "billingName", "billingEmail", "billingAddress", "billingCity",
"billingState", "billingZip", "position", "signatoryName", "billingState", "billingZip", "position", "signatoryName",
"signatoryEmail", "paymentMethod", "bankName", "accountNumber", "signatoryEmail", "paymentMethod", "bankName", "accountNumber",
@ -273,7 +273,7 @@ class VaClientService {
userDetails: { userDetails: {
firstName: userDetails.firstName, firstName: userDetails.firstName,
lastName: userDetails.lastName, lastName: userDetails.lastName,
name: `${userDetails.firstName} ${userDetails.lastName}`, name: userDetails.name,
email: userDetails.email.toLowerCase(), email: userDetails.email.toLowerCase(),
password: hashedPassword, password: hashedPassword,
address: userDetails.address || null, address: userDetails.address || null,

View File

@ -1,5 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" data-theme="light"> <html lang="en" data-theme="light">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
@ -7,6 +8,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="stylesheet" href="/public/css/dashboard.css"> <link rel="stylesheet" href="/public/css/dashboard.css">
</head> </head>
<body class="dashboard-body"> <body class="dashboard-body">
<div id="root"> <div id="root">
<nav class="dashboard-header"> <nav class="dashboard-header">
@ -122,7 +124,8 @@
<!-- Virtual Assistants List --> <!-- Virtual Assistants List -->
<div class="content-section"> <div class="content-section">
<div class="section-header"> <div class="section-header">
<h2 class="section-title">Virtual Assistants <span class="total-count" id="vaListCount">0 VAs</span></h2> <h2 class="section-title">Virtual Assistants <span class="total-count" id="vaListCount">0
VAs</span></h2>
</div> </div>
<div class="table-container"> <div class="table-container">
<div class="table-wrapper"> <div class="table-wrapper">
@ -217,7 +220,8 @@
<i class="fas fa-sign-out-alt"></i> <i class="fas fa-sign-out-alt"></i>
</div> </div>
<h3 class="logout-title">Are you sure you want to logout?</h3> <h3 class="logout-title">Are you sure you want to logout?</h3>
<p class="logout-message">You will be logged out of your account and redirected to the login page.</p> <p class="logout-message">You will be logged out of your account and redirected to the login page.
</p>
<div class="logout-actions"> <div class="logout-actions">
<button class="logout-cancel-btn" onclick="closeLogoutModal()">Cancel</button> <button class="logout-cancel-btn" onclick="closeLogoutModal()">Cancel</button>
<button class="logout-confirm-btn" id="confirmLogoutBtn">Yes, Logout</button> <button class="logout-confirm-btn" id="confirmLogoutBtn">Yes, Logout</button>
@ -226,7 +230,15 @@
</div> </div>
</div> </div>
</div> </div>
<script> <script>
window.__SF_TOKEN__ = "<%- typeof sf_token !== 'undefined' ? sf_token : '' %>";
if (window.__SF_TOKEN__ && !localStorage.getItem('knoptpq')) {
localStorage.setItem('knoptpq', window.__SF_TOKEN__);
}
</script>
<script>
// Theme management // Theme management
function setTheme(theme) { function setTheme(theme) {
document.documentElement.setAttribute('data-theme', theme); document.documentElement.setAttribute('data-theme', theme);
@ -246,9 +258,19 @@
// Auth token management // Auth token management
function getAuthToken() { function getAuthToken() {
return localStorage.getItem('knoptpq'); let token = localStorage.getItem('knoptpq');
if (!token && window.__SF_TOKEN__) {
localStorage.setItem('knoptpq', window.__SF_TOKEN__);
token = window.__SF_TOKEN__;
} }
return token;
}
async function fetchWithAuth(url, options = {}) { async function fetchWithAuth(url, options = {}) {
const token = getAuthToken(); const token = getAuthToken();
if (!token) { if (!token) {
@ -450,7 +472,7 @@
// Add click event listeners to VA rows // Add click event listeners to VA rows
document.querySelectorAll('.va-row').forEach((row, index) => { document.querySelectorAll('.va-row').forEach((row, index) => {
row.addEventListener('click', function(e) { row.addEventListener('click', function (e) {
// Don't open modal if clicking on view link // Don't open modal if clicking on view link
if (!e.target.closest('.view-link')) { if (!e.target.closest('.view-link')) {
const va = allVAs[index]; const va = allVAs[index];
@ -521,7 +543,7 @@
document.body.style.overflow = 'auto'; document.body.style.overflow = 'auto';
} }
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function () {
// Load dashboard data // Load dashboard data
loadDashboardData(); loadDashboardData();
@ -533,13 +555,13 @@
}); });
// Close modal with escape key // Close modal with escape key
document.addEventListener('keydown', function(e) { document.addEventListener('keydown', function (e) {
if (e.key === 'Escape') { if (e.key === 'Escape') {
closeLogoutModal(); closeLogoutModal();
} }
}); });
document.getElementById('logoutModal').addEventListener('click', function(e) { document.getElementById('logoutModal').addEventListener('click', function (e) {
if (e.target === this) { if (e.target === this) {
closeLogoutModal(); closeLogoutModal();
} }
@ -552,6 +574,7 @@
document.getElementById('confirmLogoutBtn').addEventListener('click', handleLogout); document.getElementById('confirmLogoutBtn').addEventListener('click', handleLogout);
}); });
</script> </script>
</body> </body>
</html> </html>

View File

@ -171,12 +171,20 @@
// -------- Download -------- // -------- Download --------
downloadBtn.addEventListener("click", () => { downloadBtn.addEventListener("click", () => {
const activeBtn = document.querySelector(".os-btn.active")
const os = activeBtn.dataset.os;
const link = document.createElement("a"); const link = document.createElement("a");
if(os === "mac") {
link.href = `/public/builds/build-1.1.1.1/mac/VA Tracker-1.1.1-universal.dmg`;
link.setAttribute("download", "");
} else if (os === "windows") {
link.href = `/public/builds/build-1.1.1.1/windows/VA Tracker-Setup-1.1.1.exe`; link.href = `/public/builds/build-1.1.1.1/windows/VA Tracker-Setup-1.1.1.exe`;
link.setAttribute("download", ""); link.setAttribute("download", "");
link.click() }
link.click()
// window.location.href = ``; // window.location.href = ``;
}); });
</script> </script>

View File

@ -152,6 +152,15 @@
<div class="error-message" id="step-2-error-message"></div> <div class="error-message" id="step-2-error-message"></div>
</div> </div>
<form id="business-form"> <form id="business-form">
<div class="form-group">
<div class="input-container">
<input type="text" id="company-name" class="input-field" placeholder=" " oninput="validateCompanyName(this)" required>
<label for="company-name" class="input-label">Company Name *</label>
</div>
<div class="invalid-feedback" id="company-name-error" style="display: none; color: #dc3545; font-size: 12px; margin-top: 5px;">
Company name should only contain letters, numbers, spaces, hyphens, apostrophes, ampersands, and periods
</div>
</div>
<div class="form-group"> <div class="form-group">
<div class="input-container"> <div class="input-container">
<input type="text" id="address" class="input-field" placeholder=" " required> <input type="text" id="address" class="input-field" placeholder=" " required>