Files
wanderer/assets/js/hooks/Mapper/components/map/hooks/api/useSelectSystem.ts

22 lines
468 B
TypeScript

import { useReactFlow } from 'reactflow';
import { useCallback } from 'react';
import { CommandSelectSystem } from '@/hooks/Mapper/types';
export const useSelectSystem = () => {
const rf = useReactFlow();
return useCallback((systemId: CommandSelectSystem) => {
if (!rf) {
return;
}
rf.setNodes(nds =>
nds.map(node => {
return {
...node,
selected: node.id === systemId,
};
}),
);
}, []);
};