refactor(cards): Switched over to new document-server api
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Nicolai Ort 2024-12-17 17:32:33 +01:00
parent 878d9714cb
commit 65ce02e777
Signed by: niggl
GPG Key ID: 13AFA55AF62F269F
2 changed files with 10 additions and 24 deletions

View File

@ -5,8 +5,11 @@
import { RunnerCardService } from "@odit/lfk-client-js";
import { createEventDispatcher } from "svelte";
import toast from "svelte-french-toast";
import DocumentServer from "../pdf_generation/DocumentServer";
export let bulk_modal_open;
const dispatch = createEventDispatcher();
const documentServer = new DocumentServer(config.baseurl_documentserver,config.documentserver_key);
$: card_count = 0;
$: is_card_count_valid = card_count > 0;
@ -60,24 +63,7 @@
toast.success($_("created-blanco-cards"));
toast.loading($_("generating-pdf"));
dispatch("created", { cards: result });
fetch(
`${config.baseurl_documentserver}/cards?&download=true&key=${config.documentserver_key}`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(result),
}
)
.then((response) => {
if (response.status != "200") {
toast.dismiss();
toast.error($_("pdf-generation-failed"));
} else {
return response.blob();
}
})
documentServer.generateCards(result, "de")
.then((blob) => {
const url = window.URL.createObjectURL(blob);
let a = document.createElement("a");

View File

@ -16,13 +16,13 @@ class DocumentServer {
enabled: cards[i].enabled,
code: cards[i].code,
runner: {
id: cards[i].runner.id,
first_name: cards[i].runner.firstname,
middle_name: cards[i].runner.middlename,
last_name: cards[i].runner.lastname,
id: cards[i]?.runner?.id,
first_name: cards[i]?.runner?.firstname,
middle_name: cards[i]?.runner?.middlename,
last_name: cards[i]?.runner?.lastname,
group: {
id: cards[i].runner.group.id,
name: cards[i].runner.group.name,
id: cards[i]?.runner?.group.id,
name: cards[i]?.runner?.group.name,
}
}
}