Update formatCurrency to use currency code from UserSettings
Changes: - Updated formatCurrency function: - Added currencyCode parameter with EUR default - Implemented Intl.NumberFormat for proper currency formatting - Added fallback for invalid currency codes - Updated component hierarchy to pass currency: - HomePage: Fetch userSettings and pass to MonthLocationList - MonthLocationList: Accept and pass currency to child components - LocationCard: Accept currency prop and use in formatCurrency - MonthCard: Accept currency prop and use in formatCurrency - ViewLocationCard: Pass currency from userSettings to formatCurrency - Removed hardcoded $ symbols, now using proper currency formatting All currency amounts now display with the user's selected currency code from their settings, using locale-appropriate formatting (hr-HR). 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -11,10 +11,11 @@ import { useLocale, useTranslations } from "next-intl";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
export interface LocationCardProps {
|
||||
location: BillingLocation
|
||||
location: BillingLocation;
|
||||
currency?: string | null;
|
||||
}
|
||||
|
||||
export const LocationCard:FC<LocationCardProps> = ({location}) => {
|
||||
export const LocationCard:FC<LocationCardProps> = ({location, currency}) => {
|
||||
const { _id, name, yearMonth, bills, seenByTenant } = location;
|
||||
|
||||
console.log("seenByTenant:", seenByTenant);
|
||||
@@ -59,7 +60,7 @@ export const LocationCard:FC<LocationCardProps> = ({location}) => {
|
||||
monthlyExpense > 0 ?
|
||||
<div className="flex items-center gap-2">
|
||||
<BanknotesIcon className="h-5 w-5" />
|
||||
{ t("payed-total-label") } <strong>${formatCurrency(monthlyExpense)}</strong>
|
||||
{ t("payed-total-label") } <strong>{formatCurrency(monthlyExpense, currency ?? "EUR")}</strong>
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user