Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions apps/web/src/components/dashboard/DepositTab.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,7 @@
import { useTranslation } from "react-i18next";
import { AmountInput } from "../ui/AmountInput";
import type { ApiPosition, ApiVault } from "../../lib/api";

function formatUsd(value: number, locale: string) {
return value.toLocaleString(locale === "fr" ? "fr-FR" : "en-US", {
style: "currency",
currency: "USD",
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
}
import { formatUsd } from "../../lib/format";

interface DepositTabProps {
amount: string;
Expand Down
10 changes: 1 addition & 9 deletions apps/web/src/components/dashboard/PositionSummary.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { useTranslation } from "react-i18next";
import type { ApiPosition } from "../../lib/api";

function formatUsd(value: number, locale: string) {
return value.toLocaleString(locale === "fr" ? "fr-FR" : "en-US", {
style: "currency",
currency: "USD",
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
}
import { formatUsd } from "../../lib/format";

interface PositionSummaryProps {
position: ApiPosition;
Expand Down
15 changes: 15 additions & 0 deletions apps/web/src/lib/format.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Formats a numeric USD value as a localised currency string.
*
* @param value - The numeric amount to format.
* @param locale - The i18n locale string (e.g. "en", "fr").
* @returns A string such as "$1,234.56" or "1 234,56 $US".
*/
export function formatUsd(value: number, locale: string): string {
return value.toLocaleString(locale === "fr" ? "fr-FR" : "en-US", {
style: "currency",
currency: "USD",
minimumFractionDigits: 2,
maximumFractionDigits: 2,
});
}