Bedarfsausweis

This commit is contained in:
Moritz Utcke
2025-04-23 10:49:58 -03:00
parent 076c49c054
commit f958eb07bf
2 changed files with 43 additions and 63 deletions

View File

@@ -160,35 +160,10 @@
if (ausweisart === Enums.Ausweisart.BedarfsausweisWohnen) {
const results: {data: string, name: string, type: "Sonstiges" | "Ausweis"}[] = []
for (const file of bedarfsausweisAdditionalInput.files || []) {
const reader = new FileReader();
let i = 0
const dateien = [...(bedarfsausweisAdditionalInput.files || []), ...(bedarfsausweisFileInput.files || [])];
reader.onload = (ev) => {
const result = reader.result;
if (!result) {
addNotification({
message: `Die Datei ${file.name} konnte nicht verarbeitet werden.`,
timeout: 3000,
type: "error",
dismissable: true
})
}
results.push({
data: result as string,
name: file.name,
type: "Sonstiges"
})
}
reader.readAsDataURL(file)
}
// Jetzt holen wir uns noch den Ausweis
const files = bedarfsausweisFileInput.files
const reader = new FileReader()
if (files === null || (files.length === 0)) {
if (dateien.length === 0) {
addNotification({
message: "Bitte laden sie vor dem Ausstellen einen Ausweis hoch.",
timeout: 3000,
@@ -198,50 +173,57 @@
return;
}
reader.onload = (ev) => {
const result = reader.result;
for (const datei of dateien) {
const reader = new FileReader();
reader.onload = async (ev) => {
const result = reader.result;
if (!result) {
addNotification({
message: `Die Datei ${files[0].name} konnte nicht verarbeitet werden.`,
message: `Die Datei ${datei.name} konnte nicht verarbeitet werden.`,
timeout: 3000,
type: "error",
dismissable: true
})
}
results.push({
results.push({
data: result as string,
name: files[0].name,
type: "Ausweis"
name: datei.name,
type: i == dateien.length - 1 ? "Ausweis" : "Sonstiges"
})
}
i++
reader.readAsDataURL(files[0])
try {
await api.admin["bedarfsausweis-ausstellen"].POST.fetch({
id_ausweis: ausweis.id,
post,
files: results
}, {
headers: {
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
if (i === dateien.length) {
try {
await api.admin["bedarfsausweis-ausstellen"].POST.fetch({
id_ausweis: ausweis.id,
post,
files: results
}, {
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}`
}
})
updateNotification(notification, {
message: "Ausweis ausgestellt.",
subtext: "Der Ausweis wurde erfolgreich ausgestellt.",
timeout: 3000,
type: "success",
})
} catch(e) {
updateNotification(notification, {
message: "Das hat nicht geklappt.",
subtext: e as string,
timeout: 3000,
type: "error",
})
}
}
})
updateNotification(notification, {
message: "Ausweis ausgestellt.",
subtext: "Der Ausweis wurde erfolgreich ausgestellt.",
timeout: 3000,
type: "success",
})
} catch(e) {
updateNotification(notification, {
message: "Das hat nicht geklappt.",
subtext: e as string,
timeout: 3000,
type: "error",
})
}
reader.readAsDataURL(datei)
}
} else {
try {

View File

@@ -131,7 +131,6 @@ export const POST = defineApiRoute({
}
// Hier müssen wir warten, damit wir sichergehen können, dass die Rechnung bei LexOffice existiert.
setTimeout(async () => {
const [pdfRechnung, pdfRechnungError] = await tryCatch(
getLexOfficeRechnung(rechnung)
);
@@ -356,6 +355,5 @@ export const POST = defineApiRoute({
},
});
}
}, 3000);
},
});