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
2025-11-02 20:24:08 +01:00
2025-11-03 00:04:07 +01:00
2025-11-03 00:04:07 +01:00
2025-11-03 00:04:07 +01:00

ColaFlow Web

AI-Powered Project Management System - Frontend

Tech Stack

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript 5.x
  • UI Components: shadcn/ui + Radix UI
  • Styling: Tailwind CSS 4
  • State Management:
    • TanStack Query v5 (server state)
    • Zustand (client state)
  • Form Handling: React Hook Form + Zod
  • Icons: Lucide React

Project Structure

colaflow-web/
├── app/                    # Next.js App Router
│   ├── (auth)/            # Authentication routes
│   ├── (dashboard)/       # Main application routes
│   │   ├── dashboard/     # Dashboard page
│   │   ├── projects/      # Projects management
│   │   └── kanban/        # Kanban board
│   ├── layout.tsx         # Root layout
│   └── page.tsx           # Home page (redirects to dashboard)
├── components/
│   ├── ui/                # shadcn/ui components
│   ├── features/          # Feature-specific components
│   │   ├── projects/      # Project components
│   │   └── kanban/        # Kanban components
│   └── layout/            # Layout components (Header, Sidebar)
├── lib/
│   ├── api/              # API client and endpoints
│   ├── hooks/            # Custom React hooks
│   ├── providers/        # Context providers
│   └── utils.ts          # Utility functions
├── stores/               # Zustand stores
├── types/                # TypeScript type definitions
└── public/               # Static assets

Getting Started

Prerequisites

  • Node.js 20 LTS or higher
  • npm or yarn

Installation

  1. Install dependencies:
npm install
  1. Create .env.local file:
NEXT_PUBLIC_API_URL=http://localhost:5000/api/v1

Development

Start the development server:

npm run dev

Open http://localhost:3000 in your browser.

Build

Build the production application:

npm run build

Linting & Formatting

# Run ESLint
npm run lint

# Format code with Prettier
npm run format

Features Implemented (Sprint 1)

Core Pages

  • Dashboard with project overview
  • Projects list page with search and filtering
  • Project detail page
  • Kanban board (static, drag-and-drop in Sprint 2)

Components

  • Responsive layout with sidebar navigation
  • Project creation dialog with form validation
  • Kanban board with column and task cards
  • shadcn/ui integration (Button, Card, Dialog, Form, Input, Table)

State Management

  • TanStack Query for server state
  • Zustand for UI state (sidebar, theme, modals, notifications)
  • Custom hooks for projects and kanban

API Integration

  • Type-safe API client with error handling
  • Projects API endpoints
  • Kanban board API integration

TypeScript Types

All API responses and data models are fully typed:

  • types/project.ts - Project, Epic, Story, Task types
  • types/kanban.ts - Kanban board types
  • types/user.ts - User and authentication types

API Endpoints

The frontend expects the following API endpoints:

  • GET /api/v1/projects - List all projects
  • POST /api/v1/projects - Create project
  • GET /api/v1/projects/{id} - Get project details
  • PUT /api/v1/projects/{id} - Update project
  • DELETE /api/v1/projects/{id} - Delete project
  • GET /api/v1/projects/{id}/kanban - Get kanban board

Environment Variables

Variable Description Default
NEXT_PUBLIC_API_URL Backend API URL http://localhost:5000/api/v1

Next Steps (Sprint 2)

  • Implement drag-and-drop for Kanban board
  • Add task creation and editing
  • Implement authentication (login/register)
  • Add user profile management
  • Implement real-time updates with SignalR
  • Add workflow customization
  • Implement audit logs viewer

Architecture Reference

For complete architecture details, see: docs/M1-Architecture-Design.md

License

Proprietary - ColaFlow Project

Description
No description provided
Readme 1.1 MiB
Languages
TypeScript 97.9%
CSS 1.1%
Dockerfile 0.6%
JavaScript 0.4%