import type { ReactNode } from 'react'; import { DataTable } from '@/components/ui/data-table'; import { renderEmphasis } from '@/lib/emphasis'; import type { NegotiationCard } from '../types'; type CardTableProps = { data: NegotiationCard[]; onEdit: (card: NegotiationCard) => void; footer?: ReactNode; }; export function CardTable({ data, onEdit, footer }: CardTableProps) { return ( card.id} onRowClick={onEdit} empty="데이터가 없습니다." footer={footer} columns={[ { header: '구분', headClassName: 'w-24', cell: (card) => (
{card.isWildcard ? ( 와일드카드 ) : ( 협상카드 )} {card.isShared && ( 전체 )}
), }, { header: '카드번호', headClassName: 'w-28', cellClassName: 'font-mono font-semibold text-foreground', cell: (card) => card.code, }, { header: '카드이름', headClassName: 'w-52', mobileHeader: true, // 모바일 카드뷰 제목(첫 컬럼 '구분' 배지 대신) cell: (card) => ( <>
{card.title}
{card.memo && (
{card.memo}
)} ), }, { header: '스크립트', headClassName: 'w-[22rem]', // 컬럼 폭 고정 → 긴 스크립트가 표를 늘리지 않게 cellClassName: 'font-mono text-muted-foreground', mobileBlock: true, // 긴 미리보기 블록 → 모바일 카드뷰에서 라벨 아래 풀폭 cell: (card) => (
{/* 마커(**굵게**·{{색}})를 스타일로 렌더 — 표 미리보기에 원시 마커가 보이지 않게 */} {renderEmphasis(card.scriptPreview)}
), }, { header: '사용 조건 (와일드 전용)', headClassName: 'w-40', cellClassName: 'font-mono text-xs font-semibold text-rose-600 dark:text-rose-400', cell: (card) => (card.isWildcard ? card.triggerCondition || '조건 없음' : '-'), }, { header: '상태', align: 'center', headClassName: 'w-24', cell: (card) => card.isWildcard ? ( {card.status === 'ACTIVE' ? '협상적용 가능' : '적용 대기(수동)'} ) : ( - ), }, { header: '작성자', align: 'center', headClassName: 'w-24', cellClassName: 'text-muted-foreground whitespace-nowrap', cell: (card) => (card.isShared ? '공용' : card.creatorName ?? '-'), }, ]} /> ); }