Repository navigation
Shared HTTP layer, admin nav and component placement cleanup - #2051
Open
devrabiuhussain wants to merge 1 commit into
Open
devrabiuhussain wants to merge 1 commit into
devrabiuhussain wants to merge 1 commit into
Conversation
…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.
|
@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. |
|
@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! 🚀 |
This branch has not been deployed
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.
Summary
Implements the shared HTTP layer and cleanup work assigned to devrabiuhussain:
lib/http.tswith a typedrequest()helper (base URL, optional bearer +credentials: "include"default, JSON serialization,ApiErrorwith status/code/message, onereportApiErrorhook, payments retry semantics, 204 handling, array-message joining). All five *-api modules migrated;adminFetch/apiFetch/credentialsFetchbecame thin wrappers. Public signatures unchanged exceptaccessToken: string→accessToken?: string.components/admin/admin-nav.tsxwithADMIN_NAV(6 existing entries + Payments/CreditCard, Charge credits/Zap, Refunds/RotateCcw),ADMIN_NAV_EXEMPT_ROUTES, clientAdminNavwitharia-current="page"+ active marking.app/admin/layout.tsxrenders it; inline nav deleted.lib/WalletStatusCard.tsx+lib/WalletFundingModal.tsx; movedAdminCreditsManagement→components/admin/credits-management.tsx;esrow.md→docs/escrow.md; inline eslint filename rules ineslint.config.mjs.lib/i18n/*(config.ts, index.ts, messages/en.json).Test updates
lib/__tests__/http.test.ts(14 tests),components/admin/__tests__/admin-nav.test.tsx(route-completeness guard + active marking)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
no-components-in-libflags.tsxfiles whose parent directory islib, not deeper files. The two pre-existing legit components directly inlib/(providers.tsx,query-provider.tsx) got a documented inlineeslint-disableeach sonpm run lintstays green without moving them.API_BASE_URL: read lazily insiderequest()rather than as a module-load-time const — same runtime behavior, makes the base-URL test deterministic.Merge coordination
accessTokenparameter and headers entirely in favor of cookie session semantics. If both merge, resolve in favor of ykargee-bit's cookie session semantics and re-apply the sharedrequest()helper on top.Closes #1976
Closes #1978
Closes #1981
Closes #1982