mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-13 12:32:18 +00:00
fix: resolve 404 balances endpoint and currency formatting errors
- Add missing /api/v1/balances endpoint to backend - Update frontend Account type to match backend AccountDetails model - Add currency validation with EUR fallback in formatCurrency function - Update AccountsOverview, TransactionsList, and Dashboard components - Fix balance calculations to use balances array structure - All pre-commit checks pass
This commit is contained in:
committed by
Elisiário Couto
parent
947342e196
commit
417b77539f
@@ -5,10 +5,22 @@ export function cn(...inputs: ClassValue[]) {
|
||||
}
|
||||
|
||||
export function formatCurrency(amount: number, currency: string = 'EUR'): string {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: currency,
|
||||
}).format(amount);
|
||||
// Validate currency code - must be 3 letters and a valid ISO 4217 code
|
||||
const validCurrency = currency && /^[A-Z]{3}$/.test(currency) ? currency : 'EUR';
|
||||
|
||||
try {
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: validCurrency,
|
||||
}).format(amount);
|
||||
} catch (error) {
|
||||
// Fallback if currency is still invalid
|
||||
console.warn(`Invalid currency code: ${currency}, falling back to EUR`);
|
||||
return new Intl.NumberFormat('en-US', {
|
||||
style: 'currency',
|
||||
currency: 'EUR',
|
||||
}).format(amount);
|
||||
}
|
||||
}
|
||||
|
||||
export function formatDate(date: string): string {
|
||||
|
||||
Reference in New Issue
Block a user