mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-12-11 18:26:04 +00:00
22 lines
468 B
TypeScript
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,
|
|
};
|
|
}),
|
|
);
|
|
}, []);
|
|
};
|