import React, { useCallback, ClipboardEvent, useRef } from 'react'; import { useMapRootState } from '@/hooks/Mapper/mapRootProvider'; import useMaxWidth from '@/hooks/Mapper/hooks/useMaxWidth'; import { LayoutEventBlocker, WdImgButton, TooltipPosition, InfoDrawer, SystemView, } from '@/hooks/Mapper/components/ui-kit'; import { PrimeIcons } from 'primereact/api'; import { Widget } from '@/hooks/Mapper/components/mapInterface/components'; import { SystemStructuresContent } from './SystemStructuresContent/SystemStructuresContent'; import { useSystemStructures } from './hooks/useSystemStructures'; import { processSnippetText } from './helpers'; export const SystemStructures: React.FC = () => { const { data: { selectedSystems }, outCommand, } = useMapRootState(); const [systemId] = selectedSystems; const isNotSelectedSystem = selectedSystems.length !== 1; const { structures, handleUpdateStructures } = useSystemStructures({ systemId, outCommand }); const labelRef = useRef(null); const isCompact = useMaxWidth(labelRef, 260); const processClipboard = useCallback( (text: string) => { const updated = processSnippetText(text, structures); handleUpdateStructures(updated); }, [structures, handleUpdateStructures], ); const handlePaste = useCallback( (e: ClipboardEvent) => { e.preventDefault(); processClipboard(e.clipboardData.getData('text')); }, [processClipboard], ); const handlePasteTimer = useCallback(async () => { try { const text = await navigator.clipboard.readText(); processClipboard(text); } catch (err) { console.error('Clipboard read error:', err); } }, [processClipboard]); function renderWidgetLabel() { return (
{!isCompact && (
Structures {!isNotSelectedSystem && ' in'}
)} {!isNotSelectedSystem && }
How to add/update structures?}> In game, select one or more structures in D-Scan and then
use the blue add structure data button
How to add a timer?}> In game, select a structure with an active timer, right click to copy, and then blue use the blue add structure data button
), }} /> ); } return (
{isNotSelectedSystem ? (
System is not selected
) : ( )}
); };