Extract BulkImportToasts component from App.tsx
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
49
apps/web/src/components/bulk-import-toasts.tsx
Normal file
49
apps/web/src/components/bulk-import-toasts.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
import type { BulkImportState } from "../hooks/use-bulk-import.js";
|
||||
import { Toast } from "./toast.js";
|
||||
|
||||
interface BulkImportToastsProps {
|
||||
state: BulkImportState;
|
||||
visible: boolean;
|
||||
onReset: () => void;
|
||||
}
|
||||
|
||||
export function BulkImportToasts({
|
||||
state,
|
||||
visible,
|
||||
onReset,
|
||||
}: BulkImportToastsProps) {
|
||||
if (!visible) return null;
|
||||
|
||||
if (state.status === "loading") {
|
||||
return (
|
||||
<Toast
|
||||
message={`Loading sources... ${state.completed + state.failed}/${state.total}`}
|
||||
progress={
|
||||
state.total > 0 ? (state.completed + state.failed) / state.total : 0
|
||||
}
|
||||
onDismiss={() => {}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (state.status === "complete") {
|
||||
return (
|
||||
<Toast
|
||||
message="All sources loaded"
|
||||
onDismiss={onReset}
|
||||
autoDismissMs={3000}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (state.status === "partial-failure") {
|
||||
return (
|
||||
<Toast
|
||||
message={`Loaded ${state.completed}/${state.total} sources (${state.failed} failed)`}
|
||||
onDismiss={onReset}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user