arbret/frontend/app/utils/exchange.ts
counterweight e35e79e84d
Fix date/time formatting to use es-ES locale
- Update all date/time formatting functions to use 'es-ES' locale instead of 'en-US' or 'de-DE'
- Update utility functions in utils/date.ts and utils/exchange.ts
- Update all component files that use date formatting
- Update e2e test helper to match new Spanish date format
- All formatting now uses Spanish locale regardless of selected language as per PR requirements
2025-12-26 11:38:17 +01:00

59 lines
1.4 KiB
TypeScript

/**
* Exchange-related utility functions for formatting and display.
*/
/**
* Format EUR amount from cents to display string.
* e.g., 10000 -> "€100"
*/
export function formatEur(cents: number): string {
return `${(cents / 100).toLocaleString("es-ES")}`;
}
/**
* Get status display properties for trade status badges.
*/
export function getTradeStatusDisplay(status: string): {
text: string;
bgColor: string;
textColor: string;
} {
switch (status) {
case "booked":
return {
text: "Pending",
bgColor: "rgba(99, 102, 241, 0.2)",
textColor: "rgba(129, 140, 248, 0.9)",
};
case "completed":
return {
text: "Completed",
bgColor: "rgba(34, 197, 94, 0.2)",
textColor: "rgba(34, 197, 94, 0.9)",
};
case "cancelled_by_user":
return {
text: "User Cancelled",
bgColor: "rgba(239, 68, 68, 0.2)",
textColor: "rgba(239, 68, 68, 0.9)",
};
case "cancelled_by_admin":
return {
text: "Admin Cancelled",
bgColor: "rgba(239, 68, 68, 0.2)",
textColor: "rgba(239, 68, 68, 0.9)",
};
case "no_show":
return {
text: "No Show",
bgColor: "rgba(251, 146, 60, 0.2)",
textColor: "rgba(251, 146, 60, 0.9)",
};
default:
return {
text: status,
bgColor: "rgba(255, 255, 255, 0.1)",
textColor: "rgba(255, 255, 255, 0.6)",
};
}
}