Checkpoint: Harmonisation des boutons d'action (Prévisualiser, Envoyer, Charger) en bleu, ajout d'un indicateur de progression pour l'upload des PDF, et correction de l'erreur logsRappels (colonne type déjà présente)
This commit is contained in:
@@ -25,6 +25,7 @@ function UploadAttestationDialog({
|
||||
onSuccess: () => void;
|
||||
}) {
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const [uploadProgress, setUploadProgress] = useState(0);
|
||||
const [fileData, setFileData] = useState<{
|
||||
nomFichier: string;
|
||||
urlFichier: string;
|
||||
@@ -85,15 +86,27 @@ function UploadAttestationDialog({
|
||||
}
|
||||
|
||||
setUploading(true);
|
||||
setUploadProgress(0);
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
|
||||
// Simuler la progression de l'upload
|
||||
const progressInterval = setInterval(() => {
|
||||
setUploadProgress(prev => {
|
||||
if (prev >= 90) return prev;
|
||||
return prev + 10;
|
||||
});
|
||||
}, 200);
|
||||
|
||||
const response = await fetch('/api/upload-file', {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
});
|
||||
|
||||
clearInterval(progressInterval);
|
||||
setUploadProgress(100);
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error('Erreur lors de l\'upload');
|
||||
}
|
||||
@@ -109,13 +122,28 @@ function UploadAttestationDialog({
|
||||
toast.success('Fichier uploadé avec succès');
|
||||
} catch (error) {
|
||||
toast.error('Erreur lors de l\'upload du fichier');
|
||||
setUploadProgress(0);
|
||||
} finally {
|
||||
setUploading(false);
|
||||
}
|
||||
}}
|
||||
className="block w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-md file:border-0 file:text-sm file:font-semibold file:bg-primary file:text-primary-foreground hover:file:bg-primary/90"
|
||||
/>
|
||||
{fileData && (
|
||||
{uploading && (
|
||||
<div className="mt-4">
|
||||
<div className="flex justify-between text-sm text-muted-foreground mb-1">
|
||||
<span>Upload en cours...</span>
|
||||
<span>{uploadProgress}%</span>
|
||||
</div>
|
||||
<div className="w-full bg-gray-200 rounded-full h-2.5">
|
||||
<div
|
||||
className="bg-blue-600 h-2.5 rounded-full transition-all duration-300"
|
||||
style={{ width: `${uploadProgress}%` }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{fileData && !uploading && (
|
||||
<p className="text-sm text-muted-foreground mt-2">
|
||||
Fichier sélectionné : {fileData.nomFichier}
|
||||
</p>
|
||||
@@ -484,15 +512,15 @@ export default function AdminGestionAttestations() {
|
||||
<>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="bg-blue-600 hover:bg-blue-700 text-white"
|
||||
onClick={() => handlePreview(documentUrl!)}
|
||||
>
|
||||
<Eye className="h-4 w-4 text-blue-600" />
|
||||
<Eye className="h-4 w-4" />
|
||||
</Button>
|
||||
{modeEnvoi === "manuel" && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
className="bg-blue-600 hover:bg-blue-700 text-white disabled:opacity-50 disabled:cursor-not-allowed"
|
||||
onClick={() => handleSendAttestation(item)}
|
||||
disabled={sendAttestationMutation.isPending}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user