mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 10:44:23 +00:00
fix(trips): default a new trip to the user's currency setting (#1790)
The new-trip forms hard-coded EUR and ignored settings.default_currency, so creating a trip always opened on EUR even with USD set in Settings > General > Currency. Read default_currency (falling back to EUR when unset) in both the desktop TripFormModal and the mobile MNewTripSheet; edit mode still pre-fills the trip's own currency. Fixes #1784
This commit is contained in:
committed by
GitHub
parent
c08530f928
commit
dd138e5293
@@ -5,6 +5,7 @@ import MNewTripSheet from '../../../../src/mobile/screens/dashboard/MNewTripShee
|
||||
import { tripsApi } from '../../../../src/api/client';
|
||||
import { useAuthStore } from '../../../../src/store/authStore';
|
||||
import { usePermissionsStore } from '../../../../src/store/permissionsStore';
|
||||
import { useSettingsStore } from '../../../../src/store/settingsStore';
|
||||
import { buildUser } from '../../../helpers/factories';
|
||||
import type { DashboardTrip } from '../../../../src/pages/dashboard/dashboardModel';
|
||||
import type { Trip, TripCreateRequest } from '@trek/shared';
|
||||
@@ -75,6 +76,7 @@ beforeEach(() => {
|
||||
afterEach(() => {
|
||||
URL.createObjectURL = origCreateObjectURL;
|
||||
delete window.__addToast;
|
||||
useSettingsStore.setState(s => ({ settings: { ...s.settings, default_currency: '' } }));
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
@@ -88,6 +90,13 @@ describe('MNewTripSheet', () => {
|
||||
expect(screen.getByText('Add cover image')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('FE-MOB-NTSH-001b: create mode defaults the currency to the user\'s default_currency (#1784)', () => {
|
||||
useSettingsStore.setState(s => ({ settings: { ...s.settings, default_currency: 'USD' } }));
|
||||
render(<MNewTripSheet open trip={null} onClose={() => {}} onSave={() => {}} />);
|
||||
|
||||
expect(screen.getByLabelText('currency')).toHaveValue('USD');
|
||||
});
|
||||
|
||||
it('FE-MOB-NTSH-002: edit mode preloads the trip and hides the no-date hint', () => {
|
||||
render(<MNewTripSheet open trip={buildDashTrip()} onClose={() => {}} onSave={() => {}} />);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user