mirror of
https://github.com/wanderer-industries/wanderer
synced 2025-11-28 03:53:26 +00:00
* feat(signatures): Add custom info to system signatures * feat(connections): Add custom info to system connections * feat(Map): Add system signature type * feat(Map): Update wormhole types info * feat(Map): Add undo action for removed systems * feat(Map): Delete systems on Backspace hotkey * feat(Map): Update k-space systems background & styles * feat(Map): Update systems status background styles * feat(Map): add support for new wh type data. add signatures settings modal menu; reworked signatures widget - was added info of wormhole; --------- Co-authored-by: achichenkov <aleksei.chichenkov@telleqt.ai>
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
|
|
import { useMemo } from 'react';
|
|
import { getSystemById } from '@/hooks/Mapper/helpers';
|
|
import { useLoadSystemStatic } from '@/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic.ts';
|
|
|
|
interface UseSystemInfoProps {
|
|
systemId: string;
|
|
}
|
|
|
|
export const useSystemInfo = ({ systemId }: UseSystemInfoProps) => {
|
|
const {
|
|
data: { systems, connections },
|
|
} = useMapRootState();
|
|
|
|
const { systems: systemStatics } = useLoadSystemStatic({ systems: [systemId] });
|
|
|
|
return useMemo(() => {
|
|
const staticInfo = systemStatics.get(parseInt(systemId));
|
|
const dynamicInfo = getSystemById(systems, systemId);
|
|
|
|
if (!staticInfo || !dynamicInfo) {
|
|
throw new Error(`Error on getting system ${systemId}`);
|
|
}
|
|
|
|
const leadsTo = connections
|
|
.filter(x => [x.source, x.target].includes(systemId))
|
|
.map(x => [x.source, x.target])
|
|
.flat()
|
|
.filter(x => x !== systemId);
|
|
|
|
return { dynamicInfo, staticInfo, leadsTo };
|
|
}, [systemStatics, systemId, systems, connections]);
|
|
};
|