diff --git a/src/components/donations/AddDonationModal.svelte b/src/components/donations/AddDonationModal.svelte index 0195d14a..b5f4156e 100644 --- a/src/components/donations/AddDonationModal.svelte +++ b/src/components/donations/AddDonationModal.svelte @@ -8,7 +8,7 @@ RunnerService, } from "@odit/lfk-client-js"; import Select from "svelte-select"; - import { createEventDispatcher } from "svelte"; + import { createEventDispatcher, onMount } from "svelte"; import toast from "svelte-french-toast"; export let modal_open; const dispatch = createEventDispatcher(); @@ -23,16 +23,6 @@ $: runners = []; $: is_fixed = false; $: is_paid = false; - DonorService.donorControllerGetAll().then((val) => { - donors = val.map((r) => { - return { label: getDonorLabel(r), value: r }; - }); - }); - RunnerService.runnerControllerGetAll().then((val) => { - runners = val.map((r) => { - return { label: getDonorLabel(r), value: r }; - }); - }); $: amount_input = 0; $: processed_last_submit = true; $: is_amount_valid = amount_input > 0; @@ -89,7 +79,7 @@ amountPerDistance: amount_cent, }; DonationService.donationControllerPostDistance(postdata) - .then((result) => { + .then((result) => { donor = donors[0].id || 0; runner = runners[0].id || 0; amount_input = 0; @@ -108,6 +98,19 @@ } } } + + onMount(() => { + DonorService.donorControllerGetAll().then((val) => { + donors = val.map((r) => { + return { label: getDonorLabel(r), value: r }; + }); + }); + RunnerService.runnerControllerGetAll().then((val) => { + runners = val.map((r) => { + return { label: getDonorLabel(r), value: r }; + }); + }); + }); {#if modal_open}