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

This commit is contained in:
2024-12-17 17:19:20 +01:00
parent e23098410c
commit f99b7f4bb8
2 changed files with 62 additions and 123 deletions

View File

@@ -7,7 +7,7 @@ class DocumentServer {
this.apiKey = apiKey;
}
async generateCards(cards: any[], locale: string, filename: string) {
async generateCards(cards: any[], locale: string) {
const generateCards = new Array<any>();
for (let i = 0; i < cards.length; i++) {
@@ -44,6 +44,40 @@ class DocumentServer {
const blob = await response.blob();
return blob;
}
async generateContracts(runners: any[], locale: string) {
const generateRunners = new Array<any>();
for (let i = 0; i < runners.length; i++) {
console.log(runners[i])
const card = {
id: runners[i].id,
first_name: runners[i].firstname,
middle_name: runners[i].middlename,
last_name: runners[i].lastname,
group: {
id: runners[i].group.id,
name: runners[i].group.name,
}
}
generateRunners.push(card)
}
const response = await fetch(`${this.baseUrl}/v1/pdfs/contracts?key=${this.apiKey}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
locale,
runners: generateRunners,
}),
});
const blob = await response.blob();
return blob;
}
}
export default DocumentServer;