import React from 'react';
import { Database } from 'lucide-react-native';

import type { SuperagentToolRendererProps } from '../../types';
import { getCreateEntitiesInfo } from '../entityWidgetUtils';
import { ToolWidgetRow } from '../primitives/ToolWidgetRow';
import { getWidgetStatus } from '../toolWidgetUtils';

// create_entity_records — native port of the web CreateEntities row (create_entities there).
export function CreateEntitiesWidget({ toolCall }: SuperagentToolRendererProps) {
  const status = getWidgetStatus(toolCall.status);
  const { entityName, recordCount } = getCreateEntitiesInfo(toolCall);

  const title = status === 'running' ? 'Creating' : status === 'error' ? 'Failed to create' : 'Created';

  return (
    <ToolWidgetRow
      chipText={entityName}
      icon={Database}
      note={recordCount != null && recordCount > 0 ? `${recordCount} records` : null}
      status={status}
      title={title}
    />
  );
}
