diff --git a/src/components/runners/RunnerDetail.svelte b/src/components/runners/RunnerDetail.svelte index 35ff0a48..60ae0d5d 100644 --- a/src/components/runners/RunnerDetail.svelte +++ b/src/components/runners/RunnerDetail.svelte @@ -69,6 +69,59 @@ }) .catch((err) => {}); } + function generateSponsoringContract(locale) { + const toast = Toastify({ + text: $_("generating-pdf"), + duration: -1, + }).showToast(); + fetch( + `https://dev.lauf-fuer-kaya.de/documents/contracts?locale=${locale}&download=true&key=${config.documentserver_key}`, + { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify([original_data_pdf]), + } + ) + .then((response) => { + if (response.status != "200") { + toast.hideToast(); + Toastify({ + text: $_("pdf-generation-failed"), + duration: 3500, + backgroundColor: + "linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)", + }).showToast(); + } else { + return response.blob(); + } + }) + .then((blob) => { + const url = window.URL.createObjectURL(blob); + let a = document.createElement("a"); + a.href = url; + a.download = + "Sponsoring_" + + original_data.firstname + + (original_data.middlename || "") + + original_data.lastname + + ".pdf"; + document.body.appendChild(a); + a.click(); + a.remove(); + toast.hideToast(); + Toastify({ + text: $_("pdf-successfully-generated"), + duration: 3500, + backgroundColor: "linear-gradient(to right, #00b09b, #96c93d)", + }).showToast(); + }) + .catch((err) => { + console.error(err); + }); + + } {#await runner_promise} @@ -135,82 +188,70 @@ {/if}