import { Button, Dialog, DialogActions, DialogBody, DialogContent, DialogSurface, DialogTitle, Text } from "@fluentui/react-components";
import type { ImportRunResult } from "../../types/blocklist";

interface ImportResultDialogProps {
  open: boolean;
  result: ImportRunResult | null;
  onClose: () => void;
}

export function ImportResultDialog({ open, result, onClose }: ImportResultDialogProps): React.JSX.Element {
  if (!open || !result) return <></>;

  return (
    <Dialog open={open} onOpenChange={(_ev, data) => { if (!data.open) onClose(); }}>
      <DialogSurface>
        <DialogBody>
          <DialogTitle>Import Complete</DialogTitle>
          <DialogContent>
            <Text size={200}>
              Total imported: {result.total_imported} | Skipped: {result.total_skipped} | Sources with errors: {result.errors_count}
            </Text>
          </DialogContent>
          <DialogActions>
            <Button appearance="primary" onClick={onClose}>
              Close
            </Button>
          </DialogActions>
        </DialogBody>
      </DialogSurface>
    </Dialog>
  );
}
