Skip to content

fix(dashboard): route five screens through the api client - #205

Merged
0xdevcollins merged 1 commit into
mainfrom
fix/dashboard-api-client
Aug 9, 2026
Merged

fix(dashboard): route five screens through the api client#205
0xdevcollins merged 1 commit into
mainfrom
fix/dashboard-api-client

Conversation

@0xdevcollins

Copy link
Copy Markdown
Owner

Recovered from an abandoned worktree that never opened a PR.

What was broken

Five screens called fetch directly, and each was broken in its own way:

screen called problem
payouts, recipients, CreatePayoutDialog /api/v1/... a path the dashboard does not serve and the API does not expose — always 404
links detail /v1/payment-links/... relative to the dashboard origin, never reached the API
AnalyticsDashboard ${NEXT_PUBLIC_API_BASE_URL}/v1/... that variable is not defined anywhere in this repo, so the base was "" — also relative

None of them sent an Authorization header, so even with a correct URL they would have 401'd.

Routing through api fixes the origin, the /v1 prefix and the bearer token at once, and picks up refresh-on-401 for free. It also puts these screens under the versionless-path rule assertVersionlessPath now enforces.

Two behaviour fixes found while verifying

The payments table on the link detail page was silently always empty. It read .data from the response, but that endpoint is paginated as { items, meta } and the client already unwraps the outer { data } — so the value was always undefined, with no error to explain it. Now reads .items. I checked each endpoint's envelope against the running API individually; the others genuinely are { ..., data } shaped.

CreatePayoutDialog was fire-and-forget. .then() closed the dialog whether or not the payout was created, with no catch. A failure now surfaces a toast and leaves the dialog open.

The link page also moves to Promise.allSettled, so a failing stats or payments call no longer takes down a page whose link loaded fine.

Verification

Dashboard: typecheck clean, 0 lint errors, 38/38 tests.

These five called `fetch` directly, and each was broken in its own way:

- payouts, recipients and CreatePayoutDialog hit `/api/v1/...` — a path the
  dashboard does not serve and the API does not expose. Always 404.
- links hit `/v1/payment-links/...` relative to the dashboard origin, so it
  never reached the API either.
- AnalyticsDashboard built a base from `NEXT_PUBLIC_API_BASE_URL`, a variable
  that is not defined anywhere in this repo. It resolved to `""`, making every
  analytics call relative to the dashboard too.

None of them sent an Authorization header, so even with a correct URL they
would have 401'd. Going through `api` fixes the origin, the `/v1` prefix and
the bearer token at once, and picks up refresh-on-401 for free.

Two behaviour fixes that came with it:

- The link detail page read `.data` from the payments response. That endpoint
  is paginated as `{ items, meta }`, and the client already unwraps the outer
  `{ data }`, so the value was always undefined — the payments table rendered
  empty and silently. It reads `.items` now. The other endpoints here really
  are `{ ..., data }` shaped and were checked against the running API
  individually.
- CreatePayoutDialog was fire-and-forget: `.then()` closed the dialog whether
  or not the payout was created, with no catch. A failure now surfaces a toast
  and leaves the dialog open.

The link page also moves to `Promise.allSettled`, so a failing stats or
payments call no longer takes down the whole page when the link itself loaded.

Recovered from an abandoned worktree that never opened a PR.

Dashboard: typecheck clean, 0 lint errors, 38/38 tests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
useroutr-www Ready Ready Preview Aug 9, 2026 7:48pm

@0xdevcollins
0xdevcollins merged commit ffd7d2b into main Aug 9, 2026
8 checks passed
@0xdevcollins
0xdevcollins deleted the fix/dashboard-api-client branch August 9, 2026 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant