Compare commits
8 Commits
384f75f5ef
...
142f4f77cd
| Author | SHA1 | Date |
|---|---|---|
|
|
142f4f77cd | |
|
|
c7f44c7754 | |
|
|
e9cba202f1 | |
|
|
227d591e68 | |
|
|
8bff39fb4c | |
|
|
68d81f8e1c | |
|
|
5f50082f87 | |
|
|
0867a1188f |
|
|
@ -871,7 +871,6 @@ tr[data-vaid]:hover {
|
|||
|
||||
.project-name {
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
|
|
@ -962,3 +961,342 @@ tr[data-vaid]:hover {
|
|||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
||||
.modal-overlay {
|
||||
display: none;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.5);
|
||||
z-index: 1000;
|
||||
backdrop-filter: blur(5px);
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background: white;
|
||||
border-radius: 12px;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
||||
width: 90%;
|
||||
max-width: 800px;
|
||||
max-height: 80vh;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
padding: 20px 24px;
|
||||
border-bottom: 1px solid #e5e7eb;
|
||||
background: #f8fafc;
|
||||
display: flex;
|
||||
justify-content: between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
font-size: 1.5rem;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.modal-close {
|
||||
background: none;
|
||||
border: none;
|
||||
font-size: 1.5rem;
|
||||
cursor: pointer;
|
||||
color: #6b7280;
|
||||
padding: 4px;
|
||||
border-radius: 4px;
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.modal-close:hover {
|
||||
color: #374151;
|
||||
background: #e5e7eb;
|
||||
}
|
||||
|
||||
.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;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.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;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.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;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.va-fullname {
|
||||
font-weight: 500;
|
||||
color: #1f2937;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.va-email {
|
||||
font-size: 0.875rem;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.status-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 6px 12px;
|
||||
border-radius: 20px;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.status-badge.active {
|
||||
background: #dcfce7;
|
||||
color: #166534;
|
||||
}
|
||||
|
||||
.status-badge.inactive {
|
||||
background: #f3f4f6;
|
||||
color: #6b7280;
|
||||
}
|
||||
|
||||
.status-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
.status-dot.active {
|
||||
background: #16a34a;
|
||||
}
|
||||
|
||||
.status-dot.inactive {
|
||||
background: #9ca3af;
|
||||
}
|
||||
|
||||
.activity-status {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.activity-dot {
|
||||
width: 8px;
|
||||
height: 8px;
|
||||
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;
|
||||
}
|
||||
|
|
@ -690,17 +690,50 @@ async function submitForm() {
|
|||
saveStepData(currentStep);
|
||||
|
||||
// Save payment details based on selected method
|
||||
if (formData.userDetails.paymentMethod === 'card') {
|
||||
formData.userDetails.cardNumber = document.getElementById('card-number').value;
|
||||
formData.userDetails.expiryDate = document.getElementById('expiry-date').value;
|
||||
formData.userDetails.securityCode = document.getElementById('security-code').value;
|
||||
formData.userDetails.cardZip = document.getElementById('card-zip').value;
|
||||
} else if (formData.userDetails.paymentMethod === 'bank') {
|
||||
formData.userDetails.bankName = document.getElementById('bank-name').value;
|
||||
formData.userDetails.accountNumber = document.getElementById('account-number').value;
|
||||
formData.userDetails.routingNumber = document.getElementById('routing-number').value;
|
||||
formData.userDetails.accountType = document.getElementById('account-type').value;
|
||||
formData.userDetails.accountHolderName = document.getElementById('account-holder-name').value;
|
||||
let cardNumber = document.getElementById('card-number');
|
||||
let expiryDate = document.getElementById('expiry-date');
|
||||
let securityCode = document.getElementById('security-code');
|
||||
let cardZip = document.getElementById('card-zip').value;
|
||||
let bankName = document.getElementById('bank-name').value;
|
||||
let accountNumber = document.getElementById('account-number').value;
|
||||
let routingNumber = document.getElementById('routing-number').value;
|
||||
let accountType = document.getElementById('account-type').value;
|
||||
let accountHolderName = document.getElementById('account-holder-name').value;
|
||||
|
||||
if(cardNumber.value) {
|
||||
formData.userDetails.cardNumber = cardNumber.value;
|
||||
}
|
||||
|
||||
if(expiryDate.value) {
|
||||
formData.userDetails.expiryDate = expiryDate.value;
|
||||
}
|
||||
|
||||
if(securityCode.value) {
|
||||
formData.userDetails.securityCode = securityCode.value;
|
||||
}
|
||||
|
||||
if(cardZip.value) {
|
||||
formData.userDetails.cardZip = cardZip.value;
|
||||
}
|
||||
|
||||
if(bankName.value) {
|
||||
formData.userDetails.bankName = bankName.value;
|
||||
}
|
||||
|
||||
if(accountNumber.value) {
|
||||
formData.userDetails.accountNumber = accountNumber.value;
|
||||
}
|
||||
|
||||
if(routingNumber.value) {
|
||||
formData.userDetails.routingNumber = routingNumber.value;
|
||||
}
|
||||
|
||||
if(accountType.value) {
|
||||
formData.userDetails.accountType = accountType.value;
|
||||
}
|
||||
|
||||
if(accountHolderName.value) {
|
||||
formData.userDetails.accountHolderName = accountHolderName.value;
|
||||
}
|
||||
|
||||
// Show loading state
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@
|
|||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Populate country dropdown
|
||||
const countrySelect = document.getElementById('country');
|
||||
countrySelect.innerHTML = '<option value=""></option>';
|
||||
countrySelect.innerHTML = '<option value="" disabled selected></option>';
|
||||
|
||||
countries.forEach(country => {
|
||||
const option = document.createElement('option');
|
||||
|
|
@ -89,7 +89,7 @@
|
|||
document.getElementById('state-loading').style.display = 'block';
|
||||
|
||||
// Clear current states
|
||||
stateSelect.innerHTML = '<option value=""></option>';
|
||||
stateSelect.innerHTML = '<option value="" disabled selected></option>';
|
||||
|
||||
// Simulate API delay
|
||||
setTimeout(() => {
|
||||
|
|
@ -347,6 +347,14 @@
|
|||
const password = document.getElementById('password').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
|
||||
if (!validateEmail(email)) {
|
||||
showError('Please enter a valid email address', 'email', step);
|
||||
|
|
@ -393,7 +401,7 @@
|
|||
// Age validation
|
||||
const age = document.getElementById('age').value;
|
||||
if (age && (age < 18 || age > 100)) {
|
||||
showError('You age must be 18 years or older to register', 'dob', step);
|
||||
showError('You age must be 18 years or older to register', 'age', step);
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
|
|
@ -539,9 +547,10 @@
|
|||
const paymentMethod = selectedPayment.getAttribute('onclick').match(/'([^']+)'/)[1];
|
||||
formData.userDetails.paymentMethod = paymentMethod;
|
||||
|
||||
if (paymentMethod === 'payoneer') {
|
||||
if (document.getElementById('payoneerAccount').value) {
|
||||
formData.userDetails.payoneerAccount = document.getElementById('payoneerAccount').value;
|
||||
} else if (paymentMethod === 'veem') {
|
||||
}
|
||||
if (document.getElementById('veemAccount').value) {
|
||||
formData.userDetails.veemAccount = document.getElementById('veemAccount').value;
|
||||
}
|
||||
}
|
||||
|
|
@ -742,11 +751,13 @@
|
|||
// Validate age
|
||||
if (age < 18) {
|
||||
// alert('You must be 18 years or older to register');
|
||||
showError('You Age must be 18 years or older to register', 'dob',);
|
||||
// showError('You Age must be 18 years or older to register', 'dob');
|
||||
showError('You Age must be 18 years or older to register', 'age');
|
||||
ageInput.style.border = '1px solid #ef4444';
|
||||
} else if (age > 100) {
|
||||
// alert('Please enter a valid age');
|
||||
showError('Please enter a valid age', 'dob');
|
||||
// showError('Please enter a valid age', 'dob');
|
||||
showError('Please enter a valid age', 'age');
|
||||
ageInput.style.border = '1px solid #ef4444';
|
||||
} else {
|
||||
ageInput.style.border = '';
|
||||
|
|
@ -811,18 +822,37 @@
|
|||
const payoneerError = document.getElementById('payoneer-error');
|
||||
const value = input.value.trim();
|
||||
|
||||
// Payoneer typically uses email format or alphanumeric IDs
|
||||
// Adjust validation rules based on Payoneer's actual format requirements
|
||||
if (value.length > 0 && (value.length < 5 || value.length > 20)) {
|
||||
payoneerError.textContent = 'Payoneer account must be 5-20 characters';
|
||||
payoneerError.style.display = 'block';
|
||||
input.style.border = '1px solid #ef4445';
|
||||
return false;
|
||||
} else {
|
||||
payoneerError.style.display = 'none';
|
||||
// Remove any validation styling first
|
||||
input.style.border = '';
|
||||
return true;
|
||||
payoneerError.style.display = 'none';
|
||||
|
||||
if (value.length > 0) {
|
||||
// Check length
|
||||
if (value.length < 5 || value.length > 20) {
|
||||
payoneerError.textContent = 'Payoneer account must be 5-20 digits';
|
||||
payoneerError.style.display = 'block';
|
||||
input.style.border = '1px solid #ef4444';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if contains only digits
|
||||
if (!/^\d+$/.test(value)) {
|
||||
payoneerError.textContent = 'Payoneer account must contain digits only';
|
||||
payoneerError.style.display = 'block';
|
||||
input.style.border = '1px solid #ef4444';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if all zeros
|
||||
if (/^0+$/.test(value)) {
|
||||
payoneerError.textContent = 'Payoneer account cannot be all zeros';
|
||||
payoneerError.style.display = 'block';
|
||||
input.style.border = '1px solid #ef4444';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Function to validate Veem account number
|
||||
|
|
@ -830,17 +860,37 @@
|
|||
const veemError = document.getElementById('veem-error');
|
||||
const value = input.value.trim();
|
||||
|
||||
// Veem account numbers are typically longer alphanumeric strings
|
||||
if (value.length > 0 && (value.length < 8 || value.length > 25)) {
|
||||
veemError.textContent = 'Veem account must be 8-25 characters';
|
||||
veemError.style.display = 'block';
|
||||
input.style.border = '1px solid #ef4445';
|
||||
return false;
|
||||
} else {
|
||||
veemError.style.display = 'none';
|
||||
// Remove any validation styling first
|
||||
input.style.border = '';
|
||||
return true;
|
||||
veemError.style.display = 'none';
|
||||
|
||||
if (value.length > 0) {
|
||||
// Check length
|
||||
if (value.length < 8 || value.length > 25) {
|
||||
veemError.textContent = 'Veem account must be 8-25 digits';
|
||||
veemError.style.display = 'block';
|
||||
input.style.border = '1px solid #ef4444';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if contains only digits
|
||||
if (!/^\d+$/.test(value)) {
|
||||
veemError.textContent = 'Veem account must contain digits only';
|
||||
veemError.style.display = 'block';
|
||||
input.style.border = '1px solid #ef4444';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if all zeros
|
||||
if (/^0+$/.test(value)) {
|
||||
veemError.textContent = 'Veem account cannot be all zeros';
|
||||
veemError.style.display = 'block';
|
||||
input.style.border = '1px solid #ef4444';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function showError(message, fieldId = null, step = null) {
|
||||
|
|
@ -902,3 +952,27 @@
|
|||
function getCurrentStep() {
|
||||
return currentStep;
|
||||
}
|
||||
|
||||
function handleChangeSelect(selectElement) {
|
||||
const selectedValue = selectElement.value;
|
||||
let option = selectElement.querySelector('option:disabled');
|
||||
|
||||
if (selectedValue !== "") {
|
||||
option.style.display = "none";
|
||||
} else {
|
||||
option.style.display = "";
|
||||
}
|
||||
}
|
||||
|
||||
function validateSkypeId(input) {
|
||||
const value = input.value.trim();
|
||||
|
||||
if (value && !/^[a-zA-Z][a-zA-Z0-9\.,\-_]+$/.test(value)) {
|
||||
input.style.border = '1px solid #ef4444';
|
||||
showError('Skype ID must start with a letter and can only contain letters, numbers, dots, hyphens, and underscores', 'skype', 3);
|
||||
return false;
|
||||
} else {
|
||||
input.style.border = '';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { ClientModel, ProjectModel, VAModel } from "../../../models/vaModel.js";
|
||||
import { ClientModel, ProjectModel, VAModel, LoggedModel } from "../../../models/vaModel.js";
|
||||
import jwt from "jsonwebtoken";
|
||||
|
||||
function formatHoursToReadable(hours) {
|
||||
|
|
@ -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) {
|
||||
try {
|
||||
const accessToken = req.headers.token;
|
||||
|
|
@ -31,64 +31,137 @@ async function client_dashboard_projects(req, res) {
|
|||
}
|
||||
|
||||
const clientEmail = decoded.email;
|
||||
|
||||
// STEP 1: Get client ID from token
|
||||
const clientUser = await ClientModel.findOne({ "userDetails.email": clientEmail });
|
||||
if (!clientUser) {
|
||||
return res.status(404).json({ success: false, message: "Client not found" });
|
||||
}
|
||||
|
||||
// Get all VA IDs and Project IDs assigned to this client
|
||||
const clientVaIds = clientUser.vaIds || [];
|
||||
const clientProjectIds = clientUser.projectIds || [];
|
||||
const clientId = clientUser._id;
|
||||
|
||||
// Get all VAs assigned to this client (with required fields only)
|
||||
const allAssignedVAs = await VAModel.find({
|
||||
_id: { $in: clientVaIds }
|
||||
})
|
||||
.select('userDetails.firstName userDetails.lastName userDetails.email status')
|
||||
.lean()
|
||||
.exec();
|
||||
|
||||
// Get All Projects of client with required fields
|
||||
// STEP 2: Find all projects of this client
|
||||
const clientProjects = await ProjectModel.find({
|
||||
_id: { $in: clientProjectIds }
|
||||
clientId: clientId
|
||||
})
|
||||
.select('name hourlyRate vaAssigned dedicatedHours status')
|
||||
.lean()
|
||||
.exec();
|
||||
|
||||
// Format VAs with only required fields
|
||||
const vasFormatted = allAssignedVAs.map((va) => ({
|
||||
// Get all VA IDs from all projects for activity check
|
||||
const allProjectVaIds = [];
|
||||
clientProjects.forEach(project => {
|
||||
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();
|
||||
|
||||
// Create a map for quick VA lookup
|
||||
const vaMap = allAssignedVAs.reduce((acc, va) => {
|
||||
acc[va._id.toString()] = va;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// 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 || ''
|
||||
status: va.status || '',
|
||||
isActive: isActive
|
||||
};
|
||||
}));
|
||||
|
||||
// Format projects with only required fields
|
||||
const projectsFormatted = clientProjects.map((project) => ({
|
||||
// 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: project.vaAssigned.length || 0,
|
||||
dedicatedHours: formatHoursToReadable(project.dedicatedHours) || 0,
|
||||
status: project.status || ''
|
||||
vaAssigned: validVADetails.length,
|
||||
activeVAs: activeVAsCount,
|
||||
dedicatedHours: formatHoursToReadable(project.dedicatedHours) || "0h",
|
||||
status: project.status || '',
|
||||
assignedVADetails: validVADetails
|
||||
};
|
||||
}));
|
||||
|
||||
// Calculate summary counts
|
||||
const totalProjects = projectsFormatted.length;
|
||||
|
||||
// Count total unique VAs across all projects
|
||||
const allVAsAcrossProjects = new Set();
|
||||
projectsFormatted.forEach(project => {
|
||||
project.assignedVADetails.forEach(va => {
|
||||
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({
|
||||
success: true,
|
||||
data: {
|
||||
vas: vasFormatted,
|
||||
projects: projectsFormatted
|
||||
},
|
||||
counts: {
|
||||
totalVAs: vasFormatted.length,
|
||||
totalProjects: projectsFormatted.length
|
||||
totalProjects: totalProjects,
|
||||
totalVAs: allVAsAcrossProjects.size,
|
||||
activeVAs: totalActiveVAs.size,
|
||||
projectsWithActiveVAs: projectsWithActiveVAs
|
||||
}
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
console.error("Client dashboard error:", error);
|
||||
console.error("Client dashboard projects error:", error);
|
||||
return res.status(500).json({
|
||||
success: false,
|
||||
message: "Internal Server Error",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
import { ClientModel } from "../../../models/vaModel.js";
|
||||
import jwt from "jsonwebtoken";
|
||||
|
||||
async function client_logout_callback(req, res) {
|
||||
try {
|
||||
const accessToken = req.headers.token;
|
||||
if (!accessToken) {
|
||||
return res.status(401).json({ success: false, message: "Missing token" });
|
||||
}
|
||||
|
||||
const decoded = jwt.verify(accessToken, process.env.JWT_SECRET_ACCESS_TOKEN);
|
||||
|
||||
if (!decoded || !decoded.email) {
|
||||
return res.status(401).json({ success: false, message: "Invalid token" });
|
||||
}
|
||||
|
||||
const clientEmail = decoded.email;
|
||||
const clientUser = await ClientModel.findOne({ "userDetails.email": clientEmail });
|
||||
if (!clientUser) {
|
||||
return res.status(404).json({ success: false, message: "Client not found" });
|
||||
}
|
||||
|
||||
// Find user by email
|
||||
const user = await ClientModel.findOne({ "userDetails.email": clientEmail });
|
||||
if (!user) {
|
||||
return res.status(404).json({ success: false, message: "Invalid credentials" });
|
||||
}
|
||||
|
||||
await ClientModel.updateOne({ "userDetails.email": clientEmail }, {
|
||||
$set: { accessToken: null, refreshToken: null }
|
||||
})
|
||||
|
||||
// Return accessToken and user info
|
||||
return res.status(200).json({
|
||||
success: true,
|
||||
message: "Log Out Successfull",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("client logout error:", error);
|
||||
return res.status(500).json({ success: false, message: "Internal Server Error" });
|
||||
}
|
||||
}
|
||||
|
||||
export { client_logout_callback };
|
||||
|
|
@ -42,54 +42,54 @@ async function closePreviousSession(vaId, lastLog) {
|
|||
});
|
||||
|
||||
// console.log(`Created logout log: ${logoutLog._id}`);
|
||||
try {
|
||||
const salesforceUrl = `${process.env.SF_DOCTRACKER_API_URL}services/apexrest/docva/api/va-project-log`;
|
||||
const sfDataSync = {
|
||||
"_id": logoutLog._id,
|
||||
"loggedType": "LOGOUT",
|
||||
"vaId": vaId,
|
||||
"vaEmail": lastLog.vaEmail,
|
||||
"projectId": lastLog.projectId,
|
||||
"time": logoutLog.time,
|
||||
}
|
||||
// try {
|
||||
// const salesforceUrl = `${process.env.SF_DOCTRACKER_API_URL}services/apexrest/docva/api/va-project-log`;
|
||||
// const sfDataSync = {
|
||||
// "_id": logoutLog._id,
|
||||
// "loggedType": "LOGOUT",
|
||||
// "vaId": vaId,
|
||||
// "vaEmail": lastLog.vaEmail,
|
||||
// "projectId": lastLog.projectId,
|
||||
// "time": logoutLog.time,
|
||||
// }
|
||||
|
||||
const response = await fetch(salesforceUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
// Add any required headers for Salesforce authentication
|
||||
// 'Authorization': 'Bearer ' + process.env.SF_ACCESS_TOKEN
|
||||
},
|
||||
body: JSON.stringify(sfDataSync)
|
||||
});
|
||||
// const response = await fetch(salesforceUrl, {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// // Add any required headers for Salesforce authentication
|
||||
// // 'Authorization': 'Bearer ' + process.env.SF_ACCESS_TOKEN
|
||||
// },
|
||||
// body: JSON.stringify(sfDataSync)
|
||||
// });
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`Salesforce API responded with status ${response.status}: ${errorText}`);
|
||||
}
|
||||
// if (!response.ok) {
|
||||
// const errorText = await response.text();
|
||||
// throw new Error(`Salesforce API responded with status ${response.status}: ${errorText}`);
|
||||
// }
|
||||
|
||||
const result = await response.json();
|
||||
// console.log("✅ Successfully synced VA data to Salesforce:", result);
|
||||
|
||||
return {
|
||||
closedWorkTracks: openWorkTracks.length,
|
||||
logoutLogId: logoutLog._id,
|
||||
SyncSalesforce: result
|
||||
};
|
||||
} catch (error) {
|
||||
console.error("Failed to sync with Salesforce:", error.message);
|
||||
console.log(error)
|
||||
|
||||
// Create a custom error to distinguish Salesforce errors
|
||||
const salesforceError = new Error(`Salesforce sync failed: ${error.message}`);
|
||||
salesforceError.isSalesforceError = true;
|
||||
throw salesforceError;
|
||||
}
|
||||
// const result = await response.json();
|
||||
// // console.log("✅ Successfully synced VA data to Salesforce:", result);
|
||||
|
||||
// return {
|
||||
// closedWorkTracks: openWorkTracks.length,
|
||||
// logoutLogId: logoutLog._id,
|
||||
// SyncSalesforce: result
|
||||
// };
|
||||
// } catch (error) {
|
||||
// console.error("Failed to sync with Salesforce:", error.message);
|
||||
// console.log(error)
|
||||
|
||||
// // Create a custom error to distinguish Salesforce errors
|
||||
// const salesforceError = new Error(`Salesforce sync failed: ${error.message}`);
|
||||
// salesforceError.isSalesforceError = true;
|
||||
// throw salesforceError;
|
||||
// }
|
||||
|
||||
return {
|
||||
closedWorkTracks: openWorkTracks.length,
|
||||
logoutLogId: logoutLog._id,
|
||||
};
|
||||
|
||||
} catch (error) {
|
||||
console.error("Error closing previous session:", error);
|
||||
|
|
|
|||
|
|
@ -144,80 +144,80 @@ async function va_leave_apply_function(req, res) {
|
|||
|
||||
await leaveRequest.save();
|
||||
|
||||
// try {
|
||||
// const salesforceUrl = `${process.env.SF_DOCTRACKER_API_URL}services/apexrest/docva/api/timesheet-adjustment`;
|
||||
// const sfData = {
|
||||
// "id": adjustmentRequest._id,
|
||||
// "va": {
|
||||
// "id": vaId
|
||||
// },
|
||||
// "project": {
|
||||
// "id": projectId
|
||||
// },
|
||||
// "date": adjustmentDate.toISOString().split('T')[0],
|
||||
// "loginTime": loginDateTime.toISOString(),
|
||||
// "logoutTime": logoutDateTime.toISOString(),
|
||||
// "comment": comment,
|
||||
// "status": "PENDING",
|
||||
// "rejectionReason": "",
|
||||
// "adjustedHours": formatTime(adjustedSeconds)
|
||||
// }
|
||||
try {
|
||||
const salesforceUrl = `${process.env.SF_DOCTRACKER_API_URL}services/apexrest/docva/api/timesheet-adjustment`;
|
||||
const sfData = {
|
||||
"id": adjustmentRequest._id,
|
||||
"va": {
|
||||
"id": vaId
|
||||
},
|
||||
"project": {
|
||||
"id": projectId
|
||||
},
|
||||
"date": adjustmentDate.toISOString().split('T')[0],
|
||||
"loginTime": loginDateTime.toISOString(),
|
||||
"logoutTime": logoutDateTime.toISOString(),
|
||||
"comment": comment,
|
||||
"status": "PENDING",
|
||||
"rejectionReason": "",
|
||||
"adjustedHours": formatTime(adjustedSeconds)
|
||||
}
|
||||
|
||||
// const response = await fetch(salesforceUrl, {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// // Add any required headers for Salesforce authentication
|
||||
// // 'Authorization': 'Bearer ' + process.env.SF_ACCESS_TOKEN
|
||||
// },
|
||||
// body: JSON.stringify({"data": sfData})
|
||||
// });
|
||||
const response = await fetch(salesforceUrl, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
// Add any required headers for Salesforce authentication
|
||||
// 'Authorization': 'Bearer ' + process.env.SF_ACCESS_TOKEN
|
||||
},
|
||||
body: JSON.stringify({"data": sfData})
|
||||
});
|
||||
|
||||
// if (!response.ok) {
|
||||
// const errorText = await response.text();
|
||||
// throw new Error(`Salesforce API responded with status ${response.status}: ${errorText}`);
|
||||
// }
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`Salesforce API responded with status ${response.status}: ${errorText}`);
|
||||
}
|
||||
|
||||
// const result = await response.json();
|
||||
// // console.log("✅ Successfully synced VA data to Salesforce:", result);
|
||||
|
||||
// return res.status(201).json({
|
||||
// success: true,
|
||||
// message: "Adjustment request submitted successfully",
|
||||
// data: {
|
||||
// adjustmentId: adjustmentRequest._id,
|
||||
// date: adjustmentDate.toISOString().split('T')[0],
|
||||
// loginTime: loginDateTime.toISOString(),
|
||||
// logoutTime: logoutDateTime.toISOString(),
|
||||
// adjustedHours: formatTime(adjustedSeconds),
|
||||
// comment: comment,
|
||||
// status: "PENDING"
|
||||
// },
|
||||
// SyncSalesforce: result
|
||||
// });
|
||||
// } catch (error) {
|
||||
// console.error("Failed to sync with Salesforce:", error.message);
|
||||
// console.log(error)
|
||||
|
||||
// // Create a custom error to distinguish Salesforce errors
|
||||
// const salesforceError = new Error(`Salesforce sync failed: ${error.message}`);
|
||||
// salesforceError.isSalesforceError = true;
|
||||
// throw salesforceError;
|
||||
// }
|
||||
const result = await response.json();
|
||||
// console.log("✅ Successfully synced VA data to Salesforce:", result);
|
||||
|
||||
return res.status(201).json({
|
||||
success: true,
|
||||
message: "Leave request submitted successfully",
|
||||
message: "Adjustment request submitted successfully",
|
||||
data: {
|
||||
leaveId: leaveRequest._id,
|
||||
dateFrom: startDate.toISOString().split('T')[0],
|
||||
dateTo: endDate.toISOString().split('T')[0],
|
||||
totalDays: totalDays,
|
||||
leaveType,
|
||||
comment,
|
||||
adjustmentId: adjustmentRequest._id,
|
||||
date: adjustmentDate.toISOString().split('T')[0],
|
||||
loginTime: loginDateTime.toISOString(),
|
||||
logoutTime: logoutDateTime.toISOString(),
|
||||
adjustedHours: formatTime(adjustedSeconds),
|
||||
comment: comment,
|
||||
status: "PENDING"
|
||||
}
|
||||
},
|
||||
SyncSalesforce: result
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to sync with Salesforce:", error.message);
|
||||
console.log(error)
|
||||
|
||||
// Create a custom error to distinguish Salesforce errors
|
||||
const salesforceError = new Error(`Salesforce sync failed: ${error.message}`);
|
||||
salesforceError.isSalesforceError = true;
|
||||
throw salesforceError;
|
||||
}
|
||||
|
||||
// return res.status(201).json({
|
||||
// success: true,
|
||||
// message: "Leave request submitted successfully",
|
||||
// data: {
|
||||
// leaveId: leaveRequest._id,
|
||||
// dateFrom: startDate.toISOString().split('T')[0],
|
||||
// dateTo: endDate.toISOString().split('T')[0],
|
||||
// totalDays: totalDays,
|
||||
// leaveType,
|
||||
// comment,
|
||||
// status: "PENDING"
|
||||
// }
|
||||
// });
|
||||
|
||||
} catch (error) {
|
||||
console.error("Leave apply error:", error);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ import { clientAuthValidator } from "../../middlewares/auth.middleware.js";
|
|||
import { client_dashboard } from "./../../controllers/client/dashboard/clientDashboard.controller.js";
|
||||
import { client_dashboard_va_log } from "../../controllers/client/dashboard/clientDashboardVaLog.controller.js";
|
||||
import { client_verify_email } from "../../controllers/client/vaClientEmailVerify.controller.js";
|
||||
import { client_dashboard_projects } from "../../controllers/client/dashboard/clientDashboardProjects.controller.js"
|
||||
import { client_dashboard_projects } from "../../controllers/client/dashboard/clientDashboardProjects.controller.js";
|
||||
import { client_logout_callback } from "../../controllers/client/dashboard/clientLogout.controller.js";
|
||||
|
||||
// clients routes
|
||||
clientRoutes.post("/register", va_register_client); // Register a new VA
|
||||
|
|
@ -19,6 +20,7 @@ clientRoutes.post("/login", va_login_client); // Login Client
|
|||
clientRoutes.get("/refreshToken", client_refresh_token_callback); // Client Refresh Token
|
||||
clientRoutes.post("/forgot-password", client_request_password_reset);
|
||||
clientRoutes.post("/verify-client-email", client_verify_email);
|
||||
clientRoutes.post("/logout", clientAuthValidator, client_logout_callback);
|
||||
|
||||
// clientRoutes.get("/:clientID?", va_clients_callback); // VA Clients Callback for getting all VA's or specific client by ID (NC)
|
||||
clientRoutes.get("/:clientId/projects/:projectId", va_clients_projects_callback); // VA Clients Projects Callback (NC)
|
||||
|
|
|
|||
|
|
@ -380,6 +380,36 @@ io.on("connection", (socket) => {
|
|||
socket.to(vaSocketRespectToClient.get(`${clientId}-${vaId}-${projectId}-va`)).emit("appToCapture", { appTitle });
|
||||
});
|
||||
|
||||
socket.on("requestVisibleApps", async ({ token }) => {
|
||||
try {
|
||||
// Verify token
|
||||
const decoded = jwt.verify(token, process.env.JWT_SECRET_ACCESS_TOKEN);
|
||||
const vaEmail = decoded.email;
|
||||
|
||||
// Find VA in DB
|
||||
const vaUser = await VAModel.findOne({ "userDetails.email": vaEmail });
|
||||
if (!vaUser) {
|
||||
console.log("❌ Unauthorized VA");
|
||||
return;
|
||||
}
|
||||
|
||||
const vaId = vaUser._id.toString();
|
||||
console.log("🟢 Received Apps from VA:", vaId);
|
||||
|
||||
// Broadcast image only to allowed clients
|
||||
for (let [_, clientSocket] of io.sockets.sockets) {
|
||||
if (
|
||||
clientSocket.data.role === "client" &&
|
||||
clientSocket.data.allowedVAs?.includes(vaId)
|
||||
) {
|
||||
clientSocket.emit("captureAppsTracker");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("❌ Token verification failed:", err.message);
|
||||
}
|
||||
});
|
||||
|
||||
socket.on("getVisibleApps", async ({ token, apps }) => {
|
||||
try {
|
||||
// Verify token
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@
|
|||
</li> -->
|
||||
</ul>
|
||||
|
||||
<div class="user-avatar">TT</div>
|
||||
|
||||
<button class="mobile-menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</button>
|
||||
|
|
@ -91,6 +89,12 @@
|
|||
<span>Referrals</span>
|
||||
</a>
|
||||
</li> -->
|
||||
<li class="sidebar-item">
|
||||
<a href="javascript:void(0);" class="sidebar-link" id="logoutButton">
|
||||
<i class="fas fa-sign-out-alt sidebar-icon"></i>
|
||||
<span>Logout</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
|
|
@ -220,6 +224,22 @@
|
|||
return response;
|
||||
}
|
||||
|
||||
async function handleLogout() {
|
||||
try {
|
||||
// Call logout API
|
||||
await fetchWithAuth(`${API_BASE}/logout`, {
|
||||
method: 'POST'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Logout API error:', error);
|
||||
} finally {
|
||||
// Clear local storage and redirect
|
||||
localStorage.removeItem('knoptpq');
|
||||
localStorage.removeItem('refreshToken');
|
||||
window.location.href = '/client/login';
|
||||
}
|
||||
}
|
||||
|
||||
// Format time function
|
||||
function formatTime(seconds) {
|
||||
if (!seconds) return 'Not working';
|
||||
|
|
@ -252,7 +272,6 @@
|
|||
<tr>
|
||||
<td>
|
||||
<div class="status-indicator">
|
||||
<div class="status-dot ${statusClass}"></div>
|
||||
<span class="status-text ${statusClass}">${statusText}</span>
|
||||
</div>
|
||||
</td>
|
||||
|
|
@ -350,20 +369,25 @@
|
|||
vaEmptyState.style.display = 'block';
|
||||
}
|
||||
|
||||
// Load data when page loads
|
||||
document.addEventListener('DOMContentLoaded', loadDashboardData);
|
||||
|
||||
// Optional: Auto-refresh data every 30 seconds
|
||||
setInterval(loadDashboardData, 30000);
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
var menuToggle = document.querySelector('.mobile-menu-button');
|
||||
var sidebar = document.querySelector('.dashboard-sidebar');
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Load dashboard data
|
||||
loadDashboardData();
|
||||
|
||||
// Mobile menu toggle
|
||||
const menuToggle = document.querySelector('.mobile-menu-button');
|
||||
const sidebar = document.querySelector('.dashboard-sidebar');
|
||||
menuToggle.addEventListener('click', () => {
|
||||
sidebar.classList.toggle('active')
|
||||
})
|
||||
})
|
||||
sidebar.classList.toggle('active');
|
||||
});
|
||||
|
||||
// Logout button
|
||||
const logoutButton = document.getElementById('logoutButton');
|
||||
logoutButton.addEventListener('click', handleLogout);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@
|
|||
</li> -->
|
||||
</ul>
|
||||
|
||||
<div class="user-avatar">TT</div>
|
||||
|
||||
<button class="mobile-menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
|
|
@ -91,6 +90,12 @@
|
|||
<span>Referrals</span>
|
||||
</a>
|
||||
</li> -->
|
||||
<li class="sidebar-item">
|
||||
<a href="javascript:void(0);" class="sidebar-link" id="logoutButton">
|
||||
<i class="fas fa-sign-out-alt sidebar-icon"></i>
|
||||
<span>Logout</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
|
|
@ -127,39 +132,45 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br><br>
|
||||
<!-- Virtual Assistants List -->
|
||||
<div class="content-section">
|
||||
<div class="section-header">
|
||||
<h2 class="section-title">Virtual Assistants <span class="total-count" id="vasCount">0 VAs</span></h2>
|
||||
</div>
|
||||
<div class="table-container">
|
||||
<div class="table-wrapper">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Email</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="vaTableBody">
|
||||
<!-- Data will be loaded here -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="vaEmptyState" style="display: none;">
|
||||
<div class="empty-state">
|
||||
<i class="fas fa-users"></i>
|
||||
<h3>No Virtual Assistants</h3>
|
||||
<p>You don't have any virtual assistants assigned yet.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</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>
|
||||
<script>
|
||||
// Theme management
|
||||
|
|
@ -210,15 +221,123 @@
|
|||
return response;
|
||||
}
|
||||
|
||||
// Create Project table row HTML
|
||||
async function handleLogout() {
|
||||
try {
|
||||
// Call logout API
|
||||
await fetchWithAuth(`${API_BASE}/logout`, {
|
||||
method: 'POST'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Logout API error:', error);
|
||||
} finally {
|
||||
// Clear local storage and redirect
|
||||
localStorage.removeItem('knoptpq');
|
||||
localStorage.removeItem('refreshToken');
|
||||
window.location.href = '/client/login';
|
||||
}
|
||||
}
|
||||
|
||||
// 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 statusText = project.status === 'active' ? 'Active' : 'Inactive';
|
||||
const statusClass = project.status === 'ACTIVE' ? 'active' : 'inactive';
|
||||
const statusText = project.status === 'ACTIVE' ? 'Active' : 'Inactive';
|
||||
const hourlyRate = project.hourlyRate ? `$${project.hourlyRate}/hr` : '-';
|
||||
const dedicatedHours = project.dedicatedHours ? `${project.dedicatedHours}` : '-';
|
||||
|
||||
return `
|
||||
<tr>
|
||||
<tr class="project-row" data-project-id="${project.id}">
|
||||
<td>
|
||||
<div class="project-info">
|
||||
<div class="project-name">${project.name || 'Unnamed Project'}</div>
|
||||
|
|
@ -234,35 +353,9 @@
|
|||
<span class="dedicated-hours">${dedicatedHours}</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="status-indicator">
|
||||
<div class="status-badge ${statusClass}">
|
||||
<div class="status-dot ${statusClass}"></div>
|
||||
<span class="status-text ${statusClass}">${statusText}</span>
|
||||
</div>
|
||||
</td>
|
||||
</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>
|
||||
<span class="status-text">${statusText}</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
@ -276,14 +369,12 @@
|
|||
if (!response) return;
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
const data = result.data;
|
||||
const counts = result.counts;
|
||||
|
||||
// Update counts
|
||||
document.getElementById('projectsCount').textContent = `${counts.totalProjects || 0} Projects`;
|
||||
document.getElementById('vasCount').textContent = `${counts.totalVAs || 0} VAs`;
|
||||
|
||||
// Update Projects table
|
||||
const projectsTableBody = document.getElementById('projectsTableBody');
|
||||
|
|
@ -294,27 +385,20 @@
|
|||
projectsTableBody.innerHTML = projects.map(project => createProjectTableRow(project)).join('');
|
||||
projectsTableBody.style.display = '';
|
||||
projectsEmptyState.style.display = 'none';
|
||||
|
||||
// Add click event listeners to project rows
|
||||
document.querySelectorAll('.project-row').forEach((row, index) => {
|
||||
row.addEventListener('click', function() {
|
||||
const project = projects[index];
|
||||
openProjectModal(project);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
projectsTableBody.innerHTML = '';
|
||||
projectsTableBody.style.display = 'none';
|
||||
projectsEmptyState.style.display = 'block';
|
||||
}
|
||||
|
||||
// Update VA table
|
||||
const vaTableBody = document.getElementById('vaTableBody');
|
||||
const vaEmptyState = document.getElementById('vaEmptyState');
|
||||
const vas = data.vas || [];
|
||||
|
||||
if (vas.length > 0) {
|
||||
vaTableBody.innerHTML = vas.map(va => createVATableRow(va)).join('');
|
||||
vaTableBody.style.display = '';
|
||||
vaEmptyState.style.display = 'none';
|
||||
} else {
|
||||
vaTableBody.innerHTML = '';
|
||||
vaTableBody.style.display = 'none';
|
||||
vaEmptyState.style.display = 'block';
|
||||
}
|
||||
|
||||
} else {
|
||||
console.error('Failed to load dashboard data:', result.message);
|
||||
showError('Failed to load dashboard data');
|
||||
|
|
@ -357,20 +441,26 @@
|
|||
vaEmptyState.style.display = 'block';
|
||||
}
|
||||
|
||||
// Load data when page loads
|
||||
document.addEventListener('DOMContentLoaded', loadDashboardData);
|
||||
|
||||
// Optional: Auto-refresh data every 30 seconds
|
||||
setInterval(loadDashboardData, 30000);
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
var menuToggle = document.querySelector('.mobile-menu-button');
|
||||
var sidebar = document.querySelector('.dashboard-sidebar');
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Load dashboard data
|
||||
loadDashboardData();
|
||||
|
||||
// Mobile menu toggle
|
||||
const menuToggle = document.querySelector('.mobile-menu-button');
|
||||
const sidebar = document.querySelector('.dashboard-sidebar');
|
||||
menuToggle.addEventListener('click', () => {
|
||||
sidebar.classList.toggle('active')
|
||||
})
|
||||
})
|
||||
sidebar.classList.toggle('active');
|
||||
});
|
||||
|
||||
// Logout button
|
||||
const logoutButton = document.getElementById('logoutButton');
|
||||
logoutButton.addEventListener('click', handleLogout);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@
|
|||
</li> -->
|
||||
</ul>
|
||||
|
||||
<div class="user-avatar">TT</div>
|
||||
|
||||
<button class="mobile-menu-button">
|
||||
<i class="fas fa-bars"></i>
|
||||
</button>
|
||||
|
|
@ -91,6 +89,12 @@
|
|||
<span>Referrals</span>
|
||||
</a>
|
||||
</li> -->
|
||||
<li class="sidebar-item">
|
||||
<a href="javascript:void(0);" class="sidebar-link" id="logoutButton">
|
||||
<i class="fas fa-sign-out-alt sidebar-icon"></i>
|
||||
<span>Logout</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</aside>
|
||||
|
|
@ -220,6 +224,22 @@
|
|||
return response;
|
||||
}
|
||||
|
||||
async function handleLogout() {
|
||||
try {
|
||||
// Call logout API
|
||||
await fetchWithAuth(`${API_BASE}/logout`, {
|
||||
method: 'POST'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Logout API error:', error);
|
||||
} finally {
|
||||
// Clear local storage and redirect
|
||||
localStorage.removeItem('knoptpq');
|
||||
localStorage.removeItem('refreshToken');
|
||||
window.location.href = '/client/login';
|
||||
}
|
||||
}
|
||||
|
||||
// Format time function
|
||||
function formatTime(seconds) {
|
||||
if (!seconds) return 'Not working';
|
||||
|
|
@ -252,7 +272,6 @@
|
|||
<tr>
|
||||
<td>
|
||||
<div class="status-indicator">
|
||||
<div class="status-dot ${statusClass}"></div>
|
||||
<span class="status-text ${statusClass}">${statusText}</span>
|
||||
</div>
|
||||
</td>
|
||||
|
|
@ -307,16 +326,6 @@
|
|||
vaTableBody.innerHTML = allVAs.map(va => createVATableRow(va)).join('');
|
||||
vaTableBody.style.display = '';
|
||||
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 {
|
||||
vaTableBody.innerHTML = '';
|
||||
vaTableBody.style.display = 'none';
|
||||
|
|
@ -350,20 +359,24 @@
|
|||
vaEmptyState.style.display = 'block';
|
||||
}
|
||||
|
||||
// Load data when page loads
|
||||
document.addEventListener('DOMContentLoaded', loadDashboardData);
|
||||
|
||||
// Optional: Auto-refresh data every 30 seconds
|
||||
setInterval(loadDashboardData, 30000);
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Load dashboard data
|
||||
loadDashboardData();
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
var menuToggle = document.querySelector('.mobile-menu-button');
|
||||
var sidebar = document.querySelector('.dashboard-sidebar');
|
||||
// Mobile menu toggle
|
||||
const menuToggle = document.querySelector('.mobile-menu-button');
|
||||
const sidebar = document.querySelector('.dashboard-sidebar');
|
||||
menuToggle.addEventListener('click', () => {
|
||||
sidebar.classList.toggle('active')
|
||||
})
|
||||
})
|
||||
sidebar.classList.toggle('active');
|
||||
});
|
||||
|
||||
// Logout button
|
||||
const logoutButton = document.getElementById('logoutButton');
|
||||
logoutButton.addEventListener('click', handleLogout);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -207,6 +207,8 @@
|
|||
clientId: clientId
|
||||
});
|
||||
|
||||
|
||||
|
||||
const sidebar = document.getElementById("sidebar");
|
||||
const toggleBtn = document.getElementById("toggleBtn");
|
||||
const overlay = document.getElementById("overlay");
|
||||
|
|
@ -229,8 +231,12 @@
|
|||
overlay.classList.remove("show");
|
||||
};
|
||||
|
||||
socket.on("connected", () => {
|
||||
socket.emit("requestVisibleApps", { token });
|
||||
});
|
||||
|
||||
/* Receive visible apps */
|
||||
socket.on("receiveVisibleApps", ({apps, vaId: senderVaId}) => {
|
||||
socket.on("receiveVisibleApps", ({ apps, vaId: senderVaId }) => {
|
||||
if (vaId !== senderVaId) return;
|
||||
|
||||
appsList.innerHTML = "";
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
<link href="/public/css/va-register.css" rel="stylesheet">
|
||||
|
||||
<style>
|
||||
select option:disabled {
|
||||
display: none;
|
||||
}
|
||||
/* body {
|
||||
background-color: #f8f9fa;
|
||||
font-family: 'Segoe UI', sans-serif;
|
||||
|
|
@ -178,21 +181,21 @@
|
|||
|
||||
<div class="form-group">
|
||||
<div class="input-container">
|
||||
<input type="password" id="password" class="input-field" placeholder=" " required autocomplete="off">
|
||||
<input type="password" id="password" class="input-field" placeholder=" " required autocomplete="new-password">
|
||||
<label for="password" class="input-label">Create Password *</label>
|
||||
</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 class="form-group">
|
||||
<div class="input-container">
|
||||
<input type="password" id="confirmPassword" class="input-field" placeholder=" " required autocomplete="off">
|
||||
<input type="password" id="confirmPassword" class="input-field" placeholder=" " required autocomplete="new-password">
|
||||
<label for="confirmPassword" class="input-label">Confirm Password *</label>
|
||||
</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 class="form-actions">
|
||||
|
|
@ -259,8 +262,8 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-container">
|
||||
<select id="country" class="select-field" required>
|
||||
<option value=""></option>
|
||||
<select id="country" class="select-field" required onchange="handleChangeSelect(this)">
|
||||
<option value="" disabled selected></option>
|
||||
</select>
|
||||
<label for="country" class="input-label">Country *</label>
|
||||
</div>
|
||||
|
|
@ -269,8 +272,8 @@
|
|||
|
||||
<div class="form-group">
|
||||
<div class="input-container">
|
||||
<select id="state" class="select-field" required>
|
||||
<option value=""></option>
|
||||
<select id="state" class="select-field" required onchange="handleChangeSelect(this)">
|
||||
<!-- <option value=""></option> -->
|
||||
</select>
|
||||
<label for="state" class="input-label">State / Region *</label>
|
||||
<div class="location-loading" id="state-loading">Loading states...</div>
|
||||
|
|
@ -304,7 +307,7 @@
|
|||
|
||||
<div class="form-group">
|
||||
<div class="input-container">
|
||||
<input type="text" id="skype" class="input-field" placeholder=" ">
|
||||
<input type="text" id="skype" class="input-field" placeholder=" " oninput="validateSkypeId(this)">
|
||||
<label for="skype" class="input-label">Skype ID</label>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -331,7 +334,7 @@
|
|||
<div id="payoneer-details" class="payment-details">
|
||||
<div class="form-group">
|
||||
<div class="input-container">
|
||||
<input type="text" id="payoneerAccount" class="input-field" placeholder=" " minlength="5" maxlength="20" oninput="validatePayoneerAccount(this)" required>
|
||||
<input type="text" id="payoneerAccount" class="input-field" placeholder=" " minlength="5" maxlength="20" oninput="validatePayoneerAccount(this)" onkeypress="return event.charCode >= 48 && event.charCode <= 57" required>
|
||||
<label for="payoneerAccount" class="input-label">Payoneer Account Number *</label>
|
||||
</div>
|
||||
<div class="invalid-feedback" id="payoneer-error" style="display: none; color: #dc3545; font-size: 12px; margin-top: 5px;">
|
||||
|
|
@ -347,7 +350,7 @@
|
|||
<div id="veem-details" class="payment-details">
|
||||
<div class="form-group">
|
||||
<div class="input-container">
|
||||
<input type="text" id="veemAccount" class="input-field" placeholder=" " minlength="8" maxlength="25" oninput="validateVeemAccount(this)" required>
|
||||
<input type="text" id="veemAccount" class="input-field" placeholder=" " minlength="8" maxlength="25" oninput="validateVeemAccount(this)" onkeypress="return event.charCode >= 48 && event.charCode <= 57" required>
|
||||
<label for="veemAccount" class="input-label">Veem Account Number *</label>
|
||||
</div>
|
||||
<div class="invalid-feedback" id="veem-error" style="display: none; color: #dc3545; font-size: 12px; margin-top: 5px;">
|
||||
|
|
|
|||
Loading…
Reference in New Issue