chore(ui): supprime PdfUploader, composant mort

Aucun import ne le referencait : le televersement se fait depuis la zone
de depot de l'accueil et le bouton de l'en-tete.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-26 05:17:43 +02:00
parent 7a87958af7
commit 50508c98a8

View File

@@ -1,168 +0,0 @@
<template>
<div
class="border-2 border-dashed rounded-lg p-8 text-center transition-colors"
:class="{
'border-blue-500 bg-blue-500/10': isDragging,
'border-gray-700 hover:border-gray-600': !isDragging && !file,
'border-green-500 bg-green-500/10': file && !isLoading
}"
@dragenter.prevent="onDragEnter"
@dragleave.prevent="onDragLeave"
@dragover.prevent
@drop.prevent="onDrop"
>
<!-- Loading state -->
<div v-if="isLoading" class="flex flex-col items-center gap-4">
<svg class="animate-spin h-12 w-12 text-blue-400" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
</svg>
<p class="text-gray-400">Extraction en cours...</p>
</div>
<!-- File selected state -->
<div v-else-if="file" class="flex flex-col items-center gap-4">
<svg class="h-12 w-12 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
</svg>
<p class="text-gray-200 font-medium">{{ file.name }}</p>
<p class="text-sm text-gray-500">{{ formatFileSize(file.size) }}</p>
<div class="flex gap-3">
<button
@click="extractPdf"
class="btn btn-primary"
>
Extraire les donnees
</button>
<button
@click="clearFile"
class="btn btn-secondary"
>
Annuler
</button>
</div>
</div>
<!-- Default upload state -->
<div v-else class="flex flex-col items-center gap-4">
<svg class="h-12 w-12 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12" />
</svg>
<div>
<p class="text-gray-400 mb-1">Glissez un PDF ici ou</p>
<label class="cursor-pointer text-blue-400 hover:text-blue-300 font-medium">
cliquez pour selectionner
<input
type="file"
accept="application/pdf,.pdf"
class="hidden"
@change="onFileSelect"
/>
</label>
</div>
<p class="text-sm text-gray-500">Fichiers PDF uniquement</p>
</div>
<!-- Error message -->
<div v-if="error" class="mt-4 p-3 bg-red-500/10 border border-red-500/30 rounded-lg">
<p class="text-red-400 text-sm">{{ error }}</p>
</div>
</div>
</template>
<script setup>
import { ref } from 'vue'
const emit = defineEmits(['file-selected', 'extraction-complete', 'extraction-error'])
const file = ref(null)
const isDragging = ref(false)
const isLoading = ref(false)
const error = ref(null)
let dragCounter = 0
function onDragEnter() {
dragCounter++
isDragging.value = true
}
function onDragLeave() {
dragCounter--
if (dragCounter === 0) {
isDragging.value = false
}
}
function onDrop(e) {
dragCounter = 0
isDragging.value = false
const droppedFile = e.dataTransfer.files[0]
if (droppedFile) {
handleFile(droppedFile)
}
}
function onFileSelect(e) {
const selectedFile = e.target.files[0]
if (selectedFile) {
handleFile(selectedFile)
}
}
function handleFile(f) {
error.value = null
// Validate file type
if (!f.name.toLowerCase().endsWith('.pdf')) {
error.value = 'Veuillez selectionner un fichier PDF'
return
}
file.value = f
emit('file-selected', f)
}
function clearFile() {
file.value = null
error.value = null
emit('file-selected', null)
}
async function extractPdf() {
if (!file.value) return
isLoading.value = true
error.value = null
try {
const formData = new FormData()
formData.append('file', file.value)
const response = await fetch('/api/extract', {
method: 'POST',
body: formData
})
if (!response.ok) {
const errorData = await response.json()
throw new Error(errorData.detail || 'Erreur lors de l\'extraction')
}
const data = await response.json()
emit('extraction-complete', data)
} catch (err) {
error.value = err.message
emit('extraction-error', err.message)
} finally {
isLoading.value = false
}
}
function formatFileSize(bytes) {
if (bytes < 1024) return bytes + ' B'
if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB'
return (bytes / (1024 * 1024)).toFixed(1) + ' MB'
}
</script>