11import { useCallback } from 'react'
22import './upload-progress.css'
3+ import { CardHeader , CardWrapper } from '../ui/card.tsx'
34
45export interface UploadProgress {
56 step : 'creating-car' | 'uploading-car' | 'checking-readiness' | 'announcing-cids' | 'finalizing-transaction'
@@ -105,32 +106,6 @@ export default function UploadProgress({
105106 }
106107 }
107108
108- const getStepIcon = ( step : UploadProgress [ 'step' ] ) => {
109- switch ( step ) {
110- case 'creating-car' :
111- case 'checking-readiness' :
112- case 'uploading-car' :
113- return 'C'
114- case 'announcing-cids' :
115- return 'I'
116- case 'finalizing-transaction' :
117- return 'R'
118- }
119- }
120-
121- const getStatusBadge = ( status : UploadProgress [ 'status' ] ) => {
122- switch ( status ) {
123- case 'pending' :
124- return < span className = "status-badge pending" > Pending</ span >
125- case 'in-progress' :
126- return < span className = "status-badge in-progress" > In progress</ span >
127- case 'completed' :
128- return < span className = "status-badge completed" > Completed</ span >
129- case 'error' :
130- return < span className = "status-badge error" > Error</ span >
131- }
132- }
133-
134109 return (
135110 < div className = "upload-progress-container" >
136111 < div className = "upload-header" >
@@ -157,13 +132,9 @@ export default function UploadProgress({
157132 < div className = "progress-steps" >
158133 { /* Combined first stage: creating-car + checking-readiness + uploading-car */ }
159134 { progress . find ( ( p ) => p . step === 'creating-car' ) && (
160- < div className = { `progress-step ${ getCombinedFirstStageStatus ( ) } ` } key = "combined-upload" >
161- < div className = "step-icon" > { getStepIcon ( 'creating-car' ) } </ div >
135+ < CardWrapper >
162136 < div className = "step-content" >
163- < div className = "step-header" >
164- < span className = "step-label" > { getStepLabel ( 'creating-car' ) } </ span >
165- { getStatusBadge ( getCombinedFirstStageStatus ( ) ) }
166- </ div >
137+ < CardHeader status = { getCombinedFirstStageStatus ( ) } title = { getStepLabel ( 'creating-car' ) } />
167138 { getCombinedFirstStageStatus ( ) === 'in-progress' && (
168139 < div className = "progress-bar-container" >
169140 < div className = "progress-bar" >
@@ -173,7 +144,7 @@ export default function UploadProgress({
173144 </ div >
174145 ) }
175146 </ div >
176- </ div >
147+ </ CardWrapper >
177148 ) }
178149
179150 { /* Show remaining steps individually */ }
@@ -182,26 +153,24 @@ export default function UploadProgress({
182153 ( step ) =>
183154 step . step !== 'creating-car' && step . step !== 'checking-readiness' && step . step !== 'uploading-car'
184155 )
185- . map ( ( step ) => (
186- < div className = { `progress-step ${ step . status } ` } key = { step . step } >
187- < div className = "step-icon" > { getStepIcon ( step . step ) } </ div >
188- < div className = "step-content" >
189- < div className = "step-header" >
190- < span className = "step-label" > { getStepLabel ( step . step ) } </ span >
191- { getStatusBadge ( step . status ) }
192- </ div >
193- { step . status === 'in-progress' && (
194- < div className = "progress-bar-container" >
195- < div className = "progress-bar" >
196- < div className = "progress-fill" style = { { width : `${ step . progress } %` } } />
156+ . map ( ( step ) => {
157+ return (
158+ < CardWrapper key = { step . step } >
159+ < div className = "step-content" >
160+ < CardHeader status = { step . status } title = { getStepLabel ( step . step ) } />
161+ { step . status === 'in-progress' && (
162+ < div className = "progress-bar-container" >
163+ < div className = "progress-bar" >
164+ < div className = "progress-fill" style = { { width : `${ step . progress } %` } } />
165+ </ div >
166+ < span className = "progress-text" > { step . progress } %</ span >
197167 </ div >
198- < span className = "progress-text" > { step . progress } %</ span >
199- </ div >
200- ) }
201- { step . error && < div className = "error-message" > { step . error } </ div > }
202- </ div >
203- </ div >
204- ) ) }
168+ ) }
169+ { step . error && < div className = "error-message" > { step . error } </ div > }
170+ </ div >
171+ </ CardWrapper >
172+ )
173+ } ) }
205174 </ div >
206175 ) }
207176 </ div >
0 commit comments