mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-27 15:17:30 +00:00
fix(planner): an imported booking with source files saves and opens its expense without file support
Saving an imported booking in the desktop booking dialog when the dialog had no upload handler but the import carried source files rejected the save: the files were handed to the missing handler, the promise rejected with nothing to catch it, and the expense editor the user asked for never opened. The transport dialog already skipped the upload in that case, the booking dialog did not. The shared uploadBookingFiles helper now takes an optional handler and does nothing without one, so every form gets the same guard. Red test: FE-PLANNER-RESMODAL-106 in client/src/components/Planner/ReservationModal.test.tsx failed with "expected spy to be called with arguments" for onOpenExpense, plus the unhandled rejection "TypeError: upload is not a function". The helper case is covered by FE-PLANNER-BOOKINGFORM-008. No existing assertions changed.
This commit is contained in:
@@ -34,13 +34,16 @@ export function travelersChanged(reservation: Pick<Reservation, 'travelers'> | n
|
||||
* the other, each described with the booking's title. Callers run it after both a
|
||||
* create and an edit: the form only holds files the user just picked, so nothing is
|
||||
* uploaded twice, and skipping the edit dropped them without a word (#2534).
|
||||
* Without an upload handler (a dialog opened with no file support) there is
|
||||
* nowhere to send them, so nothing is uploaded and the save carries on.
|
||||
*/
|
||||
export async function uploadBookingFiles(
|
||||
upload: (fd: FormData) => Promise<unknown>,
|
||||
upload: ((fd: FormData) => Promise<unknown>) | undefined,
|
||||
savedId: number,
|
||||
files: File[],
|
||||
description: string
|
||||
): Promise<void> {
|
||||
if (!upload) return;
|
||||
for (const file of files) {
|
||||
const fd = new FormData();
|
||||
fd.append('file', file);
|
||||
|
||||
Reference in New Issue
Block a user