diff --git a/frontend/src/pages/communities.astro b/frontend/src/pages/communities.astro
index 8afcb03..ed3d202 100644
--- a/frontend/src/pages/communities.astro
+++ b/frontend/src/pages/communities.astro
@@ -96,6 +96,56 @@ import { API_BASE as apiBase } from '../lib/api';
container.innerHTML = html;
}
+ function renderErrorState(message) {
+ var container = document.getElementById('communities-list');
+ if (!container) return;
+
+ container.innerHTML =
+ '
' +
+ '
' + escapeHtml(message) + '
' +
+ '
Check your connection and try again.
' +
+ '
' +
+ '
';
+
+ var retryBtn = document.getElementById('retry-communities');
+ if (retryBtn) {
+ retryBtn.addEventListener('click', function() {
+ loadCommunities();
+ });
+ }
+ }
+
+ function renderEmptyState(isFiltered) {
+ var container = document.getElementById('communities-list');
+ if (!container) return;
+
+ var label = isFiltered ? 'No communities match your search.' : 'No communities found.';
+ var hint = isFiltered ? 'Try a different keyword or clear the search.' : 'Please try again later.';
+
+ container.innerHTML =
+ '' +
+ '
' + label + '
' +
+ '
' + hint + '
' +
+ '
' +
+ (isFiltered ? '' : '') +
+ '
Refresh' +
+ '
' +
+ '
';
+
+ var resetBtn = document.getElementById('reset-community-search');
+ if (resetBtn) {
+ resetBtn.addEventListener('click', function() {
+ var searchInput = document.getElementById('search-input');
+ if (searchInput) searchInput.value = '';
+ currentQuery = '';
+ applyFilterSortAndRender();
+ });
+ }
+ }
+
function sortCommunities(list) {
var sorted = list.slice();
sorted.sort(function(a, b) {
@@ -128,7 +178,7 @@ import { API_BASE as apiBase } from '../lib/api';
if (!container) return;
if (!communities || communities.length === 0) {
- container.innerHTML = '';
+ renderEmptyState(!!String(currentQuery || '').trim());
return;
}
@@ -189,7 +239,8 @@ import { API_BASE as apiBase } from '../lib/api';
})
.catch(function(error) {
console.error('Failed to load communities:', error);
- container.innerHTML = 'Failed to load communities.
Please try again later.
';
+ updateKpis('—', '—', '');
+ renderErrorState('Failed to load communities.');
});
}
diff --git a/frontend/src/pages/communities/[slug]/index.astro b/frontend/src/pages/communities/[slug]/index.astro
index 4e6b988..add303f 100644
--- a/frontend/src/pages/communities/[slug]/index.astro
+++ b/frontend/src/pages/communities/[slug]/index.astro
@@ -18,6 +18,24 @@ const { slug } = Astro.params;