'use client'; import { useEffect, useState } from 'react'; import { Eye, Pencil, Play, History, Zap, LayoutDashboard, Save, Undo2, FolderOpen, Search, X, } from 'lucide-react'; import { useControlMode } from '../hooks/useControlMode'; import { listPresence, type PresenceUser } from '@/lib/api/control'; interface ContextBarProps { selectedCard: Record; onExit: () => void; // 카드 닫기 (제어 유지) onCtrlExit: () => void; // 제어 종료 } const MODE_TABS = [ { k: 'view' as const, Ic: Eye, label: 'READ' }, { k: 'edit' as const, Ic: Pencil, label: 'EDIT' }, { k: 'run' as const, Ic: Play, label: 'RUN' }, { k: 'history' as const, Ic: History, label: 'HISTORY' }, ]; export function ContextBar({ selectedCard, onExit, onCtrlExit }: ContextBarProps) { const mode = useControlMode((s) => s.mode); const setMode = useControlMode((s) => s.setMode); const [presence, setPresence] = useState([]); useEffect(() => { let alive = true; listPresence('').then((p) => { if (alive) setPresence(p); }); return () => { alive = false; }; }, []); const tableName = selectedCard.primary_table ?? selectedCard.PRIMARY_TABLE ?? ''; const cardTitle = selectedCard.title ?? selectedCard.TITLE ?? '카드'; const dirtyCount = 0; // TODO 단계 6에서 store 도입 return (
{/* 좌측 — 배지 + brumb */}
CONTROL IDE
/ /
{cardTitle} {tableName && {tableName}}
{/* presence stack — 빈 배열이면 미렌더 */} {presence.length > 0 && ( <>
{presence.slice(0, 4).map((p, i) => ( {p.short} ))} {presence.length > 4 && ( +{presence.length - 4} )}
); }