/** * 리플레이 전용 범례 컴포넌트 * - 리플레이 모드에서 선종별 카운트 표시 * - ShipLegend 디자인 재사용, replayStore 연동 */ import { memo } from 'react'; import { shallow } from 'zustand/shallow'; import useReplayStore from '../../replay/stores/replayStore'; import { SIGNAL_KIND_CODE_FISHING, SIGNAL_KIND_CODE_KCGV, SIGNAL_KIND_CODE_PASSENGER, SIGNAL_KIND_CODE_CARGO, SIGNAL_KIND_CODE_TANKER, SIGNAL_KIND_CODE_GOV, SIGNAL_KIND_CODE_NORMAL, SIGNAL_KIND_CODE_BUOY, } from '../../types/constants'; import './ShipLegend.scss'; // 선박 종류별 SVG 아이콘 import fishingIcon from '../../assets/img/shipKindIcons/fishing.svg'; import passIcon from '../../assets/img/shipKindIcons/pass.svg'; import cargoIcon from '../../assets/img/shipKindIcons/cargo.svg'; import hazardIcon from '../../assets/img/shipKindIcons/hazard.svg'; import govIcon from '../../assets/img/shipKindIcons/gov.svg'; import kcgvIcon from '../../assets/img/shipKindIcons/kcgv.svg'; import bouyIcon from '../../assets/img/shipKindIcons/bouy.svg'; import etcIcon from '../../assets/img/shipKindIcons/etc.svg'; /** * 선박 종류 코드 -> 아이콘 매핑 */ const SHIP_KIND_ICONS: Record = { [SIGNAL_KIND_CODE_FISHING]: fishingIcon, [SIGNAL_KIND_CODE_KCGV]: kcgvIcon, [SIGNAL_KIND_CODE_PASSENGER]: passIcon, [SIGNAL_KIND_CODE_CARGO]: cargoIcon, [SIGNAL_KIND_CODE_TANKER]: hazardIcon, [SIGNAL_KIND_CODE_GOV]: govIcon, [SIGNAL_KIND_CODE_NORMAL]: etcIcon, [SIGNAL_KIND_CODE_BUOY]: bouyIcon, }; interface LegendItemConfig { code: string; label: string; } /** * 범례 항목 설정 */ const LEGEND_ITEMS: LegendItemConfig[] = [ { code: SIGNAL_KIND_CODE_FISHING, label: '어선' }, { code: SIGNAL_KIND_CODE_PASSENGER, label: '여객선' }, { code: SIGNAL_KIND_CODE_CARGO, label: '화물선' }, { code: SIGNAL_KIND_CODE_TANKER, label: '유조선' }, { code: SIGNAL_KIND_CODE_GOV, label: '관공선' }, { code: SIGNAL_KIND_CODE_KCGV, label: '경비함정' }, { code: SIGNAL_KIND_CODE_BUOY, label: '어망/부이' }, { code: SIGNAL_KIND_CODE_NORMAL, label: '기타' }, ]; interface ReplayLegendItemProps { code: string; label: string; count: number; icon: string; isVisible: boolean; onToggle: (code: string) => void; } /** * 리플레이 범례 항목 */ const ReplayLegendItem = memo(function ReplayLegendItem({ code, label, count, icon, isVisible, onToggle }: ReplayLegendItemProps) { const isBuoy = code === SIGNAL_KIND_CODE_BUOY; return (
  • onToggle(code)}> {label} {label}
    {count}
  • ); }); /** * 리플레이 전용 범례 컴포넌트 */ const ReplayLegend = memo(function ReplayLegend() { const { replayShipCounts, replayTotalCount, shipKindCodeFilter } = useReplayStore( (state: { replayShipCounts: Record; replayTotalCount: number; shipKindCodeFilter: Set; }) => ({ replayShipCounts: state.replayShipCounts, replayTotalCount: state.replayTotalCount, shipKindCodeFilter: state.shipKindCodeFilter, }), shallow ); const toggleShipKindCode = useReplayStore((state: { toggleShipKindCode: (code: string) => void }) => state.toggleShipKindCode); return (
    {/* 헤더 */}
    리플레이 현황
    {/* 선박 종류별 목록 */}
      {LEGEND_ITEMS.map((item) => ( ))}
    {/* 푸터 - 전체 카운트 */}
    전체 {replayTotalCount}
    ); }); export default ReplayLegend;