feat: enhance receipt import to support PDF files with updated UI and backend processing
This commit is contained in:
@@ -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>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user