| 1 | import { IndexingProgressUpdate } from "core"; |
| 2 | import { getProgressPercentage } from "./IndexingProgress"; |
| 3 | |
| 4 | export interface IndexingProgressBarProps { |
| 5 | update: IndexingProgressUpdate; |
| 6 | } |
| 7 | |
| 8 | function IndexingProgressBar({ update }: IndexingProgressBarProps) { |
| 9 | // Show 100% red progress bar if indexing failed |
| 10 | const progressPercentage = |
| 11 | update.status === "failed" ? 100 : getProgressPercentage(update.progress); |
| 12 | |
| 13 | return ( |
| 14 | <div className="my-2 h-1.5 w-full rounded-md border border-solid border-gray-400"> |
| 15 | <div |
| 16 | className={`h-full rounded-lg transition-all duration-200 ease-in-out ${ |
| 17 | update.status === "failed" ? "bg-red-600" : "bg-stone-500" |
| 18 | }`} |
| 19 | style={{ |
| 20 | width: `${progressPercentage}%`, |
| 21 | }} |
| 22 | /> |
| 23 | </div> |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | export default IndexingProgressBar; |