diff --git a/resources/js/components/accounts/account-balance-chart.tsx b/resources/js/components/accounts/account-balance-chart.tsx index 420163aa..9021cd71 100644 --- a/resources/js/components/accounts/account-balance-chart.tsx +++ b/resources/js/components/accounts/account-balance-chart.tsx @@ -359,8 +359,7 @@ export function AccountBalanceChart({ const isLoan = account.type === 'loan'; const isRealEstate = isRealEstateAccount(account); const [granularity, setGranularity] = useState('monthly'); - const [currencyMode, setCurrencyMode] = - useState('account'); + const [currencyMode, setCurrencyMode] = useState('user'); const [balanceData, setBalanceData] = useState( null, ); diff --git a/resources/js/components/charts/chart-currency-toggle.test.tsx b/resources/js/components/charts/chart-currency-toggle.test.tsx new file mode 100644 index 00000000..8c63305d --- /dev/null +++ b/resources/js/components/charts/chart-currency-toggle.test.tsx @@ -0,0 +1,24 @@ +import { render, screen } from '@testing-library/react'; +import { describe, expect, it, vi } from 'vitest'; +import { ChartCurrencyToggle } from './chart-currency-toggle'; + +describe('ChartCurrencyToggle', () => { + it('renders user currency before account currency', () => { + render( + , + ); + + const buttons = screen.getAllByRole('radio'); + + expect(buttons).toHaveLength(2); + expect(buttons[0]).toHaveTextContent('USD'); + expect(buttons[1]).toHaveTextContent('EUR'); + expect(buttons[0]).toHaveAttribute('data-state', 'on'); + }); +}); diff --git a/resources/js/components/charts/chart-currency-toggle.tsx b/resources/js/components/charts/chart-currency-toggle.tsx index 882f94b2..fe5d21e9 100644 --- a/resources/js/components/charts/chart-currency-toggle.tsx +++ b/resources/js/components/charts/chart-currency-toggle.tsx @@ -31,13 +31,6 @@ export function ChartCurrencyToggle({ label: string; tooltip: string; }> = [ - { - mode: 'account', - label: accountCurrencyCode, - tooltip: __('Show in account currency (:currency)', { - currency: accountCurrencyCode, - }), - }, { mode: 'user', label: userCurrencyCode, @@ -45,6 +38,13 @@ export function ChartCurrencyToggle({ currency: userCurrencyCode, }), }, + { + mode: 'account', + label: accountCurrencyCode, + tooltip: __('Show in account currency (:currency)', { + currency: accountCurrencyCode, + }), + }, ]; return (