378 lines
16 KiB
Plaintext
378 lines
16 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en" data-theme="light">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>DocVA Client | Dashboard</title>
|
|
<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">
|
|
</head>
|
|
<body class="dashboard-body">
|
|
<div id="root">
|
|
<nav class="dashboard-header">
|
|
<div class="header-content">
|
|
<div class="header-logo">
|
|
<div class="logo-container">
|
|
<h2 class="sidebar-title">DocVA Client Portal</h2>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="header-nav">
|
|
<ul class="nav-list">
|
|
<li class="nav-item">
|
|
<a href="/client/dashboard" class="nav-button">
|
|
<i class="fas fa-chart-bar"></i>Dashboard
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a href="/client/virtual-assistants" class="nav-button">
|
|
<i class="fas fa-users"></i>Virtual Assistants
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a href="/client/projects" class="nav-button active">
|
|
<i class="fas fa-file-invoice"></i>Projects
|
|
</a>
|
|
</li>
|
|
<!-- <li class="nav-item">
|
|
<a href="/client/timesheets" class="nav-button">
|
|
<i class="fas fa-clock"></i>Timesheets
|
|
</a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a href="/client/referrals" class="nav-button">
|
|
<i class="fas fa-share-alt"></i>Referrals
|
|
</a>
|
|
</li> -->
|
|
</ul>
|
|
|
|
<div class="user-avatar">TT</div>
|
|
|
|
<button class="mobile-menu-button">
|
|
<i class="fas fa-bars"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
<div class="dashboard-container">
|
|
<aside class="dashboard-sidebar">
|
|
<!-- <div class="sidebar-header">
|
|
<h2 class="sidebar-title">DocVA Client Portal</h2>
|
|
</div> -->
|
|
<nav class="sidebar-nav">
|
|
<ul class="sidebar-list">
|
|
<li class="sidebar-item">
|
|
<a href="/client/dashboard" class="sidebar-link">
|
|
<i class="fas fa-chart-bar sidebar-icon"></i>
|
|
<span>Dashboard</span>
|
|
</a>
|
|
</li>
|
|
<li class="sidebar-item">
|
|
<a href="/client/virtual-assistants" class="sidebar-link">
|
|
<i class="fas fa-users sidebar-icon"></i>
|
|
<span>Virtual Assistants</span>
|
|
</a>
|
|
</li>
|
|
<li class="sidebar-item">
|
|
<a href="/client/projects" class="sidebar-link active">
|
|
<i class="fas fa-file-invoice sidebar-icon"></i>
|
|
<span>Projects</span>
|
|
</a>
|
|
</li>
|
|
<!-- <li class="sidebar-item">
|
|
<a href="/client/invoices" class="sidebar-link">
|
|
<i class="fas fa-file-invoice sidebar-icon"></i>
|
|
<span>Invoices</span>
|
|
</a>
|
|
</li>
|
|
<li class="sidebar-item">
|
|
<a href="/client/referrals" class="sidebar-link">
|
|
<i class="fas fa-share-alt sidebar-icon"></i>
|
|
<span>Referrals</span>
|
|
</a>
|
|
</li> -->
|
|
</ul>
|
|
</nav>
|
|
</aside>
|
|
<main class="dashboard-main">
|
|
<div class="dashboard-content">
|
|
<!-- Projects List -->
|
|
<div class="content-section">
|
|
<div class="section-header">
|
|
<h2 class="section-title">Projects <span class="total-count" id="projectsCount">0 Projects</span></h2>
|
|
</div>
|
|
<div class="table-container">
|
|
<div class="table-wrapper">
|
|
<table class="data-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Name</th>
|
|
<th>Hourly Rate</th>
|
|
<th>Total VA Assigned</th>
|
|
<th>Dedicated Hours</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="projectsTableBody">
|
|
<!-- Data will be loaded here -->
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<div id="projectsEmptyState" style="display: none;">
|
|
<div class="empty-state">
|
|
<i class="fas fa-briefcase"></i>
|
|
<h3>No Projects</h3>
|
|
<p>You don't have any projects yet.</p>
|
|
</div>
|
|
</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>
|
|
<script>
|
|
// Theme management
|
|
function setTheme(theme) {
|
|
document.documentElement.setAttribute('data-theme', theme);
|
|
localStorage.setItem('theme', theme);
|
|
}
|
|
|
|
function getSystemTheme() {
|
|
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
|
|
}
|
|
|
|
// Initialize theme
|
|
const savedTheme = localStorage.getItem('theme') || getSystemTheme();
|
|
setTheme(savedTheme);
|
|
|
|
// API base URL
|
|
const API_BASE = '/api/v1/client';
|
|
|
|
// Auth token management
|
|
function getAuthToken() {
|
|
return localStorage.getItem('knoptpq');
|
|
}
|
|
|
|
async function fetchWithAuth(url, options = {}) {
|
|
const token = getAuthToken();
|
|
if (!token) {
|
|
window.location.href = '/client/login';
|
|
return;
|
|
}
|
|
|
|
const response = await fetch(url, {
|
|
...options,
|
|
headers: {
|
|
'token': `${token}`,
|
|
'Content-Type': 'application/json',
|
|
...options.headers,
|
|
}
|
|
});
|
|
|
|
if (response.status === 401) {
|
|
localStorage.removeItem('knoptpq');
|
|
localStorage.removeItem('refreshToken');
|
|
window.location.href = '/client/login';
|
|
return;
|
|
}
|
|
|
|
return response;
|
|
}
|
|
|
|
// Create Project table row HTML
|
|
function createProjectTableRow(project) {
|
|
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>
|
|
<td>
|
|
<div class="project-info">
|
|
<div class="project-name">${project.name || 'Unnamed Project'}</div>
|
|
</div>
|
|
</td>
|
|
<td>
|
|
<span class="hourly-rate">${hourlyRate}</span>
|
|
</td>
|
|
<td>
|
|
<span class="va-count">${project.vaAssigned || 0}</span>
|
|
</td>
|
|
<td>
|
|
<span class="dedicated-hours">${dedicatedHours}</span>
|
|
</td>
|
|
<td>
|
|
<div class="status-indicator">
|
|
<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>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
`;
|
|
}
|
|
|
|
// Load dashboard data
|
|
async function loadDashboardData() {
|
|
try {
|
|
const response = await fetchWithAuth(`${API_BASE}/dashboard-projects`);
|
|
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');
|
|
const projectsEmptyState = document.getElementById('projectsEmptyState');
|
|
const projects = data.projects || [];
|
|
|
|
if (projects.length > 0) {
|
|
projectsTableBody.innerHTML = projects.map(project => createProjectTableRow(project)).join('');
|
|
projectsTableBody.style.display = '';
|
|
projectsEmptyState.style.display = 'none';
|
|
} 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');
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Error loading dashboard data:', error);
|
|
showError('Error loading dashboard data');
|
|
}
|
|
}
|
|
|
|
// Show error message
|
|
function showError(message) {
|
|
const projectsTableBody = document.getElementById('projectsTableBody');
|
|
const projectsEmptyState = document.getElementById('projectsEmptyState');
|
|
const vaTableBody = document.getElementById('vaTableBody');
|
|
const vaEmptyState = document.getElementById('vaEmptyState');
|
|
|
|
// Hide tables
|
|
projectsTableBody.style.display = 'none';
|
|
vaTableBody.style.display = 'none';
|
|
|
|
// Show error states
|
|
projectsEmptyState.innerHTML = `
|
|
<div class="empty-state">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
<h3>Error</h3>
|
|
<p>${message}</p>
|
|
</div>
|
|
`;
|
|
projectsEmptyState.style.display = 'block';
|
|
|
|
vaEmptyState.innerHTML = `
|
|
<div class="empty-state">
|
|
<i class="fas fa-exclamation-triangle"></i>
|
|
<h3>Error</h3>
|
|
<p>${message}</p>
|
|
</div>
|
|
`;
|
|
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');
|
|
menuToggle.addEventListener('click', () => {
|
|
sidebar.classList.toggle('active')
|
|
})
|
|
})
|
|
|
|
|
|
</script>
|
|
</body>
|
|
</html> |