Skip to content

fix(nav): honest loading/multi-role/wallet state, contextual empties,… - #564

Merged
chonilius merged 1 commit into
MergeFi:mainfrom
Chidubemkingsley:fix/nav-state-empty-states-locale-connect
Sep 27, 2026
Merged

chonilius merged 1 commit into
MergeFi:mainfrom
Chidubemkingsley:fix/nav-state-empty-states-locale-connect

Conversation

@Chidubemkingsley

Copy link
Copy Markdown
Contributor

Also fixed en route, all pre-existing and all blocking next build

  • dashboard/loading.tsx closed a <Card> with </div> (parse error).
  • MilestoneActions.test.tsx and CallbackClient.test.tsx had unterminated it( blocks that silently swallowed the following tests.
  • social-image.tsx had a <div> with three children and no display, which Satori rejects; it failed prerendering of /opengraph-image.
  • Duplicated JSX props/icons in Navbar, ConnectPanel and StatCard rendered two chevrons / two wallet icons / two status icons.
  • Badge rendered lower-case "in review" while BountyStatus independently rendered "In Review" for the same enum; both now share one label map.

What this PR does

Closes

Closes #

What changed

How to test

Checklist

  • npm run lint passes locally
  • npm test passes locally
  • npm run build passes locally
  • This change is actually reachable/used in the running app
  • I have tested this change in the browser (if UI-related)

… locale-aware formatting

Four related state-correctness problems, one branch. Full verification:
lint, tsc, 601 tests, next build, verify:env, verify:headers, npm audit.

Navbar / auth state matrix
- `loading` now covers in-flight re-resolves, not just mount. It only ever
  went true -> false because `refresh()` never set it back, so for the whole
  GitHub OAuth round trip the nav rendered its signed-out CTAs — including a
  live "Connect GitHub" button that re-entered the flow the user had just
  finished. Overlapping resolves are ref-counted so an early one cannot
  report "resolved" while a later one is still pending.
- Loading renders a width-matched `aria-busy` skeleton instead of nothing,
  so a persisted session never flashes logged-out and the header does not jump.
- Multi-role is a first-class case. `AuthUser.roles` is an array and a
  maintainer who also sponsors holds both; the dashboard menu is now derived
  from the array (filtered, de-duplicated, unknown values dropped) instead of
  listing all three for everyone. A multi-role account gets a count badge and
  an explanation; a zero-role account gets an explanation, not a silent gap.
- A wallet connected in the browser but never saved to the profile is shown
  as an amber warning, never as the same green chip as a server-confirmed
  link. Wallet drift was previously invisible until it blocked a payment.
- `refresh()`'s declared `Promise<void>` was a lie; it is `Promise<AuthUser|null>`.
- New `degraded` flag: a token that could not be exchanged because the backend
  was unreachable is not "signed out". `user === null` made every dashboard's
  `if (!user)` branch render mock data as the user's own.

Empty states
- `EmptyState` gains `tone` (neutral/success/info/warning), `size`, optional
  icon, `secondaryAction`, `className` and a real heading element (it was a
  bare `<p>`, so empty states were unreachable by heading navigation).
- Each call site now declares which situation it is: a sponsor who has funded
  nothing ("fund your first") is not a sponsor whose portfolio all settled
  ("every bounty settled", success tone, no CTA), and a maintainer with an
  empty review queue has finished, not failed.
- `/issues` gained a `?status=` facet so "filtered to zero" is distinguishable
  from "the platform has none" — the fix differs (clear filters vs fund one).
  The route becomes dynamic, which is required for the filter to work at all.
- `ActivityList` with no events rendered a bordered card containing zero rows;
  it now renders an explanation, and is a `<ul>` with `<time datetime>`.
- Reputation profiles with no merged PRs get a consolidated empty state with a
  next step instead of four "0" cards and two bare grey spans.
- Dead `#open-bounties` anchor in the contributor dashboard now has a target.

Data provenance
- The amber "Sample data" chip was copy-pasted into six places; it is now a
  component, plus a full `DataSourceNotice` banner on the four surfaces that
  consumed a mock fallback with no indicator at all. Emptiness and "not real
  data" render as siblings, because a backend outage whose fallback list is
  empty is both at once and showing only one misleads in both directions.

Connect flow
- Ordering policy is now explicit and enforced in the UI: GitHub sign-in
  before wallet connection, because the payout address is written server-side
  keyed to the authenticated user. A signed-out connect was returning a
  Freighter permission grant the backend never recorded, rendered as an
  identical green "Connected" banner, with no way to re-link or disconnect —
  leaving payouts pointed nowhere.
- New `WalletContext.linkState` ("none" | "local" | "linked") makes that
  distinction a value the UI can render instead of infer.
- `/auth/callback` returns to `/connect` when the resolved user has no wallet.
  Nothing in the dashboard nav links back, so a user who signed in from the
  connect page previously could never finish connecting.
- A failed `login()` now surfaces an error instead of silently landing on a
  dashboard that would render mock data as if it were real.

WalletContext / useWalletAction fixes
- `disconnect()` left the mismatch flags set, and `useWalletAction` blocks on
  them — so "disconnect and reconnect" was an unescapable loop. It also left a
  stale connect error on /connect forever.
- Cross-tab address adoption never set `network`, rendering "Connected: … ()".
- The logout-clearing effect's only dep was `user`, which is null from the
  first render on a cold load, so it never ran: a signed-out visitor kept a
  usable address and `useWalletAction` would fund a bounty against it with no
  connect() and no profile write. Gated on `authLoading` too.
- New `initializing` flag distinguishes "still reading localStorage" from
  "not connected"; `useWalletAction` blocks instead of re-prompting Freighter.
- `refresh()` is now called after a successful unlink, so the nav stops
  advertising a payout address the user just removed.

i18n scope decision
No next-intl, no locale-prefixed routing, no shipped second language. Those
need a product decision about which languages to support, and a half-done
translation surface is worse than none. What ships is the half that is correct
regardless of that decision:

- All date/number/percent/relative-time/crypto formatting now routes through
  `Intl` driven by the viewer's locale. Four sites hardcoded "en-US" and one
  (`page.tsx`) used no locale at all, so a de-DE viewer saw US formatting
  everywhere — and that last one was a latent hydration mismatch, since the
  server and client would resolve different locales.
- `lib/locale.ts` is the single seam a future next-intl swap replaces.
- `<html lang>`/`dir` are set pre-hydration by an init script (the technique
  ThemeContext already uses), so an RTL viewer never sees an LTR first frame.
- USDC/XLM deliberately use a suffix, not `style: "currency"`: they are Stellar
  asset tickers, not ISO 4217 codes, and en-US ISO placement renders a fiat
  prefix ("USD 1,234.56") no crypto surface uses. Everything numeric still
  comes from `Intl`.
- `parseMoneyInput` no longer round-trips through `toLocaleString("en-US")`
  and strips ASCII commas, which corrupted every non-en-US locale (de-DE
  "12.500" -> three decimals; fr-FR left a narrow no-break space in the wire
  format). It now reads the viewer's notation, and treats "." as grouping only
  when the locale's own decimal mark is also present — otherwise a de-DE
  number input's "1234.56" would become 123456, a 1000x deposit overstatement.
- Strings live in `lib/messages.ts` with typed keys and real ICU plural
  resolution, so a future extractor has one file to walk. `formatDaysUntil`'s
  `days === 1 ? "" : "s"` only ever worked for English.
- RTL: all 16 physical directional Tailwind classes converted to logical
  properties; `Tabs` arrow-key navigation mirrors under `dir="rtl"` (SVG and
  the sparkline do not inherit `dir`, so the sparkline is mirrored explicitly);
  the markdown renderer's blockquote/list indentation is now inline-start.

Also fixed en route, all pre-existing and all blocking `next build`
- `dashboard/loading.tsx` closed a `<Card>` with `</div>` (parse error).
- `MilestoneActions.test.tsx` and `CallbackClient.test.tsx` had unterminated
  `it(` blocks that silently swallowed the following tests.
- `social-image.tsx` had a `<div>` with three children and no `display`, which
  Satori rejects; it failed prerendering of /opengraph-image.
- Duplicated JSX props/icons in Navbar, ConnectPanel and StatCard rendered two
  chevrons / two wallet icons / two status icons.
- `Badge` rendered lower-case "in review" while `BountyStatus` independently
  rendered "In Review" for the same enum; both now share one label map.
@drips-wave

drips-wave Bot commented Sep 27, 2026

Copy link
Copy Markdown

@Chidubemkingsley 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

@vercel

vercel Bot commented Sep 27, 2026

Copy link
Copy Markdown

@Chidubemkingsley is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

@chonilius
chonilius merged commit 0b5ba0b into MergeFi:main Sep 27, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants