Skip to content

Shared HTTP layer, admin nav and component placement cleanup - #2051

Open
devrabiuhussain wants to merge 1 commit into
DistinctCodes:mainfrom
devrabiuhussain:feature/shared-http-cleanup
Open

devrabiuhussain wants to merge 1 commit into
DistinctCodes:mainfrom
devrabiuhussain:feature/shared-http-cleanup

Conversation

@devrabiuhussain

Copy link
Copy Markdown

Summary

Implements the shared HTTP layer and cleanup work assigned to devrabiuhussain:

Test updates

  • New: lib/__tests__/http.test.ts (14 tests), components/admin/__tests__/admin-nav.test.tsx (route-completeness guard + active marking)
  • Updated: lib/__tests__/wallet-api.test.ts (credentials assertion → include)

Credentials decision (wallet-api)

Chose the first option: shared default credentials: "include" (sane globally — wallet requests rely solely on the HttpOnly cookie, which must cross origins), with only that one assertion updated.

Deviations / notes

  • ESLint rule scope: no-components-in-lib flags .tsx files whose parent directory is lib, not deeper files. The two pre-existing legit components directly in lib/ (providers.tsx, query-provider.tsx) got a documented inline eslint-disable each so npm run lint stays green without moving them.
  • API_BASE_URL: read lazily inside request() rather than as a module-load-time const — same runtime behavior, makes the base-URL test deterministic.
  • Optional-parameter shape: TS forbids a required param after an optional one, so multi-param signatures made every trailing param optional.

Merge coordination

Closes #1976
Closes #1978
Closes #1981
Closes #1982

…uhussain)

- Add lib/http.ts exposing one typed request(): shared base URL, optional
  bearer auth plus cookie credentials, JSON handling, typed ApiError with
  status/code/message, one Sentry reporting hook, and the payments retry
  semantics; migrate auth/admin/payments/wallet/credits modules onto it
  and drop token threading from every caller (Closes DistinctCodes#1976)
- Add missing admin nav entries (Payments, Charge credits, Refunds) with
  an active-route aria-current marker and a guard test that fails when a
  new app/admin page lacks a nav entry or explicit exemption (Closes DistinctCodes#1978)
- Delete unused lib/WalletStatusCard.tsx and lib/WalletFundingModal.tsx,
  move AdminCreditsManagement under components/admin/, move esrow.md to
  docs/escrow.md, and add filename lint rules keeping React components out
  of lib/ with kebab-case component filenames (Closes DistinctCodes#1981)
- Delete the dead lib/i18n module (Closes DistinctCodes#1982)

Notes for reviewers:
- Existing api tests pass unchanged except assertions on exact fetch
  credentials where the shared helper now defaults to credentials:
  "include" so the backend's HttpOnly session cookie is sent cross-origin.
- Module signatures keep an optional backward-compatible accessToken
  parameter (tests pass tokens directly); the cookie-session refactor PR
  (DistinctCodes#1975 by ykargeee-bit) removes the parameter and bearer headers
  entirely, so expect small textual conflicts in the five api modules and
  their tests when both land.
@vercel

vercel Bot commented Oct 17, 2026

Copy link
Copy Markdown

@devrabiuhussain is attempting to deploy a commit to the naijabuz's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Oct 17, 2026

Copy link
Copy Markdown

@devrabiuhussain Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment