fix(dashboard): route five screens through the api client - #205
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Recovered from an abandoned worktree that never opened a PR.
What was broken
Five screens called
fetchdirectly, and each was broken in its own way:/api/v1/.../v1/payment-links/...${NEXT_PUBLIC_API_BASE_URL}/v1/...""— also relativeNone of them sent an
Authorizationheader, so even with a correct URL they would have 401'd.Routing through
apifixes the origin, the/v1prefix and the bearer token at once, and picks up refresh-on-401 for free. It also puts these screens under the versionless-path ruleassertVersionlessPathnow enforces.Two behaviour fixes found while verifying
The payments table on the link detail page was silently always empty. It read
.datafrom the response, but that endpoint is paginated as{ items, meta }and the client already unwraps the outer{ data }— so the value was alwaysundefined, 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 nocatch. 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.