Skip to content

Commit 059d68e

Browse files
authored
fix(showcase): CRM Workbench KPI cards read adapter.find().data not .records (#2632)
The CRM Workbench KPI strip (Total projects / Active) rendered 0 even though the ListView beside it, backed by the same object, showed all rows. useAdapter()'s ObjectStackAdapter.find() normalizes to a QueryResult with a `data` array, not the REST envelope's `records`, so `all.records` always missed and both counts stuck at 0. Read `.data` first with `.records`/array fallbacks. Verified in-browser: cards now show Total 5 / Active 2.
1 parent fce8ff4 commit 059d68e

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

examples/app-showcase/src/ui/pages/crm-workbench.page.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ function Page() {
3131
const refreshStats = React.useCallback(async () => {
3232
if (!adapter) return;
3333
try {
34-
// Canonical QueryOptionsV2 keys only (limit, not the legacy top alias
35-
// removed in 11.0) — the KPI cards silently stuck at 0 whenever adapter.find
36-
// rejected on the unrecognized param, and the empty catch hid the failure.
34+
// useAdapter() is the console's ObjectStackAdapter — its find() resolves to
35+
// a normalized QueryResult with a "data" array, NOT the REST envelope with
36+
// a "records" array. Reading .records here always missed, so the KPI cards
37+
// silently stuck at 0 even though the ListView beside them showed the same
38+
// rows. Read .data first, with .records/array fallbacks for robustness.
3739
const all = await adapter.find('showcase_project', { limit: 200 });
38-
const rows = Array.isArray(all) ? all : (all && all.records) || [];
40+
const rows = Array.isArray(all) ? all : (all && (all.data || all.records)) || [];
3941
setStats({ total: rows.length, active: rows.filter((r) => r.status === 'active').length });
4042
} catch (e) { console.warn('[CRM Workbench] failed to refresh stats', e); }
4143
}, [adapter]);

0 commit comments

Comments
 (0)