TableCanvasView.tsx1.5 KBView on GitHub
/**
 * TableCanvasView
 *
 * Renders the full CRM table as a canvas. Uses the same ConversationCanvas
 * infrastructure as the 'conversationCanvas' type — the underlying data is
 * identical (both read from conversationsSlice). The only difference is that
 * TableViewConfig defaults to showing all columns with no preset applied.
 *
 * Presets/column config are stored in canvas.viewConfig exactly like the
 * list and kanban canvas types.
 */

import type { Canvas, TableViewConfig, ConversationViewConfig } from '@/modules/canvas/types/canvas-types';
import { ConversationCanvas } from '@/modules/crm/components/conversation-canvas';

interface TableCanvasViewProps {
  canvas: Canvas;
}

export function TableCanvasView({ canvas }: TableCanvasViewProps) {
  // TableViewConfig has identical fields to ConversationViewConfig.
  // Cast so ConversationCanvas can read presetId, columnConfiguration, etc.
  const tableConfig = canvas.viewConfig as TableViewConfig;
  const adaptedCanvas: Canvas = {
    ...canvas,
    viewConfig: {
      type: 'conversationCanvas',
      presetId: tableConfig.presetId,
      columnIds: tableConfig.columnIds,
      filterSortConfiguration: tableConfig.filterSortConfiguration,
      columnConfiguration: tableConfig.columnConfiguration,
      selectedAopIds: tableConfig.selectedAopIds,
      searchQuery: tableConfig.searchQuery,
      ownerUserIds: tableConfig.ownerUserIds,
    } satisfies ConversationViewConfig,
  };

  return <ConversationCanvas canvas={adaptedCanvas} />;
}