diff --git a/src/Geopilot.Frontend/src/pages/delivery/deliverySubmit.tsx b/src/Geopilot.Frontend/src/pages/delivery/deliverySubmit.tsx index ae658bfc..0e3e5f30 100644 --- a/src/Geopilot.Frontend/src/pages/delivery/deliverySubmit.tsx +++ b/src/Geopilot.Frontend/src/pages/delivery/deliverySubmit.tsx @@ -42,6 +42,17 @@ export const DeliverySubmit = () => { submitDelivery(data as DeliverySubmitData); }; + const handleMandateChange = (mandateId: number) => { + formMethods.setValue("predecessor", undefined); + if (mandateId) { + fetchApi("/api/v1/delivery?" + new URLSearchParams({ mandateId: mandateId.toString() })).then( + setPreviousDeliveries, + ); + } else { + setPreviousDeliveries([]); + } + }; + return authEnabled && user ? (
@@ -55,16 +66,7 @@ export const DeliverySubmit = () => { values={mandates ?.sort((a, b) => a.name.localeCompare(b.name)) .map(mandate => ({ key: mandate.id, name: mandate.name }))} - onUpdate={mandateId => { - formMethods.setValue("predecessor", undefined); - if (mandateId) { - fetchApi( - "/api/v1/delivery?" + new URLSearchParams({ mandateId: mandateId.toString() }), - ).then(setPreviousDeliveries); - } else { - setPreviousDeliveries([]); - } - }} + onUpdate={handleMandateChange} />