Skip to content

refactor(app): render money and time only through the shared components - #48

Open
jdjioe5-cpu wants to merge 1 commit into
Kinlock-Org:mainfrom
jdjioe5-cpu:refactor/money-time-shared-components
Open

jdjioe5-cpu wants to merge 1 commit into
Kinlock-Org:mainfrom
jdjioe5-cpu:refactor/money-time-shared-components

Conversation

@jdjioe5-cpu

Copy link
Copy Markdown

Summary

Closes #40

Routes every in-scope money and time display through the shared components (`AmountDisplay`, `AssetLabel`, `DateTimeDisplay`) and introduces a static guard test to ensure zero regressions:

1. Pre-change Inventory

  • `Intl.NumberFormat` / `Intl.DateTimeFormat` / `toLocaleString` / `toFixed`: Zero call sites existed outside `lib/i18n/format.ts`.
  • `formatTokenAmount`: Directly called in `app/request/RequestForm.tsx` (rendering amount without asset issuer).
  • Raw timestamp formatting: Hardcoded string slice (`.replace("T", " ").slice(0, 16)} {t("time.utc")}`) used in `components/claim-links/SavedClaimLinks.tsx`.
  • Fallback raw amount: `components/receipts/ReceiptResult.tsx` rendered raw `fromBaseUnits(receipt.amount)` when `lock && usdc` was null.

2. In-Scope Replacements

  • `components/money/AmountDisplay.tsx`: Made `assetCode` and `issuer` optional props so fallback paths can format token amounts without guessing an asset issuer while retaining consistent numeric formatting.
  • `components/receipts/ReceiptResult.tsx`: Wrapped fallback amount in ``.
  • `app/request/RequestForm.tsx`: Replaced direct `formatTokenAmount` call with ``.
  • `components/claim-links/SavedClaimLinks.tsx`: Replaced string slice with ``; added `locale` state handling to `useSavedClaimLinks.ts` keeping `.tsx` pure markup.
  • `lib/i18n/format-usage.test.ts`: Added strict guard test modeled after `inline-strings.test.ts`. Scans `app/` and `components/`, only allowlisting `lib/i18n/format.ts`, `components/money/`, and `components/time/`. Verified locally that forbidden calls fail the test.

3. Out-of-Scope Money-Action Routes

As required by issue guidelines and Hard Rule 5, the money-action routes remain untouched and left for maintainer handling:

  • `app/send/**`
  • `app/locks/**`
  • `app/claim/**`
  • `app/r/**`
    Accordingly, roadmap row `M3-15` remains IN PROGRESS with changelog updated.

Hard rules touched

  • AGENTS.md §3 rule 5 (claim-link fragment zero-leak boundary strictly respected)
  • AGENTS.md §3 rule 7 (honest roadmap status: M3-15 kept IN PROGRESS for unbuilt money-action routes)
  • AGENTS.md §8.3 (asset label always shows code AND issuer; timestamps show dual UTC + local)
  • AGENTS.md §12 (ROADMAP.md Changelog and Last updated maintained)

Verify output

```bash
$ pnpm lint
Checked 84 files in 20ms. No fixes applied.

$ pnpm typecheck
tsc --noEmit (exited with 0)

$ pnpm test
Test Files 16 passed (16)
Tests 209 passed (209)
Start at 19:42:46
Duration 767ms

$ pnpm build
▲ Next.js 16.3.8 (Turbopack)
✓ Compiled successfully in 905ms
✓ Generating static pages using 14 workers (6/6) in 417ms
```

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.

Route every money and time display through the shared components, and enforce it

2 participants