diff --git a/src/components/nodes/OutputNode.tsx b/src/components/nodes/OutputNode.tsx new file mode 100644 index 0000000..c1e9476 --- /dev/null +++ b/src/components/nodes/OutputNode.tsx @@ -0,0 +1,124 @@ +import { memo, useState } from 'react'; +import { Handle, Position } from '@xyflow/react'; +import type { NodeProps } from '@xyflow/react'; +import { FileText, ChevronDown, ChevronUp, Download } from 'lucide-react'; +import type { OutputNodeData } from '../../types/nodes'; + +export const OutputNode = memo(({ data }: NodeProps) => { + const [isExpanded, setIsExpanded] = useState(true); + const nodeData = data as OutputNodeData; + + const downloadJSON = () => { + if (!nodeData.previewData) return; + + const jsonString = JSON.stringify(nodeData.previewData, null, 2); + const blob = new Blob([jsonString], { type: 'application/json' }); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = `${nodeData.previewData.id || 'npc'}.json`; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + }; + + return ( +
+ {/* Node Header */} +
+
+ + Output Preview +
+
+ + +
+
+ + {/* Input Handle */} + + + {/* Node Content */} + {isExpanded && ( +
+
+

NPC Summary

+
+
+
Name:
+
+ {nodeData.previewData?.names?.[0] || 'Unnamed'} +
+
+
+
ID:
+
+ {nodeData.previewData?.id || 'N/A'} +
+
+
+
Battle:
+
+ {nodeData.previewData?.battleConfiguration?.canChallenge + ? 'Enabled' + : 'Disabled'} +
+
+
+
Party:
+
+ {nodeData.previewData?.party?.type || 'None'} +
+
+
+
Variables:
+
+ {nodeData.previewData?.config?.length || 0} +
+
+
+
+ +
+
+

JSON Preview

+ + {JSON.stringify(nodeData.previewData).length} chars + +
+
+              {JSON.stringify(nodeData.previewData, null, 2)}
+            
+
+ + +
+ )} +
+ ); +}); + +OutputNode.displayName = 'OutputNode';