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:
@@ -10,11 +10,12 @@ export interface MonthCardProps {
|
||||
yearMonth: YearMonth,
|
||||
children?: React.ReactNode,
|
||||
monthlyExpense:number,
|
||||
currency?: string | null,
|
||||
expanded?:boolean,
|
||||
onToggle: (yearMonth:YearMonth) => void
|
||||
}
|
||||
|
||||
export const MonthCard:FC<MonthCardProps> = ({ yearMonth, children, monthlyExpense, expanded, onToggle }) => {
|
||||
export const MonthCard:FC<MonthCardProps> = ({ yearMonth, children, monthlyExpense, currency, expanded, onToggle }) => {
|
||||
|
||||
const elRef = useRef<HTMLDivElement>(null);
|
||||
const t = useTranslations("home-page.month-card");
|
||||
@@ -32,13 +33,13 @@ export const MonthCard:FC<MonthCardProps> = ({ yearMonth, children, monthlyExpen
|
||||
|
||||
return(
|
||||
<div className={`collapse collapse-plus bg-base-200 my-1 sm:min-w-[25em] ${expanded ? "border-2 border-neutral" : ""}`} ref={elRef}>
|
||||
<input type="checkbox" name="my-accordion-3" checked={expanded} onChange={handleChange} />
|
||||
<input type="checkbox" name="my-accordion-3" checked={expanded} onChange={handleChange} />
|
||||
<div className={`collapse-title text-xl font-medium ${expanded ? "text-white" : ""}`}>
|
||||
{`${formatYearMonth(yearMonth)}`}
|
||||
{
|
||||
monthlyExpense>0 ?
|
||||
<p className="text-xs font-medium">
|
||||
{t("payed-total-label")} <strong>{ formatCurrency(monthlyExpense) }</strong>
|
||||
{t("payed-total-label")} <strong>{ formatCurrency(monthlyExpense, currency ?? "EUR") }</strong>
|
||||
</p> : null
|
||||
}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user