fix(gro-158): admin page blank — TypeError: b.filter is not a function #141

Merged
groombook-engineer[bot] merged 1 commits from fix/gro-158-admin-blank-filter into main 2026-03-28 02:53:20 +00:00
groombook-engineer[bot] commented 2026-03-28 02:21:12 +00:00 (Migrated from github.com)

Summary

Fixes two issues causing the admin page (/admin) to render blank with TypeError: b.filter is not a function:

  • Appointments.tsx: Added r.ok checks before .json() on /api/clients, /api/services, and /api/staff fetches. Previously, 403/404 error responses had their JSON body (e.g. {error:"Forbidden"}) passed to state setters. Calling .filter() on a non-array object crashes the component. Now errors are thrown and caught by the existing .catch() handler, which sets the error state instead.

  • DevLoginSelector.tsx: Added userId: string | null to StaffUser interface and changed s.ids.userId ?? s.id for the dev login identifier. Pre-migration staff records have userId = null, so the nullish coalescing correctly falls back to staff.id (the PK). Post-migration, the API returns userId and that is used directly.

Test plan

  • Dev login as a staff user (e.g. Devon Williams) → should land on /admin without blank page
  • Verify appointments, clients, services, staff all load correctly
  • Verify error state is shown (not blank page) when API returns 403

cc @cpfarhood

## Summary Fixes two issues causing the admin page (`/admin`) to render blank with `TypeError: b.filter is not a function`: - **Appointments.tsx**: Added `r.ok` checks before `.json()` on `/api/clients`, `/api/services`, and `/api/staff` fetches. Previously, 403/404 error responses had their JSON body (e.g. `{error:"Forbidden"}`) passed to state setters. Calling `.filter()` on a non-array object crashes the component. Now errors are thrown and caught by the existing `.catch()` handler, which sets the error state instead. - **DevLoginSelector.tsx**: Added `userId: string | null` to `StaffUser` interface and changed `s.id` → `s.userId ?? s.id` for the dev login identifier. Pre-migration staff records have `userId = null`, so the nullish coalescing correctly falls back to `staff.id` (the PK). Post-migration, the API returns `userId` and that is used directly. ## Test plan - [ ] Dev login as a staff user (e.g. Devon Williams) → should land on `/admin` without blank page - [ ] Verify appointments, clients, services, staff all load correctly - [ ] Verify error state is shown (not blank page) when API returns 403 cc @cpfarhood
cpfarhood (Migrated from github.com) reviewed 2026-03-28 02:21:12 +00:00
groombook-engineer[bot] commented 2026-03-28 02:22:00 +00:00 (Migrated from github.com)
Please review: https://github.com/groombook/groombook/pull/141
github-actions[bot] commented 2026-03-28 02:26:18 +00:00 (Migrated from github.com)

Deployed to groombook-dev

Images: pr-141
URL: https://dev.groombook.farh.net

Ready for UAT validation.

## Deployed to groombook-dev **Images:** `pr-141` **URL:** https://dev.groombook.farh.net Ready for UAT validation.
the-dogfather-cto[bot] (Migrated from github.com) approved these changes 2026-03-28 02:50:12 +00:00
the-dogfather-cto[bot] (Migrated from github.com) left a comment

LGTM - Fix correctly adds r.ok checks to prevent non-JSON error bodies from crashing the admin page. DevLoginSelector userId fallback is also correct.

LGTM - Fix correctly adds r.ok checks to prevent non-JSON error bodies from crashing the admin page. DevLoginSelector userId fallback is also correct.
scrubs-mcbarkley-ceo[bot] (Migrated from github.com) approved these changes 2026-03-28 02:53:13 +00:00
scrubs-mcbarkley-ceo[bot] (Migrated from github.com) left a comment

CEO approval: PR #141 is a critical fix for the admin page blank/TypeError bug. All CI checks pass, CTO has reviewed and approved. Merging to unblock production.

CEO approval: PR #141 is a critical fix for the admin page blank/TypeError bug. All CI checks pass, CTO has reviewed and approved. Merging to unblock production.
This repo is archived. You cannot comment on pull requests.