parent
7b685d6cad
commit
2472640755
@ -24,7 +24,7 @@
|
|||||||
if (generate_orgs.length > 0) {
|
if (generate_orgs.length > 0) {
|
||||||
generateOrgCards(locale);
|
generateOrgCards(locale);
|
||||||
} else if (generate_teams.length > 0) {
|
} else if (generate_teams.length > 0) {
|
||||||
generateTeamCards(locale);
|
generateTeamCertificates(locale);
|
||||||
} else {
|
} else {
|
||||||
generateRunnerCertificates(locale);
|
generateRunnerCertificates(locale);
|
||||||
}
|
}
|
||||||
@ -83,72 +83,68 @@
|
|||||||
.catch((err) => {});
|
.catch((err) => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
// async function generateTeamCards(locale) {
|
async function generateTeamCertificates(locale) {
|
||||||
// const toast = Toastify({
|
const toast = Toastify({
|
||||||
// text: $_("generating-pdfs"),
|
text: $_("generating-pdfs"),
|
||||||
// duration: -1,
|
duration: -1,
|
||||||
// }).showToast();
|
}).showToast();
|
||||||
// let count = 0;
|
let count = 0;
|
||||||
// const current_cards = await RunnerCardService.runnerCardControllerGetAll();
|
const current_cards = await RunnerCardService.runnerCardControllerGetAll();
|
||||||
// for (const t of generate_teams) {
|
for (const t of generate_teams) {
|
||||||
// const runners = await RunnerTeamService.runnerTeamControllerGetRunners(
|
const runners = await RunnerTeamService.runnerTeamControllerGetRunners(
|
||||||
// t.id
|
t.id
|
||||||
// );
|
);
|
||||||
// let cards = [];
|
const current_donations = await DonationService.donationControllerGetAll();
|
||||||
// for (let runner of runners) {
|
let certificateRunners = [];
|
||||||
// let card = current_cards.find((c) => c.runner?.id == runner.id);
|
for (let runner of generate_runners) {
|
||||||
// if (!card) {
|
runner.distanceDonations = current_donations.find((d) => d.runner?.id == runner.id) || [];
|
||||||
// card = await RunnerCardService.runnerCardControllerPost({
|
certificateRunners.push(runner);
|
||||||
// runner: runner.id,
|
}
|
||||||
// });
|
fetch(
|
||||||
// }
|
`${config.baseurl}/documents/cards?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
||||||
// cards.push(card);
|
{
|
||||||
// }
|
method: "POST",
|
||||||
// fetch(
|
headers: {
|
||||||
// `${config.baseurl}/documents/cards?locale=${locale}&download=true&key=${config.documentserver_key}`,
|
"Content-Type": "application/json",
|
||||||
// {
|
},
|
||||||
// method: "POST",
|
body: JSON.stringify(certificateRunners),
|
||||||
// headers: {
|
}
|
||||||
// "Content-Type": "application/json",
|
)
|
||||||
// },
|
.then((response) => {
|
||||||
// body: JSON.stringify(cards),
|
if (response.status != "200") {
|
||||||
// }
|
toast.hideToast();
|
||||||
// )
|
Toastify({
|
||||||
// .then((response) => {
|
text: $_("pdf-generation-failed"),
|
||||||
// if (response.status != "200") {
|
duration: 3500,
|
||||||
// toast.hideToast();
|
backgroundColor:
|
||||||
// Toastify({
|
"linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
||||||
// text: $_("pdf-generation-failed"),
|
}).showToast();
|
||||||
// duration: 3500,
|
} else {
|
||||||
// backgroundColor:
|
return response.blob();
|
||||||
// "linear-gradient(90deg, hsla(281, 37%, 45%, 1) 0%, hsla(1, 62%, 48%, 1) 100%)",
|
}
|
||||||
// }).showToast();
|
})
|
||||||
// } else {
|
.then((blob) => {
|
||||||
// return response.blob();
|
count++;
|
||||||
// }
|
const url = window.URL.createObjectURL(blob);
|
||||||
// })
|
let a = document.createElement("a");
|
||||||
// .then((blob) => {
|
a.href = url;
|
||||||
// count++;
|
a.download = "Sponsorings_" + t.name + ".pdf";
|
||||||
// const url = window.URL.createObjectURL(blob);
|
document.body.appendChild(a);
|
||||||
// let a = document.createElement("a");
|
a.click();
|
||||||
// a.href = url;
|
a.remove();
|
||||||
// a.download = "Sponsorings_" + t.name + ".pdf";
|
if (count === generate_teams.length) {
|
||||||
// document.body.appendChild(a);
|
toast.hideToast();
|
||||||
// a.click();
|
Toastify({
|
||||||
// a.remove();
|
text: $_("pdfs-successfully-generated"),
|
||||||
// if (count === generate_teams.length) {
|
duration: 3500,
|
||||||
// toast.hideToast();
|
backgroundColor:
|
||||||
// Toastify({
|
"linear-gradient(to right, #00b09b, #96c93d)",
|
||||||
// text: $_("pdfs-successfully-generated"),
|
}).showToast();
|
||||||
// duration: 3500,
|
}
|
||||||
// backgroundColor:
|
})
|
||||||
// "linear-gradient(to right, #00b09b, #96c93d)",
|
.catch((err) => {});
|
||||||
// }).showToast();
|
}
|
||||||
// }
|
}
|
||||||
// })
|
|
||||||
// .catch((err) => {});
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// async function generateOrgCards(locale) {
|
// async function generateOrgCards(locale) {
|
||||||
// const toast = Toastify({
|
// const toast = Toastify({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user