Files
hanarang-dashboard/frontend/components/dashboard/ActivityFeed.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

116 lines
2.4 KiB
TypeScript

'use client';
import React from 'react';
import styled from 'styled-components';
import { theme } from '@/styles/theme';
interface ActivityItem {
id: number;
action: string;
detail: string | null;
createdAt: string;
sister?: { name: string } | null;
project?: { name: string } | null;
}
const actionEmojis: Record<string, string> = {
sprint_created: '📁',
task_updated: '✏️',
deploy_complete: '🚀',
ssh_check: '🔍',
pr_opened: '📋',
pr_merged: '✅',
};
function formatTime(iso: string): string {
const d = new Date(iso);
const diff = Date.now() - d.getTime();
const min = Math.floor(diff / 60000);
if (min < 1) return '방금';
if (min < 60) return `${min}분 전`;
const hr = Math.floor(min / 60);
if (hr < 24) return `${hr}시간 전`;
return `${Math.floor(hr / 24)}일 전`;
}
const List = styled.ul`
list-style: none;
display: flex;
flex-direction: column;
gap: 0;
`;
const Item = styled.li`
display: flex;
align-items: flex-start;
gap: 10px;
padding: 10px 0;
border-bottom: 1px solid ${theme.colors.border};
&:last-child {
border-bottom: none;
}
`;
const Emoji = styled.span`
font-size: 15px;
margin-top: 1px;
flex-shrink: 0;
`;
const Body = styled.div`
flex: 1;
min-width: 0;
`;
const Action = styled.div`
font-size: 13px;
color: ${theme.colors.textPrimary};
margin-bottom: 2px;
`;
const Detail = styled.div`
font-size: 12px;
color: ${theme.colors.textSecondary};
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
`;
const Time = styled.span`
font-size: 11px;
color: ${theme.colors.textSecondary};
flex-shrink: 0;
margin-top: 2px;
`;
const Empty = styled.div`
padding: 24px;
text-align: center;
color: ${theme.colors.textSecondary};
font-size: 13px;
`;
export default function ActivityFeed({ items }: { items: ActivityItem[] }) {
if (!items.length) return <Empty> </Empty>;
return (
<List>
{items.map((item) => (
<Item key={item.id}>
<Emoji>{actionEmojis[item.action] ?? '📝'}</Emoji>
<Body>
<Action>
{item.sister && <strong>{item.sister.name}</strong>}
{item.sister && ' · '}
{item.action.replace(/_/g, ' ')}
</Action>
{item.detail && <Detail>{item.detail}</Detail>}
</Body>
<Time>{formatTime(item.createdAt)}</Time>
</Item>
))}
</List>
);
}