Files
react-flow/src/nodes/NoteFlow.tsx

757 lines
21 KiB
TypeScript
Raw Normal View History

2024-09-09 16:00:58 +07:00
import { useState, useCallback, useEffect } from 'react';
import {
ReactFlow,
addEdge,
Controls,
Background,
BackgroundVariant,
2024-09-18 22:46:14 +07:00
SelectionMode,
applyNodeChanges,
applyEdgeChanges,
MarkerType
2024-09-09 16:00:58 +07:00
} from '@xyflow/react';
2024-08-16 15:08:06 +07:00
import '@xyflow/react/dist/style.css';
2024-09-09 16:00:58 +07:00
import '../assets/css/style.css';
import Tabbar from './Tabbar.tsx';
import ShowPopup from './ShowPopup.tsx';
2024-09-10 10:56:15 +07:00
import { nanoid } from 'nanoid';
import CustomEdge from './CustomEdge';
2024-09-18 22:46:14 +07:00
import MenuFlow from './MenuFlow';
2024-08-23 14:19:10 +07:00
const initialNodes = [
{
2024-09-09 16:00:58 +07:00
key: 'customer-sign',
2024-08-23 14:19:10 +07:00
id: '1',
type: 'input',
data: {
2024-08-16 15:08:06 +07:00
label: (
2024-09-09 16:00:58 +07:00
<div className='step'>
<div className='left'>
<img
2024-09-18 22:46:14 +07:00
src='/src/assets/icons/icon-time.svg'
2024-09-09 16:00:58 +07:00
width='24px'
height='24px'
alt=''
/>
</div>
<div className='right'>Customer signs up to</div>
2024-08-16 15:08:06 +07:00
</div>
2024-09-09 16:00:58 +07:00
)
2024-08-16 15:08:06 +07:00
},
2024-09-09 16:00:58 +07:00
position: { x: 250, y: 100 }
2024-08-23 14:19:10 +07:00
},
{
id: '2',
2024-09-18 22:46:14 +07:00
key: 'add-node',
type: 'output',
data: {
label: (
<div className='add-node'>
<i>+</i> <span>Add a journey point</span>
</div>
)
},
position: { x: 250, y: 220 }
2024-09-09 16:00:58 +07:00
}
2024-08-16 15:08:06 +07:00
];
2024-08-24 11:01:05 +07:00
// Nội dung cho mỗi node
const nodeContents = {
2024-09-09 16:00:58 +07:00
'send-email': `
2024-08-24 11:01:05 +07:00
<label for="email-subject">Subject:</label>
<input type="text" id="email-subject" name="email-subject" placeholder="Enter subject">
<label for="email-body">Body:</label>
<textarea id="email-body" name="email-body" rows="4" placeholder="Enter email body"></textarea>
`,
2024-09-09 16:00:58 +07:00
'customer-sign': `
2024-08-24 11:01:05 +07:00
<label for="customer-name">Customer Name:</label>
<input type="text" id="customer-name" name="customer-name" placeholder="Enter customer name">
<label for="customer-email">Customer Email:</label>
<input type="email" id="customer-email" name="customer-email" placeholder="Enter customer email">
`,
2024-09-09 16:00:58 +07:00
ifelse: `
2024-08-24 11:01:05 +07:00
<label for="reply-status">Reply Status:</label>
<select id="reply-status" name="reply-status">
<option value="replied">Replied</option>
<option value="not-replied">Not Replied</option>
</select>
`,
2024-09-09 16:00:58 +07:00
'contact-exists': `
2024-08-24 11:01:05 +07:00
<label for="contact-id">Contact ID:</label>
<input type="text" id="contact-id" name="contact-id" placeholder="Enter contact ID">
`,
2024-09-09 16:00:58 +07:00
'send-survey': `
2024-08-24 11:01:05 +07:00
<label for="survey-question">Survey Question:</label>
<input type="text" id="survey-question" name="survey-question" placeholder="Enter survey question">
<label for="survey-options">Options (comma-separated):</label>
<input type="text" id="survey-options" name="survey-options" placeholder="Option 1, Option 2, ...">
`
};
2024-09-18 22:46:14 +07:00
const connectEdges = [
{
id: 'e1-2',
source: '1',
target: '2'
}
];
2024-08-16 15:08:06 +07:00
const NoteFlow = () => {
2024-08-23 14:19:10 +07:00
const [nodes, setNodes] = useState(initialNodes);
2024-09-18 22:46:14 +07:00
const [edges, setEdges] = useState(connectEdges);
2024-08-16 15:08:06 +07:00
const [showTabBar, setShowTabBar] = useState(false);
const [lastNodeId, setLastNodeId] = useState('1');
2024-08-24 11:01:05 +07:00
const [nodeToDelete, setNodeToDelete] = useState(null);
const [showPopup, setShowPopup] = useState(false);
const [selectedNodeContent, setSelectedNodeContent] = useState('');
2024-09-10 10:56:15 +07:00
const [addNodeCallback, setAddNodeCallback] = useState(() => () => {});
2024-09-10 18:19:20 +07:00
const [isTabbarVisible, setIsTabbarVisible] = useState(false);
2024-08-24 11:01:05 +07:00
2024-08-16 15:08:06 +07:00
const handleAddNoteClick = () => {
setShowTabBar(true);
2024-09-10 18:19:20 +07:00
setIsTabbarVisible(true);
2024-09-10 10:56:15 +07:00
setAddNodeCallback(() => (selectedNode) => {
2024-09-09 16:00:58 +07:00
addNodeBetween(selectedNode, sourceId, targetId);
2024-09-10 10:56:15 +07:00
});
2024-08-16 15:08:06 +07:00
};
2024-09-10 18:19:20 +07:00
const closeTabbar = () => {
setIsTabbarVisible(false); // Ẩn tabbar khi click close
};
2024-08-16 15:08:06 +07:00
2024-09-09 16:00:58 +07:00
const onNodeClick = (event, node) => {
2024-09-18 22:46:14 +07:00
console.log(node);
if (node.key === 'add-node') {
console.log(node);
// Check if the clicked node is "Add Node"
2024-09-09 16:00:58 +07:00
setShowTabBar(true);
2024-09-10 18:19:20 +07:00
setIsTabbarVisible(true);
2024-09-09 16:00:58 +07:00
} else {
// Hiển thị popup khi click vào bất kỳ node nào
const content = nodeContents[node.key]; // Lấy nội dung tương ứng của node
setSelectedNodeContent(content); // Cập nhật nội dung cho popup
setShowPopup(true); // Mở popup
}
};
2024-08-23 14:19:10 +07:00
2024-09-09 16:00:58 +07:00
const onNodeContextMenu = useCallback((event, node) => {
event.preventDefault(); // Ngăn không cho menu chuột phải mặc định hiện ra
setNodeToDelete(node);
}, []);
2024-08-24 21:28:13 +07:00
2024-09-09 16:00:58 +07:00
const handleNodeDelete = () => {
if (nodeToDelete) {
setNodes((nds) => nds.filter((node) => node.id !== nodeToDelete.id));
setEdges((eds) =>
eds.filter(
(edge) =>
edge.source !== nodeToDelete.id && edge.target !== nodeToDelete.id
)
);
setNodeToDelete(null);
2024-08-24 21:28:13 +07:00
}
2024-09-09 16:00:58 +07:00
};
2024-08-24 21:28:13 +07:00
2024-09-09 16:00:58 +07:00
// Function to get a unique y position
const getUniqueYPosition = (xPosition, baseY, spacing) => {
const existingYPositions = nodes
.filter((node) => node.position.x === xPosition)
.map((node) => node.position.y);
let newYPosition = baseY;
2024-08-16 15:08:06 +07:00
2024-09-09 16:00:58 +07:00
while (existingYPositions.includes(newYPosition)) {
newYPosition += spacing;
}
return newYPosition;
};
const getNextYPosition = (xPosition, spacing) => {
const nodesInColumn = nodes.filter((node) => node.position.x === xPosition);
if (nodesInColumn.length === 0) return 0; // Return 0 if there are no nodes
const lastNode = nodesInColumn[nodesInColumn.length - 1];
return lastNode.position.y + spacing;
};
2024-09-10 10:56:15 +07:00
const removeEdgesRelatedToNode = (nodeId) => {
setEdges((eds) =>
eds.filter((edge) => edge.source !== nodeId && edge.target !== nodeId)
);
};
2024-09-09 16:00:58 +07:00
const addNode = (option) => {
2024-09-10 10:56:15 +07:00
const newNodeId = nanoid(8); // Generate a unique ID for the new node
2024-09-18 22:46:14 +07:00
const addNoteNode = nodes.find((node) => node.key === 'add-node');
const initialX = addNoteNode?.position.x;
2024-09-10 10:56:15 +07:00
2024-09-09 16:00:58 +07:00
const nextY =
nodes.length > 2
2024-09-18 22:46:14 +07:00
? getNextYPosition(initialX, 120)
: addNoteNode?.position.y;
2024-08-16 15:08:06 +07:00
2024-09-10 10:56:15 +07:00
// Remove existing edges from addNoteNode
setEdges((eds) =>
eds.filter((edge) => edge.source !== '2' && edge.target !== '2')
);
2024-08-16 15:08:06 +07:00
2024-09-10 10:56:15 +07:00
if (option.id === '4') {
2024-08-23 14:19:10 +07:00
const repliedNode = {
2024-09-09 16:00:58 +07:00
id: newNodeId,
key: option.key,
data: { label: option.htmlNode },
2024-09-10 10:56:15 +07:00
position: { x: initialX, y: nextY }
2024-08-16 15:08:06 +07:00
};
2024-08-23 14:19:10 +07:00
const yesNode = {
2024-09-10 10:56:15 +07:00
id: nanoid(8),
2024-08-23 14:42:10 +07:00
type: 'output',
2024-09-09 16:00:58 +07:00
key: 'contact-exists',
2024-08-23 14:19:10 +07:00
data: {
label: (
2024-09-09 16:00:58 +07:00
<div className='step'>
<div className='left'>
<img
src='/src/assets/icons/icon-check.svg'
width='24px'
height='24px'
alt=''
/>
</div>
<div className='right'>Contact Exists</div>
2024-08-23 14:19:10 +07:00
</div>
2024-09-09 16:00:58 +07:00
)
2024-08-23 14:19:10 +07:00
},
2024-09-10 10:56:15 +07:00
position: { x: initialX - 150, y: nextY + 150 }
2024-08-16 15:08:06 +07:00
};
2024-08-23 14:19:10 +07:00
const noNode = {
2024-09-10 10:56:15 +07:00
id: nanoid(8),
type: '',
2024-09-09 16:00:58 +07:00
key: 'send-survey',
2024-08-23 14:19:10 +07:00
data: {
label: (
2024-09-09 16:00:58 +07:00
<div className='step'>
<div className='left'>
<img
src='/src/assets/icons/icon-list.svg'
width='24px'
height='24px'
alt=''
/>
</div>
<div className='right'>Send survey</div>
2024-08-23 14:19:10 +07:00
</div>
2024-09-09 16:00:58 +07:00
)
2024-08-23 14:19:10 +07:00
},
2024-09-10 10:56:15 +07:00
position: { x: initialX + 150, y: nextY + 150 }
2024-08-23 14:19:10 +07:00
};
2024-09-10 10:56:15 +07:00
// Di chuyển node add-note sang nhánh no
setNodes((nds) =>
nds.map((node) =>
node.id === '2'
? {
...node,
position: {
x: noNode.position.x,
y: noNode.position.y + 150
}
}
: node
)
);
// Thêm các node mới (replied, yes, no)
2024-08-23 14:19:10 +07:00
setNodes((nds) => [...nds, repliedNode, yesNode, noNode]);
2024-08-16 15:08:06 +07:00
2024-09-10 10:56:15 +07:00
// Kết nối các edges giữa các node
2024-08-16 15:08:06 +07:00
setEdges((eds) => [
...eds,
2024-09-09 16:00:58 +07:00
{
2024-09-10 10:56:15 +07:00
id: nanoid(8),
2024-09-09 16:00:58 +07:00
source: repliedNode.id,
target: yesNode.id,
2024-09-10 10:56:15 +07:00
label: 'yes'
2024-09-09 16:00:58 +07:00
},
{
2024-09-10 10:56:15 +07:00
id: nanoid(8),
2024-09-09 16:00:58 +07:00
source: repliedNode.id,
target: noNode.id,
2024-09-10 10:56:15 +07:00
label: 'no'
2024-09-09 16:00:58 +07:00
},
2024-09-10 10:56:15 +07:00
{ id: nanoid(8), source: lastNodeId, target: repliedNode.id },
{ id: nanoid(8), source: noNode.id, target: addNoteNode.id }
2024-08-16 15:08:06 +07:00
]);
2024-09-10 10:56:15 +07:00
setLastNodeId(noNode.id);
2024-08-23 14:19:10 +07:00
} else {
2024-09-09 16:00:58 +07:00
// Add new node logic
2024-08-23 14:19:10 +07:00
if (addNoteNode) {
2024-09-09 16:00:58 +07:00
const initialX = addNoteNode.position.x;
2024-08-23 14:19:10 +07:00
setNodes((nds) =>
nds.map((node) =>
2024-09-18 22:46:14 +07:00
node.key === 'add-node'
2024-09-09 16:00:58 +07:00
? {
...node,
position: {
x: initialX,
y: nextY + 130
}
}
2024-08-23 14:19:10 +07:00
: node
)
);
}
2024-09-09 16:00:58 +07:00
const newNode = {
id: newNodeId,
key: option.key,
data: { label: option.htmlNode },
position: {
2024-09-10 10:56:15 +07:00
x: initialX,
2024-09-09 16:00:58 +07:00
y: nodes.length > 2 ? nextY : addNoteNode.position.y
}
};
2024-08-23 14:19:10 +07:00
2024-09-10 10:56:15 +07:00
const newEdge = {
id: nanoid(8),
source: lastNodeId,
target: newNodeId
2024-09-18 22:46:14 +07:00
// data: {
// label: <div onClick={handleAddNoteClick}>+</div>,
// onClick: handleAddNoteClick
// }
2024-09-10 10:56:15 +07:00
};
2024-08-23 14:19:10 +07:00
2024-09-09 16:00:58 +07:00
setNodes((nds) => [...nds, newNode]);
setEdges((eds) => [
...eds,
2024-09-10 10:56:15 +07:00
newEdge,
{ id: nanoid(8), source: newNodeId, target: addNoteNode.id }
2024-09-09 16:00:58 +07:00
]);
2024-08-23 14:19:10 +07:00
2024-09-10 10:56:15 +07:00
// setEdges((eds) => [
// ...eds,
// {
2024-09-18 22:46:14 +07:00
// id: nanoid(8),
2024-09-10 10:56:15 +07:00
// source: lastNodeId,
// data: {
// label: <div onClick={handleAddNoteClick}>Add Note</div>, // Use HTML or React component
// onClick: handleAddNoteClick
// },
// target: newNodeId
2024-09-18 22:46:14 +07:00
// },
// { id: nanoid(8), source: newNodeId, target: addNoteNode.id }
2024-09-10 10:56:15 +07:00
// ]);
2024-09-18 22:46:14 +07:00
2024-09-10 10:56:15 +07:00
// Cuộn tới node mới thêm
2024-09-09 16:00:58 +07:00
setLastNodeId(newNodeId);
2024-08-16 15:08:06 +07:00
}
2024-08-23 14:42:10 +07:00
2024-09-09 16:00:58 +07:00
setShowTabBar(false);
2024-08-16 15:08:06 +07:00
};
2024-09-09 16:00:58 +07:00
const hidePopup = () => {
setShowPopup(false);
2024-08-22 16:42:25 +07:00
};
2024-09-09 16:00:58 +07:00
const addPopup = (node) => {
const content = nodeContents[node.id]; // Lấy nội dung từ nodeContents dựa trên ID node
setSelectedNodeContent(content); // Cập nhật nội dung được chọn
2024-08-24 11:01:05 +07:00
};
2024-09-18 22:46:14 +07:00
const onDrop = (event) => {
event.preventDefault();
const type = JSON.parse(
event.dataTransfer.getData('application/reactflow')
);
const reactFlowBounds = event.target.getBoundingClientRect();
const position = {
x: event.clientX - reactFlowBounds.left - 100,
y: event.clientY - reactFlowBounds.top + 5
};
const newNodeId = nanoid(8);
// Xử lý add-node với id '2'
const addNodeId = '2';
const addNode = nodes.find((node) => node.id === addNodeId);
// Tìm các edge nối với node có id '2'
const targetEdge = edges.find(
(edge) => edge?.source === '2' || edge?.target === '2'
);
const targetNodeId =
targetEdge?.source === '2' ? targetEdge?.target : targetEdge?.source;
const targetNode = nodes.find((node) => node.id === targetNodeId);
// Cập nhật vị trí của node mới để cách node đang kết nối 200 đơn vị
const newNodePosition = {
x: targetNode?.position.x,
y: targetNode?.position.y + 110
};
// Tạo node mới
const newNode = {
id: newNodeId,
key: type.key,
type: type.type || 'default',
data: {
label: (
<div className='step'>
<div className='left'>
<img src={type.icon} width='24px' height='24px' alt='' />
</div>
<div className='right'>{type.label}</div>
</div>
)
},
position: newNodePosition
};
// Loại bỏ các edge liên quan đến node '2'
setEdges((eds) =>
eds.filter((edge) => edge.source !== '2' && edge.target !== '2')
);
// Kiểm tra điều kiện node là 'ifelse'
if (type.key === 'ifelse') {
setNodes((nds) => nds.filter((node) => node.id !== addNodeId));
const yesNodeId = nanoid(8);
const noNodeId = nanoid(8);
// Tạo node Yes
const yesNode = {
id: yesNodeId,
key: 'add-node',
brand: 'yes',
data: {
label: (
<div className='add-node'>
<i>+</i> <span>Add a journey point</span>
</div>
)
},
position: {
x: newNode.position.x - 200, // Điều chỉnh vị trí của nhánh Yes
y: newNode.position.y + 150 // Điều chỉnh vị trí của nhánh Yes
}
};
// Tạo node No
const noNode = {
id: noNodeId,
key: 'add-node',
brand: 'no',
data: {
label: (
<div className='add-node'>
<i>+</i> <span>Add a journey point</span>
</div>
)
},
position: {
x: newNode?.position.x + 200, // Điều chỉnh vị trí của nhánh No
y: newNode?.position.y + 150 // Điều chỉnh vị trí của nhánh No
}
};
// Tạo các edge nối từ node ifelse đến Yes và No
const ifelseEdges = [
{
id: nanoid(8),
source: targetNodeId,
target: newNodeId
},
{
id: nanoid(8),
source: newNodeId,
target: yesNodeId,
type: 'custom',
data: {
label: 'Yes'
}
},
{
id: nanoid(8),
source: newNodeId,
target: noNodeId,
type: 'custom',
data: {
label: 'No'
}
}
];
// Thêm node yes, no và edge vào danh sách node và edges
setNodes((nds) => [...nds, newNode, yesNode, noNode]);
setEdges((eds) => [...eds, ...ifelseEdges]);
} else {
// Nếu không phải 'ifelse', kiểm tra các điều kiện của node bình thường
if (targetNode) {
setNodes((nds) => [...nds, newNode]);
setEdges((eds) => [
...eds,
{
id: nanoid(8),
source: targetNodeId,
target: newNodeId
},
{
id: nanoid(8),
source: newNodeId,
target: '2'
}
]);
if (addNode) {
const addNodePosition = {
x: addNode.position.x,
y: addNode.position.y + 110
};
setNodes((nds) =>
nds.map((node) =>
node.id === addNodeId
? { ...node, position: addNodePosition }
: node
)
);
setEdges((eds) =>
eds.filter(
(edge) => edge.source !== addNodeId && edge.target !== addNodeId
)
);
// Thêm edge mới nối add-node và node mới
setEdges((eds) => [
...eds,
{
id: nanoid(8),
source: newNodeId,
target: addNodeId
}
]);
// Kiểm tra nếu node mới là 'contact-exists', ẩn add-node
if (type.key === 'contact-exists') {
setNodes((nds) => nds.filter((node) => node.id !== addNodeId));
}
}
} else {
const newNodeNew = {
id: newNodeId,
key: type.key,
type: type.type || 'default',
data: {
label: (
<div className='step'>
<div className='left'>
<img src={type.icon} width='24px' height='24px' alt='' />
</div>
<div className='right'>{type.label}</div>
</div>
)
},
position: position
};
setNodes((nds) => [...nds, newNodeNew]);
}
}
};
const onDragOver = useCallback((event) => {
event.preventDefault();
event.dataTransfer.dropEffect = 'move';
}, []);
const onNodesChange = useCallback(
(changes) => setNodes((nds) => applyNodeChanges(changes, nds)),
[setNodes]
);
const onEdgesChange = useCallback(
(changes) => setEdges((eds) => applyEdgeChanges(changes, eds)),
[setEdges]
);
const defaultEdgeOptions = {
style: { strokeWidth: 1.5, stroke: 'black' },
type: 'floating',
markerEnd: {
type: MarkerType.ArrowClosed,
color: 'black'
}
};
const onConnect = useCallback(
(params) => setEdges((eds) => addEdge(params, eds)),
[setEdges]
);
// Hàm tính khoảng cách giữa hai node
const getDistance = (pos1, pos2) => {
return Math.sqrt(
Math.pow(pos1.x - pos2.x, 2) + Math.pow(pos1.y - pos2.y, 2)
);
};
// Hàm xử lý khi dừng kéo node
const onNodeDragStop = useCallback(
(event, node) => {
const threshold = 50; // khoảng cách cho phép để node bị "đè"
let closestNode = null;
let closestDistance = Infinity;
nodes.forEach((item) => {
if (item.id !== node.id) {
const distance = getDistance(node.position, item.position);
if (distance < closestDistance && distance <= threshold) {
closestNode = item;
closestDistance = distance;
}
}
});
if (closestNode) {
// Thay thế node cũ bằng node mới
const updatedEdges = edges.map((edge) => {
if (edge.source === closestNode.id) {
return { ...edge, source: node.id }; // Nối node mới làm source
}
if (edge.target === closestNode.id) {
return { ...edge, target: node.id }; // Nối node mới làm target
}
return edge;
});
if (node.type != 'output') {
// Tạo một node mới với nội dung "Add a journey point" ngay dưới node thay thế
const newNode = {
id: nanoid(8),
key: 'add-node',
brand: node.brand,
position: {
x: node.position.x, // Giữ nguyên vị trí x
y: node.position.y + 100 // Đặt node mới xuống dưới 150 đơn vị y
},
data: {
label: (
<div className='add-node'>
<i>+</i> <span>Add a journey point</span>
</div>
)
}
};
// Thay thế node cũ bằng node mới
setNodes((nds) => [
...nds.map((n) =>
n.id === closestNode.id
? { ...closestNode, ...node, position: node.position }
: n
),
newNode // Thêm node mới
]);
// Cập nhật edges
setEdges([
...updatedEdges,
{
id: nanoid(8), // ID của edge mới
source: node.id, // Nối từ node vừa thay thế
target: newNode.id // Đến node "Add a journey point"
}
]);
} else {
// Thay thế node cũ bằng node mới
setNodes((nds) => [
...nds.map((n) =>
n.id === closestNode.id
? { ...closestNode, ...node, position: node.position }
: n
)
]);
// Cập nhật edges
setEdges(updatedEdges);
}
} else {
// Không có node gần, cập nhật node vào vị trí mới
setNodes((nds) =>
nds.map((n) =>
n.id === node.id ? { ...n, position: node.position } : n
)
);
}
},
[nodes, edges, setNodes, setEdges]
);
2024-08-16 15:08:06 +07:00
return (
2024-09-18 22:46:14 +07:00
<div style={{ overflowY: 'auto', position: 'relative' }}>
<div className='flex-flow'>
<MenuFlow />
<div className='panelContainer'>
<ReactFlow
nodes={nodes}
edges={edges}
edgeTypes={{ custom: CustomEdge }}
onNodeClick={onNodeClick}
onNodeContextMenu={onNodeContextMenu}
onNodesChange={onNodesChange}
onEdgesChange={onEdgesChange}
onDrop={onDrop}
onDragOver={onDragOver}
panOnScroll
defaultEdgeOptions={defaultEdgeOptions}
onConnect={onConnect}
onNodeDragStop={onNodeDragStop}
>
<Controls position='right-bottom' />
<Background variant={BackgroundVariant.Lines} color='#ccccc' />
</ReactFlow>
</div>
</div>
2024-09-09 16:00:58 +07:00
2024-09-10 18:19:20 +07:00
{isTabbarVisible && (
<Tabbar addNode={addNode} closeTabbar={closeTabbar} />
)}
2024-09-09 16:00:58 +07:00
2024-08-24 11:01:05 +07:00
{nodeToDelete && (
<div
style={{
position: 'absolute',
top: nodeToDelete.position.y - 12,
left: nodeToDelete.position.x + 260,
2024-09-09 16:00:58 +07:00
zIndex: 10
2024-08-24 11:01:05 +07:00
}}
>
<button
onClick={handleNodeDelete}
style={{
background: 'red',
color: 'white',
border: 'none',
borderRadius: '4px',
cursor: 'pointer'
}}
>
X
</button>
</div>
)}
{showPopup && (
2024-09-09 16:00:58 +07:00
<ShowPopup
selectedNodeContent={selectedNodeContent}
hidePopup={() => setShowPopup(false)}
/>
2024-08-24 11:01:05 +07:00
)}
2024-08-16 15:08:06 +07:00
</div>
);
};
2024-09-09 16:00:58 +07:00
export default NoteFlow;