You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|[`Tooltip`](src/components/Tooltip.tsx)| Status surface with loading/empty/error/success states (see [tooltips.md](docs/tooltips.md)) |
61
-
|[`Slippage`](src/components/Slippage.tsx)| Slippage tolerance control with preset/custom options and state handling (see [slippage.md](docs/slippage.md)) |
61
+
|[`QuoteHistory`](src/app/quote/QuoteHistory.tsx)| Recent quote history list with selection callback and memoization (see [history.md](docs/history.md)) |
62
62
63
63
Data fetching helpers (`apiClient`, `useApi`, `useList`) live in `src/lib`.
| 5 | Display | Formats amount via `formatQuoteAmountDisplay` / `formatQuoteRateDisplay` (both from `src/lib/format.ts`). |
127
-
| 6 | History | Inputs persisted to `localStorage` via `useLocalStorage` (`src/lib/useLocalStorage.ts`). |
127
+
| 6 | History | Inputs persisted to `localStorage` via `useLocalStorage` (`src/lib/useLocalStorage.ts`) and rendered via `QuoteHistory` (see [`docs/history.md`](history.md)).|
The `QuoteHistory` component renders a list of recently requested currency routing path quotes persisted in `localStorage`. Clicking a history item applies its saved inputs (`source`, `dest`, `amount`) back into the quote form.
4
+
5
+
The component is memoized (`React.memo`) so stable prop references prevent unnecessary re-renders when parent form inputs, loading state, or error messages update.
6
+
7
+
## Props
8
+
9
+
| Prop | Type | Required | Description |
10
+
|---|---|---|---|
11
+
|`history`|`HistoryEntry[]`| Yes | List of recently saved quote input entries. |
12
+
|`onSelect`|`(entry: HistoryEntry) => void`| Yes | Callback invoked when a user clicks a history button to select an entry. |
13
+
14
+
## Types
15
+
16
+
```typescript
17
+
exporttypeQuoteInputs= {
18
+
source:string;
19
+
dest:string;
20
+
amount:string;
21
+
};
22
+
23
+
exporttypeHistoryEntry=QuoteInputs& {
24
+
savedAt:number; // Unix timestamp in milliseconds when saved
25
+
};
26
+
27
+
exportinterfaceQuoteHistoryProps {
28
+
history:HistoryEntry[];
29
+
onSelect: (entry:HistoryEntry) =>void;
30
+
}
31
+
```
32
+
33
+
## Behavior & Rendering Contract
34
+
35
+
-**Empty State** — If `history` is empty (`history.length === 0`), `QuoteHistory` renders `null`.
36
+
-**Item Display** — Each entry is rendered as a full-width button displaying `{entry.source} → {entry.dest} · {entry.amount}`.
37
+
-**Memoization** — Wrapped with `React.memo`. Re-renders only when `history` array reference or `onSelect` function reference changes.
38
+
-**Persistence** — Quotes are stored in `localStorage` under `stableroute.quote.history`, limited to a maximum of 5 entries. Duplicate entries are deduplicated on push.
0 commit comments