Client Care Dashboard: choose AND or OR when multiple add-on categories are selected
Objective
- Let Client Care staff choose how multiple add-on global categories combine when more than one category is selected:
- Match all (AND) — count only core orders that carry every selected category (via distinct services / charges as appropriate).
- Match any (OR) — keep today’s union behavior: orders that carry at least one of the selected categories (current combined add-on semantics).
- Default behavior - (OR)
- Ensure combined add-on metrics and scheduler
selectedAddOnRate(when categories are passed) follow the same mode so the dashboard never implies one rule while the API applies another. - Make the active rule obvious in the UI (copy next to the control and/or combined card) so numbers are not misread.
Background
- Coordinators reported that with two categories selected (e.g. radon + termite), results looked like either category, not both — that matches current backend combined logic (union of service ids → ANY).
- Internal thread: Message from ryan — Slack.
- Original intake: "On the Client Care dashboard, the add-on selector appears to use OR logic instead of AND logic. For example, selecting radon and termite shows orders with either add-on instead of only orders that have both."
- Decision needed: Default for users who never touch the control (and for existing saved views with no stored mode): treat as match any (OR) to preserve legacy numbers, vs default match all (AND) — product call.
- Decision needed: When only one category is selected, hide the control vs show disabled with helper text — minor UX.
Scope
Frontend
attik-frontend/src/app/admin/client-care-dashboard/_components/AddonRatesPanel.tsx— add a clear control (e.g. segmented buttons or radio group): Match all / Match any, visible when two or more categories are selected (unless product prefers always visible).attik-frontend/src/app/admin/client-care-dashboard/CCDashboardClient.tsx— pass the chosen mode oncc-dashboard/metricsandcc-dashboard/scheduler-metricsrequests alongsideglobalCategoryIds(exact query key is Decision needed, e.g.globalCategoryMatch=all|any).attik-frontend/src/app/admin/client-care-dashboard/view/[viewId]/page.tsxandSaveViewModal/ save payload — persist mode on the saved view when Decision needed for schema field name.attik-frontend/src/app/admin/client-care-dashboard/_types.ts— extend saved-view / client types for the new field.attik-frontend/src/app/admin/client-care-dashboard/ClientCareViewsClient.tsx— optional: surface mode in the view list summary if saved per view.- Per-category
addonRatescards today are inherently per category; Decision needed whether AND/OR only affectsaddonRatesCombined(and scheduler) or also changes how individual cards are interpreted.
Backend
attik-backend/src/routes/ccDashboard.ts— extendGET /cc-dashboard/metrics: honor mode when computingaddonRatesCombined(and document in response types / file header comment). AND likely requires counting inspections that have at least one qualifying charge per selected category (intersection of distinct inspection id sets or equivalent aggregation), not a single flat$inover unioned service ids.- Same file —
GET /cc-dashboard/scheduler-metrics: apply the same parameter toselectedAddOnRate/resolveAddonServiceIdsForCategoriesusage so scheduler totals agree with the dashboard. attik-backend/src/models/ccDashboardViewSchema.tsandattik-backend/src/routes/ccDashboardSavedViews.ts— add optional persisted field for the mode; migration: missing field → default per product (see Background).attik-backend/scripts/createCcDashboardViews.ts/cc_inspection_base— only touch if AND cannot be expressed efficiently in the route; otherwise keep view unchanged.
Product
- Final labels for end users ("All selected add-ons" vs "Any selected add-on" or similar) and tooltip text explaining denominators (core orders).
- Release note: saved views gain optional mode; default behavior for old views.
References
- Message from ryan — Slack
attik-frontend/src/app/admin/client-care-dashboard/CCDashboardClient.tsxattik-frontend/src/app/admin/client-care-dashboard/_components/AddonRatesPanel.tsxattik-backend/src/routes/ccDashboard.tsattik-backend/src/routes/ccDashboardSavedViews.tsattik-backend/src/models/ccDashboardViewSchema.tsattik-backend/scripts/createCcDashboardViews.ts
Status: Completed
Log in to comment and vote
No comments yet
Be the first to share your thoughts.