11'use client' ;
22
33import { useFileUpload } from '@/hooks/useFileUpload' ;
4- import { Upload , X , CheckCircle2 , AlertCircle , File , Image } from 'lucide-react' ;
4+ import {
5+ Upload ,
6+ X ,
7+ CheckCircle2 ,
8+ AlertCircle ,
9+ File ,
10+ Image ,
11+ } from 'lucide-react' ;
512import { useCallback , useState } from 'react' ;
613
714interface FileUploadProps {
@@ -35,8 +42,15 @@ export function FileUpload({
3542 title = 'Upload Documents' ,
3643 description = 'Drag and drop your files here or click to browse' ,
3744} : FileUploadProps ) {
38- const { files, isUploading, validationErrors, addFiles, removeFile, uploadAll, clearAll } =
39- useFileUpload ( ) ;
45+ const {
46+ files,
47+ isUploading,
48+ validationErrors,
49+ addFiles,
50+ removeFile,
51+ uploadAll,
52+ clearAll,
53+ } = useFileUpload ( ) ;
4054
4155 const [ isDragging , setIsDragging ] = useState ( false ) ;
4256
@@ -78,7 +92,11 @@ export function FileUpload({
7892 ) ;
7993
8094 const handleUpload = async ( ) => {
81- const fileIds = await uploadAll ( fileType ) ;
95+ await uploadAll ( fileType ) ;
96+ const fileIds = files
97+ . filter ( ( file ) => file . uploadStatus === 'success' && file . fileId )
98+ . map ( ( file ) => file . fileId as string ) ;
99+
82100 if ( onUploadComplete && fileIds . length > 0 ) {
83101 onUploadComplete ( fileIds ) ;
84102 }
@@ -97,8 +115,12 @@ export function FileUpload({
97115 < div className = "space-y-6 rounded-xl border border-gray-200 bg-white p-6 dark:border-gray-700 dark:bg-gray-900" >
98116 { /* Header */ }
99117 < div >
100- < h3 className = "text-lg font-semibold text-gray-900 dark:text-white" > { title } </ h3 >
101- < p className = "mt-1 text-sm text-gray-600 dark:text-gray-400" > { description } </ p >
118+ < h3 className = "text-lg font-semibold text-gray-900 dark:text-white" >
119+ { title }
120+ </ h3 >
121+ < p className = "mt-1 text-sm text-gray-600 dark:text-gray-400" >
122+ { description }
123+ </ p >
102124 </ div >
103125
104126 { /* Validation Errors */ }
@@ -109,7 +131,10 @@ export function FileUpload({
109131 < div className = "flex-1" >
110132 { validationErrors . map ( ( error , idx ) => (
111133 < p key = { idx } className = "text-sm text-red-700 dark:text-red-300" >
112- < span className = "font-semibold" > { error . field . toUpperCase ( ) } :</ span > { error . message }
134+ < span className = "font-semibold" >
135+ { error . field . toUpperCase ( ) } :
136+ </ span > { ' ' }
137+ { error . message }
113138 </ p >
114139 ) ) }
115140 </ div >
@@ -159,7 +184,9 @@ export function FileUpload({
159184 : 'text-gray-900 dark:text-gray-100'
160185 } `}
161186 >
162- { isDragging ? 'Drop your files here' : 'Click to upload or drag and drop' }
187+ { isDragging
188+ ? 'Drop your files here'
189+ : 'Click to upload or drag and drop' }
163190 </ p >
164191 < p className = "text-xs text-gray-600 dark:text-gray-400" >
165192 JPEG, PNG, or PDF up to 5MB
@@ -226,7 +253,8 @@ export function FileUpload({
226253
227254 { file . uploadStatus === 'error' && (
228255 < p className = "mt-1 flex items-center gap-1 text-xs font-medium text-red-600 dark:text-red-400" >
229- < AlertCircle className = "h-3 w-3" /> { file . error || 'Upload failed' }
256+ < AlertCircle className = "h-3 w-3" /> { ' ' }
257+ { file . error || 'Upload failed' }
230258 </ p >
231259 ) }
232260 </ div >
@@ -278,8 +306,8 @@ export function FileUpload({
278306 < CheckCircle2 className = "h-5 w-5 flex-shrink-0 text-green-600 dark:text-green-400" />
279307 < div >
280308 < p className = "text-sm font-medium text-green-800 dark:text-green-300" >
281- { successFiles . length } file{ successFiles . length !== 1 ? 's' : '' } uploaded
282- successfully!
309+ { successFiles . length } file{ successFiles . length !== 1 ? 's' : '' } { ' ' }
310+ uploaded successfully!
283311 </ p >
284312 </ div >
285313 </ div >
@@ -288,7 +316,9 @@ export function FileUpload({
288316
289317 { /* Constraints */ }
290318 < div className = "space-y-2 rounded-lg bg-gray-50 p-3 dark:bg-gray-800/50" >
291- < p className = "text-xs font-semibold text-gray-700 dark:text-gray-300" > Constraints:</ p >
319+ < p className = "text-xs font-semibold text-gray-700 dark:text-gray-300" >
320+ Constraints:
321+ </ p >
292322 < ul className = "space-y-1 text-xs text-gray-600 dark:text-gray-400" >
293323 < li > • Maximum file size: 5MB</ li >
294324 < li > • Allowed formats: JPEG, PNG, PDF</ li >
0 commit comments