diff --git a/src/components/pdf_generation/GenerateRunnerCards.svelte b/src/components/pdf_generation/GenerateRunnerCards.svelte index bc0ee84b..f00e9405 100644 --- a/src/components/pdf_generation/GenerateRunnerCards.svelte +++ b/src/components/pdf_generation/GenerateRunnerCards.svelte @@ -150,7 +150,6 @@ let count = 0; const current_cards = await RunnerCardService.runnerCardControllerGetAll(); for await (const t of generate_teams) { - count++; const runners = await RunnerTeamService.runnerTeamControllerGetRunners( t.id ); @@ -216,18 +215,29 @@ duration: -1, }).showToast(); let count = 0; + const current_cards = await RunnerCardService.runnerCardControllerGetAll(); for await (const o of generate_orgs) { const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners( o.id ); + let cards = []; + for (let runner of runners) { + let card = current_cards.find((c) => c.runner?.id == runner.id); + if (!card) { + card = await RunnerCardService.runnerCardControllerPost({ + runner: runner.id, + }); + } + cards.push(card); + } fetch( - `${config.baseurl}/documents/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`, + `${config.baseurl}/documents/cards?locale=${locale}&download=true&key=${config.documentserver_key}`, { method: "POST", headers: { "Content-Type": "application/json", }, - body: JSON.stringify(runners), + body: JSON.stringify(cards), } ) .then((response) => { diff --git a/src/components/pdf_generation/GenerateSponsoringContracts.svelte b/src/components/pdf_generation/GenerateSponsoringContracts.svelte index 052e5a94..6508cab0 100644 --- a/src/components/pdf_generation/GenerateSponsoringContracts.svelte +++ b/src/components/pdf_generation/GenerateSponsoringContracts.svelte @@ -89,7 +89,6 @@ text: $_("generating-pdf"), duration: -1, }).showToast(); - let count = 0; for await (const o of generate_orgs) { const runners = await RunnerOrganizationService.runnerOrganizationControllerGetRunners( o.id