104 lines
3.7 KiB
HTML
104 lines
3.7 KiB
HTML
{% extends "ui/templates/base/layout.html" %}
|
|
{% block content %}
|
|
<section class="space-y-6">
|
|
<div class="rounded-3xl border border-slate-200 bg-white p-6 shadow-soft">
|
|
<div class="flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between">
|
|
<div>
|
|
<p class="text-xs font-semibold uppercase tracking-[0.24em] text-brand-600">Branch Operations Control Centre</p>
|
|
<h1 class="mt-2 text-2xl font-bold text-slate-900">Partner Operations Dashboard</h1>
|
|
<p class="mt-1 text-sm text-slate-500">
|
|
Monitor branch clients, due work, overdue tasks, review queue, team workload, billing and operational reports.
|
|
</p>
|
|
<p class="mt-2 text-xs text-slate-500">
|
|
Scope: {{ overview.tenant.name if overview.tenant else 'Tenant' }}{% if overview.branch %} · {{ overview.branch.name }}{% else %} · All permitted branches{% endif %}{% if overview.financial_year %} · FY {{ overview.financial_year }}{% endif %}
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{# Dashboard sections are now part of the unified Partner Dashboard submenu. #}
|
|
|
|
<div id="partner-dashboard-panel"
|
|
data-initial-tab="{{ active_tab }}"
|
|
class="min-h-[360px]">
|
|
<div class="rounded-3xl border border-slate-200 bg-white p-8 text-center text-sm text-slate-500 shadow-soft">Loading dashboard...</div>
|
|
</div>
|
|
</section>
|
|
|
|
<script>
|
|
(function () {
|
|
"use strict";
|
|
|
|
const panel = document.getElementById('partner-dashboard-panel');
|
|
if (!panel) return;
|
|
|
|
const dashboardLinks = Array.from(document.querySelectorAll(
|
|
'[data-uiux-v2-pilot="partner"] a[href^="/partner/dashboard?tab="]'
|
|
));
|
|
|
|
function tabFromLink(link) {
|
|
try {
|
|
return new URL(link.href, window.location.origin).searchParams.get('tab') || 'overview';
|
|
} catch (error) {
|
|
return 'overview';
|
|
}
|
|
}
|
|
|
|
function setActive(tabName) {
|
|
dashboardLinks.forEach((link) => {
|
|
const active = tabFromLink(link) === tabName;
|
|
link.classList.toggle('bg-brand-50', active);
|
|
link.classList.toggle('text-brand-700', active);
|
|
link.classList.toggle('text-slate-700', !active);
|
|
if (active) {
|
|
link.setAttribute('aria-current', 'page');
|
|
} else {
|
|
link.removeAttribute('aria-current');
|
|
}
|
|
});
|
|
}
|
|
|
|
async function loadTab(tabName, pushState) {
|
|
setActive(tabName);
|
|
panel.innerHTML = '<div class="rounded-3xl border border-slate-200 bg-white p-8 text-center text-sm text-slate-500 shadow-soft">Loading...</div>';
|
|
|
|
try {
|
|
const response = await fetch('/partner/dashboard/tab/' + encodeURIComponent(tabName), {
|
|
headers: { 'X-Requested-With': 'fetch' }
|
|
});
|
|
if (!response.ok) throw new Error('Tab load failed');
|
|
|
|
panel.innerHTML = await response.text();
|
|
|
|
if (pushState) {
|
|
const url = new URL(window.location.href);
|
|
url.searchParams.set('tab', tabName);
|
|
history.pushState({ tab: tabName }, '', url.toString());
|
|
}
|
|
|
|
document.querySelectorAll('[data-uiux-v2-pilot="partner"] details[open]').forEach((details) => {
|
|
details.open = false;
|
|
});
|
|
} catch (error) {
|
|
panel.innerHTML = '<div class="rounded-3xl border border-red-200 bg-red-50 p-6 text-sm text-red-700 shadow-soft">Unable to load this dashboard section. Please refresh the page.</div>';
|
|
}
|
|
}
|
|
|
|
dashboardLinks.forEach((link) => {
|
|
link.addEventListener('click', function (event) {
|
|
if (window.location.pathname !== '/partner/dashboard') return;
|
|
event.preventDefault();
|
|
loadTab(tabFromLink(link), true);
|
|
});
|
|
});
|
|
|
|
window.addEventListener('popstate', function () {
|
|
const url = new URL(window.location.href);
|
|
loadTab(url.searchParams.get('tab') || 'overview', false);
|
|
});
|
|
|
|
loadTab(panel.dataset.initialTab || 'overview', false);
|
|
})();
|
|
</script>
|
|
{% endblock %}
|