Files
wanderer/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemInfo/SystemInfo.tsx
Aleksei Chichenkov d8222d83f0 Refactoring and fixing problems (#317)
* fix(Map): fix design of kills widget, fix design of signatures widget - refactor a lot of code, fixed problem with tooltip blinking

* fix(Map): refactor Tracking dialog, refactor Activity tracker, refactor codebase and some styles

* fix(Core): don't count character passage on manual add connection

* refactor(Core): improved characters tracking API

* fix(Core): fixed link signature to system on 'leads to' set

* fix(Map): Refactor map settings and prepared it to easier using

* fix(Map): Add support new command for following update

* fix(Map): Add support new command for main update

* refactor(Core): Reduce map init data by using cached system static data

* refactor(Core): Reduce map init data by extract signatures loading to a separate event

* fix(Core): adjusted IP rate limits

* fix(Map): Update design of tracking characters. Added icons for following and main. Added ability to see that character on the station or structure

---------

Co-authored-by: achichenkov <aleksei.chichenkov@telleqt.ai>
Co-authored-by: Dmitry Popov <dmitriypopovsamara@gmail.com>
2025-04-11 23:17:53 +04:00

77 lines
3.2 KiB
TypeScript

import { Widget } from '@/hooks/Mapper/components/mapInterface/components';
import { useMapRootState } from '@/hooks/Mapper/mapRootProvider';
import { LayoutEventBlocker, SystemView, WdImgButton } from '@/hooks/Mapper/components/ui-kit';
import { SystemInfoContent } from './SystemInfoContent';
import { PrimeIcons } from 'primereact/api';
import { useState, useCallback } from 'react';
import { SystemSettingsDialog } from '@/hooks/Mapper/components/mapInterface/components/SystemSettingsDialog/SystemSettingsDialog.tsx';
import { ANOIK_ICON, DOTLAN_ICON, ZKB_ICON } from '@/hooks/Mapper/icons';
import { getSystemStaticInfo } from '@/hooks/Mapper/mapRootProvider/hooks/useLoadSystemStatic';
export const SystemInfo = () => {
const [visible, setVisible] = useState(false);
const {
data: { selectedSystems },
} = useMapRootState();
const [systemId] = selectedSystems;
const systemStaticInfo = getSystemStaticInfo(systemId)!;
const { solar_system_name: solarSystemName } = systemStaticInfo || {};
const isNotSelectedSystem = selectedSystems.length !== 1;
const copySystemNameToClipboard = useCallback(async () => {
try {
await navigator.clipboard.writeText(solarSystemName);
} catch (err) {
console.error(err);
}
}, [solarSystemName]);
return (
<Widget
label={
!isNotSelectedSystem && (
<div className="flex justify-between items-center text-xs h-full w-full">
<div className="flex gap-1">
<SystemView systemId={systemId} className="select-none text-center" hideRegion />
<LayoutEventBlocker className="flex gap-1 items-center">
<WdImgButton className={PrimeIcons.COPY} onClick={copySystemNameToClipboard} />
<WdImgButton
className="pi pi-pen-to-square"
onClick={() => setVisible(true)}
tooltip={{ content: 'Edit system name and description' }}
/>
</LayoutEventBlocker>
</div>
<LayoutEventBlocker className="flex gap-1 items-center">
<a href={`https://zkillboard.com/system/${systemId}`} rel="noreferrer" target="_blank">
<img src={ZKB_ICON} width="14" height="14" className="external-icon" />
</a>
<a href={`http://anoik.is/systems/${solarSystemName}`} rel="noreferrer" target="_blank">
<img src={ANOIK_ICON} width="14" height="14" className="external-icon" />
</a>
<a href={`https://evemaps.dotlan.net/system/${solarSystemName}`} rel="noreferrer" target="_blank">
<img src={DOTLAN_ICON} alt="" width="14" height="14" className="external-icon" />
</a>
</LayoutEventBlocker>
</div>
)
}
>
{isNotSelectedSystem ? (
<div className="w-full h-full flex justify-center items-center select-none text-center text-stone-400/80 text-sm">
System is not selected
</div>
) : (
<SystemInfoContent systemId={systemId} onEditClick={() => setVisible(true)} />
)}
{visible && <SystemSettingsDialog systemId={systemId} visible setVisible={setVisible} />}
</Widget>
);
};