refactor: extract shared formatEur and getTradeStatusDisplay utilities

- Create frontend/app/utils/exchange.ts with shared formatting functions
- Update exchange/page.tsx to use shared formatEur
- Update trades/page.tsx to use shared formatEur and getTradeStatusDisplay
- Update admin/trades/page.tsx to use shared formatEur and getTradeStatusDisplay
- SatsDisplay was already extracted (confirmed it's in components/SatsDisplay.tsx)
This commit is contained in:
counterweight 2025-12-23 10:52:53 +01:00
parent 4e6f38e4a1
commit 110e5ec07f
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
4 changed files with 62 additions and 117 deletions

View file

@ -10,6 +10,7 @@ import { SatsDisplay } from "../components/SatsDisplay";
import { useRequireAuth } from "../hooks/useRequireAuth";
import { components } from "../generated/api";
import { formatDate, formatTime, getDateRange } from "../utils/date";
import { formatEur } from "../utils/exchange";
import { layoutStyles, typographyStyles, bannerStyles, buttonStyles } from "../styles/shared";
type ExchangePriceResponse = components["schemas"]["ExchangePriceResponse"];
@ -24,13 +25,6 @@ const MAX_ADVANCE_DAYS = 30;
type Direction = "buy" | "sell";
type WizardStep = "details" | "booking";
/**
* Format EUR amount from cents to display string
*/
function formatEur(cents: number): string {
return `${(cents / 100).toLocaleString("de-DE")}`;
}
/**
* Format price for display
*/