feat(frontend): Implement Epic detail page with Story management

Add comprehensive Epic detail page at /epics/[id] with full CRUD operations.

Changes:
- Created Epic detail page with breadcrumb navigation
- Display Epic details: name, description, status, priority, time estimates
- Show list of Stories belonging to the Epic with card view
- Add Edit Epic functionality (opens dialog with form)
- Add Create/Edit/Delete Story functionality under Epic
- Fix Epic type inconsistency (name vs title) across components
- Update Kanban page to map Epic.name to title for unified interface
- Update epic-form to use 'name' field and add createdBy support
- Update work-item-breadcrumb to use Epic.name instead of title

Technical improvements:
- Use Shadcn UI components for consistent design
- Implement optimistic updates with React Query
- Add loading and error states with skeletons
- Follow Next.js App Router patterns with async params
- Add delete confirmation dialogs for Epic and Stories

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Yaojia Wang
2025-11-05 14:56:29 +01:00
parent 04ba00d108
commit 2a0394b5ab
4 changed files with 552 additions and 10 deletions

View File

@@ -26,13 +26,14 @@ import { useCreateEpic, useUpdateEpic } from '@/lib/hooks/use-epics';
import type { Epic, WorkItemPriority } from '@/types/project';
import { toast } from 'sonner';
import { Loader2 } from 'lucide-react';
import { useAuthStore } from '@/stores/authStore';
const epicSchema = z.object({
projectId: z.string().min(1, 'Project is required'),
title: z
name: z
.string()
.min(1, 'Title is required')
.max(200, 'Title must be less than 200 characters'),
.min(1, 'Name is required')
.max(200, 'Name must be less than 200 characters'),
description: z
.string()
.max(2000, 'Description must be less than 2000 characters')
@@ -58,12 +59,13 @@ export function EpicForm({ epic, projectId, onSuccess, onCancel }: EpicFormProps
const isEditing = !!epic;
const createEpic = useCreateEpic();
const updateEpic = useUpdateEpic();
const user = useAuthStore((state) => state.user);
const form = useForm<EpicFormValues>({
resolver: zodResolver(epicSchema),
defaultValues: {
projectId: epic?.projectId || projectId || '',
title: epic?.title || '',
name: epic?.name || '',
description: epic?.description || '',
priority: epic?.priority || 'Medium',
estimatedHours: epic?.estimatedHours || ('' as any),
@@ -72,11 +74,16 @@ export function EpicForm({ epic, projectId, onSuccess, onCancel }: EpicFormProps
async function onSubmit(data: EpicFormValues) {
try {
if (!user?.id) {
toast.error('User not authenticated');
return;
}
if (isEditing && epic) {
await updateEpic.mutateAsync({
id: epic.id,
data: {
title: data.title,
name: data.name,
description: data.description,
priority: data.priority,
estimatedHours:
@@ -87,11 +94,12 @@ export function EpicForm({ epic, projectId, onSuccess, onCancel }: EpicFormProps
} else {
await createEpic.mutateAsync({
projectId: data.projectId,
title: data.title,
name: data.name,
description: data.description,
priority: data.priority,
estimatedHours:
typeof data.estimatedHours === 'number' ? data.estimatedHours : undefined,
createdBy: user.id,
});
toast.success('Epic created successfully');
}
@@ -109,14 +117,14 @@ export function EpicForm({ epic, projectId, onSuccess, onCancel }: EpicFormProps
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
<FormField
control={form.control}
name="title"
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Epic Title *</FormLabel>
<FormLabel>Epic Name *</FormLabel>
<FormControl>
<Input placeholder="e.g., User Authentication System" {...field} />
</FormControl>
<FormDescription>A clear, concise title for this epic</FormDescription>
<FormDescription>A clear, concise name for this epic</FormDescription>
<FormMessage />
</FormItem>
)}