diff --git a/client/src/components/Planner/BookingNotesFilesCosts.test.tsx b/client/src/components/Planner/BookingNotesFilesCosts.test.tsx index 37e88f3f5..741631fb4 100644 --- a/client/src/components/Planner/BookingNotesFilesCosts.test.tsx +++ b/client/src/components/Planner/BookingNotesFilesCosts.test.tsx @@ -28,10 +28,8 @@ function setup(overrides: Partial = {}) { linkAndFiles.mockClear(); costs.mockClear(); const props: Props = { - notes: 'Gate B', - onNotesChange: vi.fn(), - url: 'https://example.com', - onUrlChange: vi.fn(), + form: { notes: 'Gate B', url: 'https://example.com' }, + set: vi.fn(), reservationId: 9, tripFiles: [], pendingFiles: [], @@ -61,7 +59,7 @@ describe('BookingNotesFilesCosts', () => { const area = screen.getByPlaceholderText('Additional notes...'); expect(area).toHaveValue('Gate B'); fireEvent.change(area, { target: { value: 'Gate C' } }); - expect(props.onNotesChange).toHaveBeenCalledWith('Gate C'); + expect(props.set).toHaveBeenCalledWith('notes', 'Gate C'); }); it('FE-PLANNER-NOTESFILESCOSTS-002: hands the link, the files and the costs their parts of the booking', () => { @@ -70,7 +68,6 @@ describe('BookingNotesFilesCosts', () => { expect(linkAndFiles).toHaveBeenCalledWith( expect.objectContaining({ url: 'https://example.com', - onUrlChange: props.onUrlChange, reservationId: 9, canAttach: true, uploading: false, @@ -80,6 +77,8 @@ describe('BookingNotesFilesCosts', () => { onDetached: props.attach.detachFile, }) ); + linkAndFiles.mock.calls[0][0].onUrlChange('https://example.org'); + expect(props.set).toHaveBeenCalledWith('url', 'https://example.org'); expect(costs).toHaveBeenCalledWith( expect.objectContaining({ reservationId: 9, diff --git a/client/src/components/Planner/BookingNotesFilesCosts.tsx b/client/src/components/Planner/BookingNotesFilesCosts.tsx index fe7584f9a..2d45b08ea 100644 --- a/client/src/components/Planner/BookingNotesFilesCosts.tsx +++ b/client/src/components/Planner/BookingNotesFilesCosts.tsx @@ -13,10 +13,8 @@ import type { useBookingFileAttach } from './useBookingFileAttach'; * files row, and the costs linked to this booking when the budget addon is on. */ export function BookingNotesFilesCosts({ - notes, - onNotesChange, - url, - onUrlChange, + form, + set, reservationId, tripFiles, pendingFiles, @@ -28,10 +26,8 @@ export function BookingNotesFilesCosts({ pendingExpense, expense, }: { - notes: string; - onNotesChange: (notes: string) => void; - url: string; - onUrlChange: (url: string) => void; + form: { notes: string; url: string }; + set: (field: 'notes' | 'url', value: string) => void; /** The saved booking; unset while it is being created. */ reservationId: number | undefined; tripFiles: TripFile[]; @@ -50,8 +46,8 @@ export function BookingNotesFilesCosts({ <>