This commit is contained in:
seb
2026-10-16 14:17:22 +02:00
parent 764d6f850a
commit a592cc30f6
8 changed files with 477 additions and 64 deletions

View File

@@ -659,20 +659,17 @@ class LieferungNeuPage extends PureComponent {
const existingTxt = this.state.attachments?.find(
(a) => a.parentPdfId === attachment.id || a.name === txtName,
);
let targetTxt = existingTxt;
if (existingTxt) {
const updated = {
this.automat.actions.updateAttachment({
id: existingTxt.id,
file: txtFile,
size: txtFile.size,
text,
thumbnail: txtThumbnail || existingTxt.thumbnail,
isDirty: true,
};
this.automat.actions.updateAttachment(updated);
targetTxt = { ...existingTxt, ...updated };
});
} else {
targetTxt = {
this.automat.actions.addAttachment({
id: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
file: txtFile,
name: txtFile.name,
@@ -682,14 +679,10 @@ class LieferungNeuPage extends PureComponent {
text,
parentPdfId: attachment.id,
uploadedAt: new Date().toISOString(),
};
this.automat.actions.addAttachment(targetTxt);
});
}
this.handleAttachmentClick(targetTxt);
enqueueSnackbar('Text aus PDF extrahiert und geöffnet', { variant: 'success' });
} catch (txtErr) {
console.error('Fehler beim Aktualisieren der Textdatei:', txtErr);
enqueueSnackbar('Fehler beim Extrahieren von Text aus der PDF', { variant: 'error' });
}
}
}
@@ -715,17 +708,12 @@ class LieferungNeuPage extends PureComponent {
}
const trimmed = (text || '').trim();
if (!trimmed) {
enqueueSnackbar('Datei enthält keinen Text zum Erwähnen im Chat.', { variant: 'warning' });
return;
}
if (!trimmed) return;
const size = attachment.size || new Blob([trimmed]).size;
chatAutomat.actions.insertExtractionSnippet({
text: trimmed,
size,
label: 'parsed invoice',
});
enqueueSnackbar('Text im Chat erwähnt', { variant: 'success' });
}
handlePdfDelete(attachment) {