diff --git a/frontend/src/pages/dashboard.astro b/frontend/src/pages/dashboard.astro index 0021534..889dcb5 100644 --- a/frontend/src/pages/dashboard.astro +++ b/frontend/src/pages/dashboard.astro @@ -4,9 +4,15 @@ import { API_BASE as apiBase } from '../lib/api'; --- -
-
-

Loading...

+
+
+
+
+
+
+
+
+
@@ -21,50 +27,129 @@ import { API_BASE as apiBase } from '../lib/api'; const user = JSON.parse(userStr || '{}'); + function escapeHtml(value) { + return String(value || '').replace(/[&<>"']/g, function(ch) { + switch (ch) { + case '&': return '&'; + case '<': return '<'; + case '>': return '>'; + case '"': return '"'; + case "'": return '''; + default: return ch; + } + }); + } + + function normalizeStatus(status) { + const s = String(status || '').toLowerCase(); + if (s === 'draft' || s === 'discussion' || s === 'voting' || s === 'closed') return s; + return 'draft'; + } + + function setText(id, value) { + const el = document.getElementById(id); + if (el) el.textContent = String(value); + } + + function setBadge(id, value) { + const el = document.getElementById(id); + if (!el) return; + const str = String(value); + el.textContent = str; + el.setAttribute('aria-label', str); + } + async function loadDashboard() { const container = document.getElementById('dashboard-content'); if (!container) return; + const safeName = escapeHtml(user.display_name || user.username || ''); + const safeEmail = escapeHtml(user.email || ''); + container.innerHTML = ` -
-

Welcome, ${user.display_name || user.username}!

-

${user.email}

-
- -
-
-

My Communities

-
-

Loading...

+
+
+
+

Welcome, ${safeName}!

+

${safeEmail}

+
+
-
-

My Proposals

-
-

Loading...

-
-
- -
-

Recent Activity

-
-

Loading...

-
-
- -
-

Quick Actions

-
- Create Community - Browse Communities +
+
At a glance
+
+
+
+
My communities
+
+
+
+
My proposals
+
+
+
+
Recent activity
+
-