feat: enhance receipt import to support PDF files with updated UI and backend processing

This commit is contained in:
Nils-Johan Gynther
2026-04-16 20:22:27 +02:00
parent a12abe0402
commit b8744f625b
3 changed files with 95 additions and 16 deletions
+14 -4
View File
@@ -29,7 +29,11 @@ export default function ReceiptImportClient() {
const file = e.target.files?.[0];
if (!file) return;
setSelectedFile(file);
setPreview(URL.createObjectURL(file));
if (file.type === 'application/pdf') {
setPreview('pdf');
} else {
setPreview(URL.createObjectURL(file));
}
setRows([]);
setError(null);
setSavedCount(null);
@@ -119,12 +123,18 @@ export default function ReceiptImportClient() {
<input
ref={fileRef}
type="file"
accept="image/*"
accept="image/*,application/pdf"
capture="environment"
onChange={handleFileChange}
style={{ display: 'none' }}
/>
{preview ? (
{preview === 'pdf' ? (
<div style={{ padding: '1rem', color: '#333' }}>
<div style={{ fontSize: '2.5rem', marginBottom: '0.5rem' }}>📄</div>
<div style={{ fontWeight: 600 }}>{selectedFile?.name}</div>
<div style={{ fontSize: '0.85rem', color: '#888', marginTop: '0.25rem' }}>PDF-kvitto valt</div>
</div>
) : preview ? (
// eslint-disable-next-line @next/next/no-img-element
<img
src={preview}
@@ -136,7 +146,7 @@ export default function ReceiptImportClient() {
<div style={{ fontSize: '2.5rem', marginBottom: '0.5rem' }}>📷</div>
<div style={{ fontWeight: 600 }}>Fotografera eller välj kvitto</div>
<div style={{ fontSize: '0.85rem', marginTop: '0.25rem' }}>
Klicka för att välja bild (JPEG, PNG, WebP)
Klicka för att välja bild (JPEG, PNG, WebP) eller PDF
</div>
</div>
)}