diff --git a/assets/js/hooks/Mapper/common-styles/fixes.scss b/assets/js/hooks/Mapper/common-styles/fixes.scss index 98149bf7..94b55ad3 100644 --- a/assets/js/hooks/Mapper/common-styles/fixes.scss +++ b/assets/js/hooks/Mapper/common-styles/fixes.scss @@ -112,3 +112,28 @@ .p-autocomplete .p-autocomplete-multiple-container .p-autocomplete-token { margin-right: 0 !important; } + +/* Fixed sizes of Input switch */ +.p-inputswitch { + width: 2.0rem; + height: 1.15rem; + + .p-inputswitch-slider:before { + width: 0.8rem; + height: 0.8rem; + left: 0.14rem; + margin-top: -0.385rem; + } + + &.p-highlight .p-inputswitch-slider:before { + transform: translateX(0.8rem); + } + + &:not(.p-disabled):has(.p-inputswitch-input:hover) .p-inputswitch-slider { + background: rgb(255 255 255 / 21%); + } + + &.p-highlight .p-inputswitch-slider { + background: #966d3d; + } +} diff --git a/assets/js/hooks/Mapper/components/map/components/UnsplashedSignature/UnsplashedSignature.module.scss b/assets/js/hooks/Mapper/components/map/components/UnsplashedSignature/UnsplashedSignature.module.scss index 22f6420b..1c7791ea 100644 --- a/assets/js/hooks/Mapper/components/map/components/UnsplashedSignature/UnsplashedSignature.module.scss +++ b/assets/js/hooks/Mapper/components/map/components/UnsplashedSignature/UnsplashedSignature.module.scss @@ -15,4 +15,8 @@ font-weight: bolder; display: block; } + + & > .Eol { + display: block; + } } diff --git a/assets/js/hooks/Mapper/components/map/components/UnsplashedSignature/UnsplashedSignature.tsx b/assets/js/hooks/Mapper/components/map/components/UnsplashedSignature/UnsplashedSignature.tsx index 022a0e71..49e8fa84 100644 --- a/assets/js/hooks/Mapper/components/map/components/UnsplashedSignature/UnsplashedSignature.tsx +++ b/assets/js/hooks/Mapper/components/map/components/UnsplashedSignature/UnsplashedSignature.tsx @@ -8,8 +8,8 @@ import { WORMHOLE_CLASS_STYLES, WORMHOLES_ADDITIONAL_INFO } from '@/hooks/Mapper import { useMemo } from 'react'; import clsx from 'clsx'; import { renderInfoColumn } from '@/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/renders'; - -import { k162Types } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect'; +import { K162_TYPES_MAP } from '@/hooks/Mapper/constants.ts'; +import { parseSignatureCustomInfo } from '@/hooks/Mapper/helpers/parseSignatureCustomInfo.ts'; interface UnsplashedSignatureProps { signature: SystemSignature; @@ -22,17 +22,22 @@ export const UnsplashedSignature = ({ signature }: UnsplashedSignatureProps) => const whData = useMemo(() => wormholesData[signature.type], [signature.type, wormholesData]); const whClass = useMemo(() => (whData ? WORMHOLES_ADDITIONAL_INFO[whData.dest] : null), [whData]); - const k162TypeOption = useMemo(() => { - if (!signature.custom_info) { - return null; - } - const customInfo = JSON.parse(signature.custom_info); - if (!customInfo.k162Type) { - return null; - } - return k162Types.find(x => x.value === customInfo.k162Type); + const customInfo = useMemo(() => { + return parseSignatureCustomInfo(signature.custom_info); }, [signature]); + const k162TypeOption = useMemo(() => { + if (!customInfo?.k162Type) { + return null; + } + + return K162_TYPES_MAP[customInfo.k162Type]; + }, [customInfo]); + + const isEOL = useMemo(() => { + return customInfo?.isEOL; + }, [customInfo]); + const whClassStyle = useMemo(() => { if (signature.type === 'K162' && k162TypeOption) { const k162Data = wormholesData[k162TypeOption.whClassName]; @@ -45,19 +50,19 @@ export const UnsplashedSignature = ({ signature }: UnsplashedSignatureProps) => return ( - {signature.eve_id}}> - {renderInfoColumn(signature)} - - - ) as React.ReactNode +
+ {signature.eve_id}}> + {renderInfoColumn(signature)} + +
} >
- - + + + {isEOL && }
diff --git a/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/renders/renderInfoColumn.tsx b/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/renders/renderInfoColumn.tsx index a6618411..e49ad6ea 100644 --- a/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/renders/renderInfoColumn.tsx +++ b/assets/js/hooks/Mapper/components/mapInterface/widgets/SystemSignatures/renders/renderInfoColumn.tsx @@ -1,28 +1,29 @@ import { PrimeIcons } from 'primereact/api'; import { SignatureGroup, SystemSignature } from '@/hooks/Mapper/types'; -import { SystemViewStandalone, WHClassView } from '@/hooks/Mapper/components/ui-kit'; +import { SystemViewStandalone, TooltipPosition, WHClassView } from '@/hooks/Mapper/components/ui-kit'; -import { - k162Types, - renderK162Type, -} from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect'; +import { renderK162Type } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect'; import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper'; import clsx from 'clsx'; import { renderName } from './renderName.tsx'; +import { K162_TYPES_MAP } from '@/hooks/Mapper/constants.ts'; +import { parseSignatureCustomInfo } from '@/hooks/Mapper/helpers/parseSignatureCustomInfo.ts'; export const renderInfoColumn = (row: SystemSignature) => { if (!row.group || row.group === SignatureGroup.Wormhole) { - let k162TypeOption = null; - if (row.custom_info) { - const customInfo = JSON.parse(row.custom_info); - if (customInfo.k162Type) { - k162TypeOption = k162Types.find(x => x.value === customInfo.k162Type); - } - } + const customInfo = parseSignatureCustomInfo(row.custom_info); + + const k162TypeOption = customInfo.k162Type ? K162_TYPES_MAP[customInfo.k162Type] : null; return (
+ {customInfo.isEOL && ( + +
+
+ )} + {row.type && ( { /> )} - {!row.linked_system && row.type === 'K162' && !!k162TypeOption && <>{renderK162Type(k162TypeOption)}} + {!row.linked_system && row.type === 'K162' && k162TypeOption && renderK162Type(k162TypeOption)} {row.linked_system && ( <> diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/Connections/PassageCard/PassageCard.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/Connections/PassageCard/PassageCard.tsx index 8246de29..2b480194 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/Connections/PassageCard/PassageCard.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/Connections/PassageCard/PassageCard.tsx @@ -2,7 +2,9 @@ import clsx from 'clsx'; import classes from './PassageCard.module.scss'; import { Passage } from '@/hooks/Mapper/types'; import { TimeAgo } from '@/hooks/Mapper/components/ui-kit'; +import { WdTooltipWrapper } from '@/hooks/Mapper/components/ui-kit/WdTooltipWrapper'; import { kgToTons } from '@/hooks/Mapper/utils/kgToTons.ts'; +import { useMemo } from 'react'; type PassageCardType = { // compact?: boolean; @@ -26,6 +28,11 @@ export const getShipName = (name: string) => { export const PassageCard = ({ inserted_at, character: char, ship }: PassageCardType) => { const isOwn = false; + const insertedAt = useMemo(() => { + const date = new Date(inserted_at); + return date.toLocaleString(); + }, [inserted_at]); + return (
@@ -76,7 +83,9 @@ export const PassageCard = ({ inserted_at, character: char, ship }: PassageCardT {/*time and class*/}
- + + +
{kgToTons(parseInt(ship.ship_type_info.mass))}
diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/PrettySwitchbox/PrettySwitchbox.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/PrettySwitchbox/PrettySwitchbox.tsx index 68ddffe9..9edd4172 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/PrettySwitchbox/PrettySwitchbox.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/MapSettings/components/PrettySwitchbox/PrettySwitchbox.tsx @@ -1,4 +1,5 @@ import styles from './MapSettings.module.scss'; + import { WdCheckbox } from '@/hooks/Mapper/components/ui-kit'; interface PrettySwitchboxProps { diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/SignatureSettings.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/SignatureSettings.tsx index 84bcbb4e..270b5208 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/SignatureSettings.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/SignatureSettings.tsx @@ -53,6 +53,7 @@ export const SignatureSettings = ({ systemId, show, onHide, signatureData }: Map ...out, custom_info: JSON.stringify({ k162Type: values.k162Type, + isEOL: values.isEOL, }), }; @@ -127,14 +128,17 @@ export const SignatureSettings = ({ systemId, show, onHide, signatureData }: Map const { linked_system, custom_info, ...rest } = signatureData; let k162Type = null; + let isEOL = false; if (custom_info) { const customInfo = JSON.parse(custom_info); k162Type = customInfo.k162Type; + isEOL = customInfo.isEOL; } signatureForm.reset({ linked_system: linked_system?.solar_system_id.toString() ?? undefined, k162Type: k162Type, + isEOL: isEOL, ...rest, }); }, [signatureForm, signatureData]); diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureEOLCheckbox/SignatureEOLCheckbox.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureEOLCheckbox/SignatureEOLCheckbox.tsx new file mode 100644 index 00000000..add3286f --- /dev/null +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureEOLCheckbox/SignatureEOLCheckbox.tsx @@ -0,0 +1,24 @@ +import { InputSwitch } from 'primereact/inputswitch'; +import { Controller, useFormContext } from 'react-hook-form'; +import { SystemSignature } from '@/hooks/Mapper/types'; + +export interface SignatureEOLCheckboxProps { + name: string; + defaultValue?: boolean; +} + +export const SignatureEOLCheckbox = ({ name, defaultValue = false }: SignatureEOLCheckboxProps) => { + const { control } = useFormContext(); + + return ( + { + return field.onChange(e.value)} />; + }} + /> + ); +}; diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureEOLCheckbox/index.ts b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureEOLCheckbox/index.ts new file mode 100644 index 00000000..e5af02cd --- /dev/null +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureEOLCheckbox/index.ts @@ -0,0 +1 @@ +export * from './SignatureEOLCheckbox.tsx'; diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureGroupContentWormholes.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureGroupContentWormholes.tsx index d9f92ac8..c7032955 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureGroupContentWormholes.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureGroupContentWormholes.tsx @@ -3,6 +3,7 @@ import { SystemSignature } from '@/hooks/Mapper/types'; import { SignatureWormholeTypeSelect } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureWormholeTypeSelect'; import { SignatureK162TypeSelect } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect'; import { SignatureLeadsToSelect } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureLeadsToSelect'; +import { SignatureEOLCheckbox } from '@/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureEOLCheckbox'; export const SignatureGroupContentWormholes = () => { const { watch } = useFormContext(); @@ -26,6 +27,11 @@ export const SignatureGroupContentWormholes = () => { Leads To: + + ); }; diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/SignatureK162TypeSelect.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/SignatureK162TypeSelect.tsx index 4d7ed440..e12fa4cc 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/SignatureK162TypeSelect.tsx +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/SignatureK162TypeSelect.tsx @@ -3,100 +3,8 @@ import clsx from 'clsx'; import { Controller, useFormContext } from 'react-hook-form'; import { useMemo } from 'react'; import { SystemSignature } from '@/hooks/Mapper/types'; -import { WHClassView } from '@/hooks/Mapper/components/ui-kit'; - -export const k162Types = [ - { - label: 'Hi-Sec', - value: 'hs', - whClassName: 'A641', - }, - { - label: 'Low-Sec', - value: 'ls', - whClassName: 'J377', - }, - { - label: 'Null-Sec', - value: 'ns', - whClassName: 'C248', - }, - { - label: 'C1', - value: 'c1', - whClassName: 'E004', - }, - { - label: 'C2', - value: 'c2', - whClassName: 'D382', - }, - { - label: 'C3', - value: 'c3', - whClassName: 'L477', - }, - { - label: 'C4', - value: 'c4', - whClassName: 'M001', - }, - { - label: 'C5', - value: 'c5', - whClassName: 'L614', - }, - { - label: 'C6', - value: 'c6', - whClassName: 'G008', - }, - { - label: 'C13', - value: 'c13', - whClassName: 'A009', - }, - { - label: 'Thera', - value: 'thera', - whClassName: 'F353', - }, - { - label: 'Pochven', - value: 'pochven', - whClassName: 'F216', - }, -]; - -const renderNoValue = () =>
-Unknown-
; - -// @ts-ignore -export const renderK162Type = (option: { - label?: string; - value: string; - security?: string; - system_class?: number; - whClassName?: string; -}) => { - if (!option) { - return renderNoValue(); - } - const { value, whClassName = '' } = option; - if (value == null) { - return renderNoValue(); - } - - return ( - - ); -}; +import { K162_TYPES } from '@/hooks/Mapper/constants.ts'; +import { renderK162Type } from '.'; export interface SignatureK162TypeSelectProps { name: string; @@ -107,7 +15,7 @@ export const SignatureK162TypeSelect = ({ name, defaultValue = '' }: SignatureK1 const { control } = useFormContext(); const options = useMemo(() => { - return [{ value: null }, ...k162Types]; + return [{ value: null }, ...K162_TYPES]; }, []); return ( diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/index.ts b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/index.ts index 9c9ff58c..d15d9008 100644 --- a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/index.ts +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/index.ts @@ -1 +1,2 @@ export * from './SignatureK162TypeSelect.tsx'; +export * from './renderK162Type.tsx'; diff --git a/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/renderK162Type.tsx b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/renderK162Type.tsx new file mode 100644 index 00000000..6363ebe7 --- /dev/null +++ b/assets/js/hooks/Mapper/components/mapRootContent/components/SignatureSettings/components/SignatureK162TypeSelect/renderK162Type.tsx @@ -0,0 +1,26 @@ +import { WHClassView } from '@/hooks/Mapper/components/ui-kit'; +import { K162Type } from '@/hooks/Mapper/constants.ts'; + +const renderNoValue = () =>
-Unknown-
; + +export const renderK162Type = (option: K162Type) => { + if (!option) { + return renderNoValue(); + } + + const { value, whClassName = '' } = option; + if (value == null) { + return renderNoValue(); + } + + return ( + + ); +}; diff --git a/assets/js/hooks/Mapper/constants.ts b/assets/js/hooks/Mapper/constants.ts index 18f91522..d093e83b 100644 --- a/assets/js/hooks/Mapper/constants.ts +++ b/assets/js/hooks/Mapper/constants.ts @@ -65,3 +65,77 @@ export const REGIONS_MAP: Record = { [Regions.TashMurkon]: Spaces.Amarr, [Regions.VergeVendor]: Spaces.Gallente, }; + +export type K162Type = { + label: string; + value: string; + whClassName: string; +}; + +export const K162_TYPES: K162Type[] = [ + { + label: 'Hi-Sec', + value: 'hs', + whClassName: 'A641', + }, + { + label: 'Low-Sec', + value: 'ls', + whClassName: 'J377', + }, + { + label: 'Null-Sec', + value: 'ns', + whClassName: 'C248', + }, + { + label: 'C1', + value: 'c1', + whClassName: 'E004', + }, + { + label: 'C2', + value: 'c2', + whClassName: 'D382', + }, + { + label: 'C3', + value: 'c3', + whClassName: 'L477', + }, + { + label: 'C4', + value: 'c4', + whClassName: 'M001', + }, + { + label: 'C5', + value: 'c5', + whClassName: 'L614', + }, + { + label: 'C6', + value: 'c6', + whClassName: 'G008', + }, + { + label: 'C13', + value: 'c13', + whClassName: 'A009', + }, + { + label: 'Thera', + value: 'thera', + whClassName: 'F353', + }, + { + label: 'Pochven', + value: 'pochven', + whClassName: 'F216', + }, +]; + +export const K162_TYPES_MAP: { [key: string]: K162Type } = K162_TYPES.reduce( + (acc, x) => ({ ...acc, [x.value]: x }), + {}, +); diff --git a/assets/js/hooks/Mapper/helpers/parseSignatureCustomInfo.ts b/assets/js/hooks/Mapper/helpers/parseSignatureCustomInfo.ts new file mode 100644 index 00000000..0bb2b752 --- /dev/null +++ b/assets/js/hooks/Mapper/helpers/parseSignatureCustomInfo.ts @@ -0,0 +1,9 @@ +import { SignatureCustomInfo } from '@/hooks/Mapper/types'; + +export const parseSignatureCustomInfo = (str: string | undefined): SignatureCustomInfo => { + if (str == null || str === '') { + return {}; + } + + return JSON.parse(str); +}; diff --git a/assets/js/hooks/Mapper/types/signatures.ts b/assets/js/hooks/Mapper/types/signatures.ts index 78505365..7974f550 100644 --- a/assets/js/hooks/Mapper/types/signatures.ts +++ b/assets/js/hooks/Mapper/types/signatures.ts @@ -26,15 +26,20 @@ export type GroupType = { h: number; }; +export type SignatureCustomInfo = { + k162Type?: string; + isEOL?: boolean; +}; + export type SystemSignature = { eve_id: string; kind: SignatureKind; name: string; + // SignatureCustomInfo custom_info?: string; description?: string; group: SignatureGroup; type: string; - k162Type?: string; linked_system?: SolarSystemStaticInfoRaw; inserted_at?: string; updated_at?: string;