"use client"; import { useEffect, useState } from "react"; import { X, ArrowRight } from "lucide-react"; import { EdgeType } from "@/app/types/council"; import { useCouncilStore } from "@/app/store/council-store"; // Right-side panel shown when a canvas edge is selected export function EdgeSettingsPanel() { const selectedEdgeId = useCouncilStore((s) => s.selectedEdgeId); const edges = useCouncilStore((s) => s.edges); const nodes = useCouncilStore((s) => s.nodes); const updateEdgeData = useCouncilStore((s) => s.updateEdgeData); const selectEdge = useCouncilStore((s) => s.selectEdge); const edge = edges.find((e) => e.id === selectedEdgeId); const [edgeType, setEdgeType] = useState("linear"); const [condition, setCondition] = useState(""); useEffect(() => { if (edge) { setEdgeType((edge.data?.type as EdgeType) ?? "linear"); setCondition((edge.data?.condition as string) ?? ""); } }, [selectedEdgeId, edge]); if (!selectedEdgeId || !edge) return null; const sourceNode = nodes.find((n) => n.id === edge.source); const targetNode = nodes.find((n) => n.id === edge.target); const handleTypeChange = (newType: EdgeType) => { setEdgeType(newType); updateEdgeData(selectedEdgeId, newType, newType === "conditional" ? condition : undefined); }; const handleConditionChange = (value: string) => { setCondition(value); updateEdgeData(selectedEdgeId, edgeType, value); }; return ( ); }