Files
hanarang-dashboard/frontend/components/projects/TaskTable.tsx
narang-ai 52732e88b9 feat(sprint-002): projects + task ledger + activity feed
Sprint 001 non-blocking 해결:
- N6: npm audit high 패키지 업데이트 (@nestjs/config, @nestjs/cli)
- S1: CORS origin 화이트리스트 (CORS_ORIGINS env)
- S3: DATABASE_URL 미설정 시 즉시 throw
- N2: SSH_KEY_PATH 미설정 시 즉시 throw (하드코딩 fallback 제거)
- N3: API 응답에서 내부 IP 제거
- N7: SshService 에러 메시지 마스킹 (IP 노출 차단)
- N4: theme.ts 색상 SisterCard/StatusBadge에 실제 적용
- N5: Sidebar-MainContent margin 연동 (SidebarContext)
- N9: LayoutShell Client 컴포넌트로 분리

Sprint 002 본문:
- TASK-004: GiteaService (org repo 목록, PR 조회)
- TASK-004: GET /api/projects → Gitea + DB 병합
- TASK-004: GET /api/projects/:id → 상세 + open PRs
- TASK-005: GET /api/projects/:id/tasks → Sprint/Task Ledger
- TASK-005: POST /api/projects/:id/sprints → Sprint 생성
- TASK-005: PATCH /api/tasks/:id → Task 상태 업데이트 + ActivityLog
- TASK-006: GET /api/activity, /api/projects/:id/activity
- TASK-007: /projects/[id] 상세 페이지 (SprintAccordion + TaskTable + 활동탭)
- TASK-007: 메인 대시보드에 프로젝트 섹션 + 활동 피드 추가
- 테스트 11/11 pass
2026-04-04 11:34:04 +09:00

130 lines
3.3 KiB
TypeScript

'use client';
import React, { useState } from 'react';
import styled from 'styled-components';
import TaskBadge from '../common/TaskBadge';
import { theme } from '@/styles/theme';
interface Task {
id: number;
taskId: string;
title: string;
assignee: string;
status: string;
iteration: number;
createdAt: string;
}
const ALL_STATUSES = ['all', 'pending', 'in_progress', 'review', 'done', 'failed', 'blocked', 'escalated'];
const Wrapper = styled.div``;
const Filters = styled.div`
display: flex;
gap: 6px;
margin-bottom: 16px;
flex-wrap: wrap;
`;
const FilterBtn = styled.button<{ $active: boolean }>`
padding: 4px 10px;
border-radius: 6px;
border: 1px solid ${({ $active }) => $active ? theme.colors.accent : theme.colors.border};
background: ${({ $active }) => $active ? 'rgba(88,166,255,0.12)' : 'transparent'};
color: ${({ $active }) => $active ? theme.colors.accent : theme.colors.textSecondary};
font-size: 12px;
cursor: pointer;
transition: all 0.15s;
&:hover { border-color: ${theme.colors.accent}; color: ${theme.colors.accent}; }
`;
const Table = styled.table`
width: 100%;
border-collapse: collapse;
`;
const Th = styled.th`
text-align: left;
padding: 8px 12px;
font-size: 12px;
font-weight: 600;
color: ${theme.colors.textSecondary};
border-bottom: 1px solid ${theme.colors.border};
text-transform: uppercase;
letter-spacing: 0.05em;
`;
const Td = styled.td`
padding: 10px 12px;
font-size: 13px;
border-bottom: 1px solid ${theme.colors.border};
color: ${theme.colors.textPrimary};
`;
const Tr = styled.tr`
&:last-child td { border-bottom: none; }
&:hover td { background: rgba(240,246,252,0.03); }
`;
const TaskIdCell = styled.code`
color: ${theme.colors.accent};
font-family: monospace;
font-size: 12px;
`;
const IterationCell = styled.span<{ $count: number }>`
color: ${({ $count }) => $count > 0 ? '#FF9800' : theme.colors.textSecondary};
`;
const Empty = styled.div`
padding: 32px;
text-align: center;
color: ${theme.colors.textSecondary};
font-size: 13px;
`;
export default function TaskTable({ tasks }: { tasks: Task[] }) {
const [filter, setFilter] = useState('all');
const filtered = filter === 'all' ? tasks : tasks.filter((t) => t.status === filter);
return (
<Wrapper>
<Filters>
{ALL_STATUSES.map((s) => (
<FilterBtn key={s} $active={filter === s} onClick={() => setFilter(s)}>
{s === 'all' ? '전체' : s}
</FilterBtn>
))}
</Filters>
{filtered.length === 0 ? (
<Empty> </Empty>
) : (
<Table>
<thead>
<tr>
<Th>ID</Th>
<Th></Th>
<Th></Th>
<Th></Th>
<Th></Th>
</tr>
</thead>
<tbody>
{filtered.map((task) => (
<Tr key={task.id}>
<Td><TaskIdCell>{task.taskId}</TaskIdCell></Td>
<Td>{task.title}</Td>
<Td>{task.assignee}</Td>
<Td><TaskBadge status={task.status as any} /></Td>
<Td><IterationCell $count={task.iteration}>{task.iteration || '-'}</IterationCell></Td>
</Tr>
))}
</tbody>
</Table>
)}
</Wrapper>
);
}