Files
ColaFlow-Web/components/features/kanban/KanbanBoard.tsx
Yaojia Wang ea67d90880 fix(frontend): Fix critical type safety issues from code review
Address all Critical and High Priority issues identified in frontend code review report:

Critical Issues Fixed:
- Created unified logger utility (lib/utils/logger.ts) to replace all console.log statements
- Consolidated User type definitions - removed duplicate from authStore, using single source from types/user.ts
- Eliminated 'any' types in API client - added proper generic types with AxiosRequestConfig
- Fixed SignalR ConnectionManager - replaced 'any' with generic types <T>
- Created API error types (lib/types/errors.ts) with ApiError and getErrorMessage helper
- Fixed IssueCard component - removed all type assertions, created discriminated union types for Kanban items
- Added React.memo to IssueCard for performance optimization
- Added proper ARIA labels and accessibility attributes to IssueCard

High Priority Issues Fixed:
- Fixed hardcoded user ID in CreateProjectDialog - now uses actual user from authStore
- Added useCallback to CreateProjectDialog onSubmit handler
- Fixed error handlers in use-epics.ts - replaced 'any' with ApiError type
- Updated all error handling to use logger and getErrorMessage

Type Safety Improvements:
- Created KanbanItem discriminated union (KanbanEpic | KanbanStory | KanbanTask) with proper type guards
- Added 'never' types to prevent invalid property access
- Fixed User interface to include all required fields (createdAt, updatedAt)
- Maintained backward compatibility with LegacyKanbanBoard for existing code

Files Changed:
- lib/utils/logger.ts - New centralized logging utility
- lib/types/errors.ts - New API error types and helpers
- types/user.ts - Consolidated User type with TenantRole
- types/kanban.ts - New discriminated union types for type-safe Kanban items
- components/features/kanban/IssueCard.tsx - Type-safe with React.memo
- components/features/projects/CreateProjectDialog.tsx - Fixed hardcoded user ID, added useCallback
- lib/api/client.ts - Eliminated 'any', added proper generics
- lib/signalr/ConnectionManager.ts - Replaced console.log, added generics
- lib/hooks/use-epics.ts - Fixed error handler types
- stores/authStore.ts - Removed duplicate User type
- lib/hooks/useAuth.ts - Added createdAt field to User

TypeScript compilation:  All type checks passing (0 errors)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 19:11:48 +01:00

52 lines
1.9 KiB
TypeScript

'use client';
import { TaskCard } from './TaskCard';
import type { LegacyKanbanBoard } from '@/types/kanban';
interface KanbanBoardProps {
board: LegacyKanbanBoard;
}
// Legacy KanbanBoard component using old Kanban type
// For new Issue-based Kanban, use the page at /projects/[id]/kanban
export function KanbanBoard({ board }: KanbanBoardProps) {
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
<h2 className="text-2xl font-bold">{board.projectName}</h2>
<p className="text-sm text-muted-foreground">
Total tasks: {board.columns.reduce((acc, col) => acc + col.tasks.length, 0)}
</p>
</div>
<div className="flex gap-4 overflow-x-auto pb-4">
{board.columns.map((column) => (
<div
key={column.status}
className="flex min-w-[300px] flex-col rounded-lg border-2 bg-muted/50 p-4"
>
<div className="mb-4 flex items-center justify-between">
<h3 className="font-semibold">{column.title}</h3>
<span className="rounded-full bg-background px-2 py-0.5 text-xs font-medium">
{column.tasks.length}
</span>
</div>
<div className="flex-1 space-y-3">
{column.tasks.map((task) => (
<TaskCard key={task.id} task={task} />
))}
{column.tasks.length === 0 && (
<div className="flex h-32 items-center justify-center rounded-lg border-2 border-dashed border-muted-foreground/25">
<p className="text-sm text-muted-foreground">No tasks</p>
</div>
)}
</div>
</div>
))}
</div>
<p className="text-xs text-muted-foreground">
Note: Drag-and-drop functionality will be implemented in Sprint 2
</p>
</div>
);
}