Compare commits
6 Commits
d9228057bb
...
f2aa3b03b6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f2aa3b03b6 | ||
|
|
79f210d0ee | ||
|
|
777f94bf13 | ||
|
|
8022c0517f | ||
|
|
8fe6d64e2e | ||
|
|
f7a17a3d1a |
53
app/(dashboard)/stories/[id]/error.tsx
Normal file
53
app/(dashboard)/stories/[id]/error.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
'use client';
|
||||
|
||||
import { useEffect } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Card,
|
||||
CardContent,
|
||||
CardDescription,
|
||||
CardHeader,
|
||||
CardTitle,
|
||||
} from '@/components/ui/card';
|
||||
import { AlertCircle } from 'lucide-react';
|
||||
|
||||
export default function StoryDetailError({
|
||||
error,
|
||||
reset,
|
||||
}: {
|
||||
error: Error & { digest?: string };
|
||||
reset: () => void;
|
||||
}) {
|
||||
useEffect(() => {
|
||||
// Log the error to an error reporting service
|
||||
console.error('Story detail page error:', error);
|
||||
}, [error]);
|
||||
|
||||
return (
|
||||
<div className="flex items-center justify-center min-h-[400px] p-4">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader>
|
||||
<div className="flex items-center gap-2">
|
||||
<AlertCircle className="h-5 w-5 text-destructive" />
|
||||
<CardTitle className="text-destructive">Error Loading Story</CardTitle>
|
||||
</div>
|
||||
<CardDescription>
|
||||
{error.message || 'An unexpected error occurred while loading the story.'}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="flex flex-col gap-2">
|
||||
<Button onClick={() => reset()} className="w-full">
|
||||
Try Again
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => window.history.back()}
|
||||
variant="outline"
|
||||
className="w-full"
|
||||
>
|
||||
Go Back
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
66
app/(dashboard)/stories/[id]/loading.tsx
Normal file
66
app/(dashboard)/stories/[id]/loading.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Card, CardContent, CardHeader } from '@/components/ui/card';
|
||||
|
||||
export default function StoryDetailLoading() {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Breadcrumb Skeleton */}
|
||||
<Skeleton className="h-5 w-96" />
|
||||
|
||||
{/* Header Skeleton */}
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="space-y-4 flex-1">
|
||||
<Skeleton className="h-10 w-3/4" />
|
||||
<div className="flex gap-2">
|
||||
<Skeleton className="h-6 w-20" />
|
||||
<Skeleton className="h-6 w-20" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Skeleton className="h-10 w-32" />
|
||||
<Skeleton className="h-10 w-24" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Two-column layout Skeleton */}
|
||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
||||
{/* Main Content */}
|
||||
<div className="lg:col-span-2 space-y-6">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<Skeleton className="h-6 w-32" />
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<Skeleton className="h-4 w-full" />
|
||||
<Skeleton className="h-4 w-full" />
|
||||
<Skeleton className="h-4 w-3/4" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<Skeleton className="h-6 w-24" />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Skeleton className="h-32 w-full" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Sidebar */}
|
||||
<div className="space-y-4">
|
||||
{Array.from({ length: 5 }).map((_, i) => (
|
||||
<Card key={i}>
|
||||
<CardHeader className="pb-3">
|
||||
<Skeleton className="h-5 w-20" />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Skeleton className="h-10 w-full" />
|
||||
</CardContent>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
516
app/(dashboard)/stories/[id]/page.tsx
Normal file
516
app/(dashboard)/stories/[id]/page.tsx
Normal file
@@ -0,0 +1,516 @@
|
||||
"use client";
|
||||
|
||||
import { use, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import {
|
||||
ArrowLeft,
|
||||
Edit,
|
||||
Trash2,
|
||||
Loader2,
|
||||
Clock,
|
||||
Calendar,
|
||||
User,
|
||||
Layers,
|
||||
CheckCircle2,
|
||||
Tag,
|
||||
Target,
|
||||
} from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from "@/components/ui/dialog";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogAction,
|
||||
AlertDialogCancel,
|
||||
AlertDialogContent,
|
||||
AlertDialogDescription,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogTitle,
|
||||
} from "@/components/ui/alert-dialog";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import {
|
||||
useStory,
|
||||
useUpdateStory,
|
||||
useDeleteStory,
|
||||
useChangeStoryStatus,
|
||||
} from "@/lib/hooks/use-stories";
|
||||
import { useEpic } from "@/lib/hooks/use-epics";
|
||||
import { useProject } from "@/lib/hooks/use-projects";
|
||||
import { StoryForm } from "@/components/projects/story-form";
|
||||
import { TaskList } from "@/components/tasks/task-list";
|
||||
import { formatDistanceToNow } from "date-fns";
|
||||
import { toast } from "sonner";
|
||||
import type { WorkItemStatus, WorkItemPriority } from "@/types/project";
|
||||
|
||||
interface StoryDetailPageProps {
|
||||
params: Promise<{ id: string }>;
|
||||
}
|
||||
|
||||
export default function StoryDetailPage({ params }: StoryDetailPageProps) {
|
||||
const { id: storyId } = use(params);
|
||||
const router = useRouter();
|
||||
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false);
|
||||
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false);
|
||||
|
||||
const { data: story, isLoading: storyLoading, error: storyError } = useStory(storyId);
|
||||
const { data: epic, isLoading: epicLoading } = useEpic(story?.epicId || "");
|
||||
const { data: project, isLoading: projectLoading } = useProject(story?.projectId || "");
|
||||
const updateStory = useUpdateStory();
|
||||
const deleteStory = useDeleteStory();
|
||||
const changeStatus = useChangeStoryStatus();
|
||||
|
||||
const handleDeleteStory = async () => {
|
||||
try {
|
||||
await deleteStory.mutateAsync(storyId);
|
||||
toast.success("Story deleted successfully");
|
||||
// Navigate back to epic detail page
|
||||
router.push(`/epics/${story?.epicId}`);
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Failed to delete story";
|
||||
toast.error(message);
|
||||
}
|
||||
};
|
||||
|
||||
const handleStatusChange = async (status: WorkItemStatus) => {
|
||||
if (!story) return;
|
||||
try {
|
||||
await changeStatus.mutateAsync({ id: storyId, status });
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Failed to update status";
|
||||
toast.error(message);
|
||||
}
|
||||
};
|
||||
|
||||
const handlePriorityChange = async (priority: WorkItemPriority) => {
|
||||
if (!story) return;
|
||||
try {
|
||||
await updateStory.mutateAsync({
|
||||
id: storyId,
|
||||
data: { priority },
|
||||
});
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : "Failed to update priority";
|
||||
toast.error(message);
|
||||
}
|
||||
};
|
||||
|
||||
const getStatusColor = (status: WorkItemStatus) => {
|
||||
switch (status) {
|
||||
case "Backlog":
|
||||
return "secondary";
|
||||
case "Todo":
|
||||
return "outline";
|
||||
case "InProgress":
|
||||
return "default";
|
||||
case "Done":
|
||||
return "default";
|
||||
default:
|
||||
return "secondary";
|
||||
}
|
||||
};
|
||||
|
||||
const getPriorityColor = (priority: WorkItemPriority) => {
|
||||
switch (priority) {
|
||||
case "Low":
|
||||
return "bg-blue-100 text-blue-700 hover:bg-blue-100";
|
||||
case "Medium":
|
||||
return "bg-yellow-100 text-yellow-700 hover:bg-yellow-100";
|
||||
case "High":
|
||||
return "bg-orange-100 text-orange-700 hover:bg-orange-100";
|
||||
case "Critical":
|
||||
return "bg-red-100 text-red-700 hover:bg-red-100";
|
||||
default:
|
||||
return "secondary";
|
||||
}
|
||||
};
|
||||
|
||||
// Loading state
|
||||
if (storyLoading || epicLoading || projectLoading) {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<Skeleton className="h-10 w-96" />
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex-1 space-y-4">
|
||||
<Skeleton className="h-12 w-1/2" />
|
||||
<Skeleton className="h-20 w-full" />
|
||||
</div>
|
||||
<Skeleton className="h-10 w-32" />
|
||||
</div>
|
||||
<Skeleton className="h-64 w-full" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Error state
|
||||
if (storyError || !story) {
|
||||
return (
|
||||
<div className="flex min-h-[400px] items-center justify-center">
|
||||
<Card className="w-full max-w-md">
|
||||
<CardHeader>
|
||||
<CardTitle className="text-destructive">Error Loading Story</CardTitle>
|
||||
<CardDescription>
|
||||
{storyError instanceof Error ? storyError.message : "Story not found"}
|
||||
</CardDescription>
|
||||
</CardHeader>
|
||||
<CardContent className="flex gap-2">
|
||||
<Button onClick={() => router.back()}>Go Back</Button>
|
||||
<Button onClick={() => window.location.reload()} variant="outline">
|
||||
Retry
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Breadcrumb Navigation */}
|
||||
<div className="text-muted-foreground flex items-center gap-2 text-sm">
|
||||
<Link href="/projects" className="hover:text-foreground">
|
||||
Projects
|
||||
</Link>
|
||||
<span>/</span>
|
||||
{project && (
|
||||
<>
|
||||
<Link href={`/projects/${project.id}`} className="hover:text-foreground">
|
||||
{project.name}
|
||||
</Link>
|
||||
<span>/</span>
|
||||
</>
|
||||
)}
|
||||
<Link href={`/projects/${story.projectId}/epics`} className="hover:text-foreground">
|
||||
Epics
|
||||
</Link>
|
||||
<span>/</span>
|
||||
{epic && (
|
||||
<>
|
||||
<Link href={`/epics/${epic.id}`} className="hover:text-foreground">
|
||||
{epic.name}
|
||||
</Link>
|
||||
<span>/</span>
|
||||
</>
|
||||
)}
|
||||
<span className="text-foreground">Stories</span>
|
||||
<span>/</span>
|
||||
<span className="text-foreground max-w-[200px] truncate" title={story.title}>
|
||||
{story.title}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{/* Header */}
|
||||
<div className="flex items-start justify-between gap-4">
|
||||
<div className="flex-1 space-y-2">
|
||||
<div className="flex items-center gap-3">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
onClick={() => router.push(`/epics/${story.epicId}`)}
|
||||
title="Back to Epic"
|
||||
>
|
||||
<ArrowLeft className="h-5 w-5" />
|
||||
</Button>
|
||||
<div className="flex-1">
|
||||
<h1 className="text-3xl font-bold tracking-tight">{story.title}</h1>
|
||||
<div className="mt-2 flex flex-wrap items-center gap-2">
|
||||
<Badge variant={getStatusColor(story.status)}>{story.status}</Badge>
|
||||
<Badge className={getPriorityColor(story.priority)}>{story.priority}</Badge>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" onClick={() => setIsEditDialogOpen(true)}>
|
||||
<Edit className="mr-2 h-4 w-4" />
|
||||
Edit Story
|
||||
</Button>
|
||||
<Button variant="destructive" onClick={() => setIsDeleteDialogOpen(true)}>
|
||||
<Trash2 className="mr-2 h-4 w-4" />
|
||||
Delete
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Two-column layout */}
|
||||
<div className="grid grid-cols-1 gap-6 lg:grid-cols-3">
|
||||
{/* Main Content Area (2/3 width) */}
|
||||
<div className="space-y-6 lg:col-span-2">
|
||||
{/* Story Details Card */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Story Details</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{story.description ? (
|
||||
<div>
|
||||
<h3 className="text-muted-foreground mb-2 text-sm font-medium">Description</h3>
|
||||
<p className="text-sm whitespace-pre-wrap">{story.description}</p>
|
||||
</div>
|
||||
) : (
|
||||
<p className="text-muted-foreground text-sm italic">No description</p>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Tasks Section - Sprint 4 Story 2 */}
|
||||
<TaskList storyId={storyId} />
|
||||
</div>
|
||||
|
||||
{/* Metadata Sidebar (1/3 width) */}
|
||||
<div className="space-y-4">
|
||||
{/* Status */}
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm font-medium">Status</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Select
|
||||
value={story.status}
|
||||
onValueChange={(value) => handleStatusChange(value as WorkItemStatus)}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="Backlog">Backlog</SelectItem>
|
||||
<SelectItem value="Todo">Todo</SelectItem>
|
||||
<SelectItem value="InProgress">In Progress</SelectItem>
|
||||
<SelectItem value="Done">Done</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Priority */}
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm font-medium">Priority</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Select
|
||||
value={story.priority}
|
||||
onValueChange={(value) => handlePriorityChange(value as WorkItemPriority)}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="Low">Low</SelectItem>
|
||||
<SelectItem value="Medium">Medium</SelectItem>
|
||||
<SelectItem value="High">High</SelectItem>
|
||||
<SelectItem value="Critical">Critical</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Story Points - Sprint 4 Story 3 */}
|
||||
{story.storyPoints && (
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm font-medium">Story Points</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="flex items-center gap-2">
|
||||
<Target className="text-muted-foreground h-4 w-4" />
|
||||
<span className="text-2xl font-semibold">{story.storyPoints}</span>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* Assignee */}
|
||||
{story.assigneeId && (
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm font-medium">Assignee</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="flex items-center gap-2">
|
||||
<User className="text-muted-foreground h-4 w-4" />
|
||||
<span className="text-sm">{story.assigneeId}</span>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* Tags - Sprint 4 Story 3 */}
|
||||
{story.tags && story.tags.length > 0 && (
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm font-medium">Tags</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{story.tags.map((tag) => (
|
||||
<Badge key={tag} variant="secondary" className="text-xs">
|
||||
<Tag className="mr-1 h-3 w-3" />
|
||||
{tag}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* Time Tracking */}
|
||||
{(story.estimatedHours !== undefined || story.actualHours !== undefined) && (
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm font-medium">Time Tracking</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
{story.estimatedHours !== undefined && (
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<Clock className="text-muted-foreground h-4 w-4" />
|
||||
<span>Estimated: {story.estimatedHours}h</span>
|
||||
</div>
|
||||
)}
|
||||
{story.actualHours !== undefined && (
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<Clock className="text-muted-foreground h-4 w-4" />
|
||||
<span>Actual: {story.actualHours}h</span>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* Acceptance Criteria - Sprint 4 Story 3 */}
|
||||
{story.acceptanceCriteria && story.acceptanceCriteria.length > 0 && (
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm font-medium">Acceptance Criteria</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
{story.acceptanceCriteria.map((criterion, index) => (
|
||||
<div key={index} className="flex items-start gap-2 text-sm">
|
||||
<CheckCircle2 className="text-muted-foreground mt-0.5 h-4 w-4 flex-shrink-0" />
|
||||
<span>{criterion}</span>
|
||||
</div>
|
||||
))}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* Dates */}
|
||||
<Card>
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm font-medium">Dates</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-2">
|
||||
<div className="flex items-start gap-2 text-sm">
|
||||
<Calendar className="text-muted-foreground mt-0.5 h-4 w-4" />
|
||||
<div className="flex-1">
|
||||
<p className="font-medium">Created</p>
|
||||
<p className="text-muted-foreground">
|
||||
{formatDistanceToNow(new Date(story.createdAt), { addSuffix: true })}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-start gap-2 text-sm">
|
||||
<Calendar className="text-muted-foreground mt-0.5 h-4 w-4" />
|
||||
<div className="flex-1">
|
||||
<p className="font-medium">Updated</p>
|
||||
<p className="text-muted-foreground">
|
||||
{formatDistanceToNow(new Date(story.updatedAt), { addSuffix: true })}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Parent Epic Card */}
|
||||
{epic && (
|
||||
<Card className="transition-shadow hover:shadow-lg">
|
||||
<CardHeader className="pb-3">
|
||||
<CardTitle className="text-sm font-medium">Parent Epic</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<Link
|
||||
href={`/epics/${epic.id}`}
|
||||
className="hover:bg-accent block space-y-2 rounded-md border p-3 transition-colors"
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<Layers className="text-muted-foreground h-4 w-4" />
|
||||
<span className="text-sm font-medium">{epic.name}</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge variant={getStatusColor(epic.status)} className="text-xs">
|
||||
{epic.status}
|
||||
</Badge>
|
||||
<Badge className={`${getPriorityColor(epic.priority)} text-xs`}>
|
||||
{epic.priority}
|
||||
</Badge>
|
||||
</div>
|
||||
</Link>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Edit Story Dialog */}
|
||||
<Dialog open={isEditDialogOpen} onOpenChange={setIsEditDialogOpen}>
|
||||
<DialogContent className="max-h-[90vh] max-w-2xl overflow-y-auto">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Edit Story</DialogTitle>
|
||||
<DialogDescription>Update the story details</DialogDescription>
|
||||
</DialogHeader>
|
||||
<StoryForm
|
||||
story={story}
|
||||
projectId={story.projectId}
|
||||
onSuccess={() => setIsEditDialogOpen(false)}
|
||||
onCancel={() => setIsEditDialogOpen(false)}
|
||||
/>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
|
||||
{/* Delete Story Confirmation Dialog */}
|
||||
<AlertDialog open={isDeleteDialogOpen} onOpenChange={setIsDeleteDialogOpen}>
|
||||
<AlertDialogContent>
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogTitle>Are you sure?</AlertDialogTitle>
|
||||
<AlertDialogDescription>
|
||||
This action cannot be undone. This will permanently delete the story and all its
|
||||
associated tasks.
|
||||
</AlertDialogDescription>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
||||
<AlertDialogAction
|
||||
onClick={handleDeleteStory}
|
||||
className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
|
||||
disabled={deleteStory.isPending}
|
||||
>
|
||||
{deleteStory.isPending ? (
|
||||
<>
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
Deleting...
|
||||
</>
|
||||
) : (
|
||||
"Delete Story"
|
||||
)}
|
||||
</AlertDialogAction>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogContent>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
96
components/projects/acceptance-criteria-editor.tsx
Normal file
96
components/projects/acceptance-criteria-editor.tsx
Normal file
@@ -0,0 +1,96 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { X, Plus } from 'lucide-react';
|
||||
|
||||
interface AcceptanceCriteriaEditorProps {
|
||||
criteria: string[];
|
||||
onChange: (criteria: string[]) => void;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
export function AcceptanceCriteriaEditor({
|
||||
criteria,
|
||||
onChange,
|
||||
disabled,
|
||||
}: AcceptanceCriteriaEditorProps) {
|
||||
const [newCriterion, setNewCriterion] = useState('');
|
||||
|
||||
const addCriterion = () => {
|
||||
if (newCriterion.trim()) {
|
||||
onChange([...criteria, newCriterion.trim()]);
|
||||
setNewCriterion('');
|
||||
}
|
||||
};
|
||||
|
||||
const removeCriterion = (index: number) => {
|
||||
onChange(criteria.filter((_, i) => i !== index));
|
||||
};
|
||||
|
||||
const handleKeyPress = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
addCriterion();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
{/* Existing criteria list */}
|
||||
{criteria.length > 0 && (
|
||||
<div className="space-y-2">
|
||||
{criteria.map((criterion, index) => (
|
||||
<div
|
||||
key={index}
|
||||
className="flex items-start gap-2 p-2 rounded-md border bg-muted/50"
|
||||
>
|
||||
<Checkbox checked disabled className="mt-0.5" />
|
||||
<span className="flex-1 text-sm">{criterion}</span>
|
||||
{!disabled && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="h-6 w-6 p-0"
|
||||
onClick={() => removeCriterion(index)}
|
||||
>
|
||||
<X className="h-3 w-3" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Add new criterion */}
|
||||
{!disabled && (
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
placeholder="Add acceptance criterion..."
|
||||
value={newCriterion}
|
||||
onChange={(e) => setNewCriterion(e.target.value)}
|
||||
onKeyPress={handleKeyPress}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={addCriterion}
|
||||
disabled={!newCriterion.trim()}
|
||||
>
|
||||
<Plus className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{criteria.length === 0 && disabled && (
|
||||
<p className="text-sm text-muted-foreground">
|
||||
No acceptance criteria defined
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
'use client';
|
||||
"use client";
|
||||
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import * as z from 'zod';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import * as z from "zod";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
@@ -12,39 +12,45 @@ import {
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
} from "@/components/ui/form";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Textarea } from "@/components/ui/textarea";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { useCreateStory, useUpdateStory } from '@/lib/hooks/use-stories';
|
||||
import { useEpics } from '@/lib/hooks/use-epics';
|
||||
import type { Story, WorkItemPriority } from '@/types/project';
|
||||
import { toast } from 'sonner';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
import { useAuthStore } from '@/stores/authStore';
|
||||
} from "@/components/ui/select";
|
||||
import { useCreateStory, useUpdateStory } from "@/lib/hooks/use-stories";
|
||||
import { useEpics } from "@/lib/hooks/use-epics";
|
||||
import type { Story } from "@/types/project";
|
||||
import { toast } from "sonner";
|
||||
import { Loader2 } from "lucide-react";
|
||||
import { useAuthStore } from "@/stores/authStore";
|
||||
import { AcceptanceCriteriaEditor } from "./acceptance-criteria-editor";
|
||||
import { TagsInput } from "./tags-input";
|
||||
|
||||
const storySchema = z.object({
|
||||
epicId: z.string().min(1, 'Parent Epic is required'),
|
||||
title: z
|
||||
.string()
|
||||
.min(1, 'Title is required')
|
||||
.max(200, 'Title must be less than 200 characters'),
|
||||
description: z
|
||||
.string()
|
||||
.max(2000, 'Description must be less than 2000 characters')
|
||||
.optional(),
|
||||
priority: z.enum(['Low', 'Medium', 'High', 'Critical']),
|
||||
epicId: z.string().min(1, "Parent Epic is required"),
|
||||
title: z.string().min(1, "Title is required").max(200, "Title must be less than 200 characters"),
|
||||
description: z.string().max(2000, "Description must be less than 2000 characters").optional(),
|
||||
priority: z.enum(["Low", "Medium", "High", "Critical"]),
|
||||
estimatedHours: z
|
||||
.number()
|
||||
.min(0, 'Estimated hours must be positive')
|
||||
.min(0, "Estimated hours must be positive")
|
||||
.optional()
|
||||
.or(z.literal('')),
|
||||
.or(z.literal("")),
|
||||
// Sprint 4 Story 3: New fields
|
||||
acceptanceCriteria: z.array(z.string()).optional(),
|
||||
assigneeId: z.string().optional(),
|
||||
tags: z.array(z.string()).optional(),
|
||||
storyPoints: z
|
||||
.number()
|
||||
.min(0, "Story points must be positive")
|
||||
.max(100, "Story points must be less than 100")
|
||||
.optional()
|
||||
.or(z.literal("")),
|
||||
});
|
||||
|
||||
type StoryFormValues = z.infer<typeof storySchema>;
|
||||
@@ -57,13 +63,7 @@ interface StoryFormProps {
|
||||
onCancel?: () => void;
|
||||
}
|
||||
|
||||
export function StoryForm({
|
||||
story,
|
||||
epicId,
|
||||
projectId,
|
||||
onSuccess,
|
||||
onCancel,
|
||||
}: StoryFormProps) {
|
||||
export function StoryForm({ story, epicId, projectId, onSuccess, onCancel }: StoryFormProps) {
|
||||
const isEditing = !!story;
|
||||
const user = useAuthStore((state) => state.user);
|
||||
const createStory = useCreateStory();
|
||||
@@ -75,11 +75,16 @@ export function StoryForm({
|
||||
const form = useForm<StoryFormValues>({
|
||||
resolver: zodResolver(storySchema),
|
||||
defaultValues: {
|
||||
epicId: story?.epicId || epicId || '',
|
||||
title: story?.title || '',
|
||||
description: story?.description || '',
|
||||
priority: story?.priority || 'Medium',
|
||||
estimatedHours: story?.estimatedHours || ('' as any),
|
||||
epicId: story?.epicId || epicId || "",
|
||||
title: story?.title || "",
|
||||
description: story?.description || "",
|
||||
priority: story?.priority || "Medium",
|
||||
estimatedHours: story?.estimatedHours || ("" as const),
|
||||
// Sprint 4 Story 3: New field defaults
|
||||
acceptanceCriteria: story?.acceptanceCriteria || [],
|
||||
assigneeId: story?.assigneeId || "",
|
||||
tags: story?.tags || [],
|
||||
storyPoints: story?.storyPoints || ("" as const),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -93,17 +98,22 @@ export function StoryForm({
|
||||
description: data.description,
|
||||
priority: data.priority,
|
||||
estimatedHours:
|
||||
typeof data.estimatedHours === 'number' ? data.estimatedHours : undefined,
|
||||
typeof data.estimatedHours === "number" ? data.estimatedHours : undefined,
|
||||
// Sprint 4 Story 3: New fields
|
||||
acceptanceCriteria: data.acceptanceCriteria,
|
||||
assigneeId: data.assigneeId || undefined,
|
||||
tags: data.tags,
|
||||
storyPoints: typeof data.storyPoints === "number" ? data.storyPoints : undefined,
|
||||
},
|
||||
});
|
||||
toast.success('Story updated successfully');
|
||||
toast.success("Story updated successfully");
|
||||
} else {
|
||||
if (!user?.id) {
|
||||
toast.error('User not authenticated');
|
||||
toast.error("User not authenticated");
|
||||
return;
|
||||
}
|
||||
if (!projectId) {
|
||||
toast.error('Project ID is required');
|
||||
toast.error("Project ID is required");
|
||||
return;
|
||||
}
|
||||
await createStory.mutateAsync({
|
||||
@@ -112,15 +122,19 @@ export function StoryForm({
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
priority: data.priority,
|
||||
estimatedHours:
|
||||
typeof data.estimatedHours === 'number' ? data.estimatedHours : undefined,
|
||||
estimatedHours: typeof data.estimatedHours === "number" ? data.estimatedHours : undefined,
|
||||
createdBy: user.id,
|
||||
// Sprint 4 Story 3: New fields
|
||||
acceptanceCriteria: data.acceptanceCriteria,
|
||||
assigneeId: data.assigneeId || undefined,
|
||||
tags: data.tags,
|
||||
storyPoints: typeof data.storyPoints === "number" ? data.storyPoints : undefined,
|
||||
});
|
||||
toast.success('Story created successfully');
|
||||
toast.success("Story created successfully");
|
||||
}
|
||||
onSuccess?.();
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : 'Operation failed';
|
||||
const message = error instanceof Error ? error.message : "Operation failed";
|
||||
toast.error(message);
|
||||
}
|
||||
}
|
||||
@@ -148,11 +162,9 @@ export function StoryForm({
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
{epicsLoading ? (
|
||||
<div className="p-2 text-sm text-muted-foreground">Loading epics...</div>
|
||||
<div className="text-muted-foreground p-2 text-sm">Loading epics...</div>
|
||||
) : epics.length === 0 ? (
|
||||
<div className="p-2 text-sm text-muted-foreground">
|
||||
No epics available
|
||||
</div>
|
||||
<div className="text-muted-foreground p-2 text-sm">No epics available</div>
|
||||
) : (
|
||||
epics.map((epic) => (
|
||||
<SelectItem key={epic.id} value={epic.id}>
|
||||
@@ -163,7 +175,7 @@ export function StoryForm({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormDescription>
|
||||
{isEditing ? 'Parent epic cannot be changed' : 'Select the parent epic'}
|
||||
{isEditing ? "Parent epic cannot be changed" : "Select the parent epic"}
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
@@ -199,9 +211,7 @@ export function StoryForm({
|
||||
{...field}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
Optional detailed description (max 2000 characters)
|
||||
</FormDescription>
|
||||
<FormDescription>Optional detailed description (max 2000 characters)</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
@@ -247,9 +257,9 @@ export function StoryForm({
|
||||
{...field}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
field.onChange(value === '' ? '' : parseFloat(value));
|
||||
field.onChange(value === "" ? "" : parseFloat(value));
|
||||
}}
|
||||
value={field.value === undefined ? '' : field.value}
|
||||
value={field.value === undefined ? "" : field.value}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription>Optional time estimate</FormDescription>
|
||||
@@ -259,20 +269,114 @@ export function StoryForm({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Sprint 4 Story 3: Acceptance Criteria */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="acceptanceCriteria"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Acceptance Criteria</FormLabel>
|
||||
<FormControl>
|
||||
<AcceptanceCriteriaEditor
|
||||
criteria={field.value || []}
|
||||
onChange={field.onChange}
|
||||
disabled={isLoading}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
Define conditions that must be met for this story to be complete
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Sprint 4 Story 3: Assignee and Story Points */}
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="assigneeId"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Assignee</FormLabel>
|
||||
<Select onValueChange={field.onChange} value={field.value} disabled={isLoading}>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Unassigned" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="">Unassigned</SelectItem>
|
||||
{user?.id && <SelectItem value={user.id}>{user.fullName || "Me"}</SelectItem>}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormDescription>Assign to team member</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="storyPoints"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Story Points</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="number"
|
||||
placeholder="e.g., 5"
|
||||
min="0"
|
||||
max="100"
|
||||
step="1"
|
||||
{...field}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
field.onChange(value === "" ? "" : parseInt(value));
|
||||
}}
|
||||
value={field.value === undefined ? "" : field.value}
|
||||
disabled={isLoading}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription>Fibonacci: 1, 2, 3, 5, 8, 13...</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Sprint 4 Story 3: Tags */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="tags"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Tags</FormLabel>
|
||||
<FormControl>
|
||||
<TagsInput
|
||||
tags={field.value || []}
|
||||
onChange={field.onChange}
|
||||
disabled={isLoading}
|
||||
placeholder="Add tags (press Enter)..."
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
Add tags to categorize this story (e.g., frontend, bug, urgent)
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="flex justify-end gap-3">
|
||||
{onCancel && (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={onCancel}
|
||||
disabled={isLoading}
|
||||
>
|
||||
<Button type="button" variant="outline" onClick={onCancel} disabled={isLoading}>
|
||||
Cancel
|
||||
</Button>
|
||||
)}
|
||||
<Button type="submit" disabled={isLoading}>
|
||||
{isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
{isEditing ? 'Update Story' : 'Create Story'}
|
||||
{isEditing ? "Update Story" : "Create Story"}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
78
components/projects/tags-input.tsx
Normal file
78
components/projects/tags-input.tsx
Normal file
@@ -0,0 +1,78 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { X } from 'lucide-react';
|
||||
|
||||
interface TagsInputProps {
|
||||
tags: string[];
|
||||
onChange: (tags: string[]) => void;
|
||||
disabled?: boolean;
|
||||
placeholder?: string;
|
||||
}
|
||||
|
||||
export function TagsInput({
|
||||
tags,
|
||||
onChange,
|
||||
disabled,
|
||||
placeholder = 'Add tag and press Enter...',
|
||||
}: TagsInputProps) {
|
||||
const [inputValue, setInputValue] = useState('');
|
||||
|
||||
const addTag = () => {
|
||||
const tag = inputValue.trim().toLowerCase();
|
||||
if (tag && !tags.includes(tag)) {
|
||||
onChange([...tags, tag]);
|
||||
setInputValue('');
|
||||
}
|
||||
};
|
||||
|
||||
const removeTag = (tagToRemove: string) => {
|
||||
onChange(tags.filter((tag) => tag !== tagToRemove));
|
||||
};
|
||||
|
||||
const handleKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
addTag();
|
||||
} else if (e.key === 'Backspace' && !inputValue && tags.length > 0) {
|
||||
removeTag(tags[tags.length - 1]);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
{/* Display existing tags */}
|
||||
{tags.length > 0 && (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{tags.map((tag) => (
|
||||
<Badge key={tag} variant="secondary" className="px-2 py-1">
|
||||
{tag}
|
||||
{!disabled && (
|
||||
<button
|
||||
type="button"
|
||||
className="ml-1 hover:text-destructive"
|
||||
onClick={() => removeTag(tag)}
|
||||
>
|
||||
<X className="h-3 w-3" />
|
||||
</button>
|
||||
)}
|
||||
</Badge>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Input for new tags */}
|
||||
{!disabled && (
|
||||
<Input
|
||||
placeholder={placeholder}
|
||||
value={inputValue}
|
||||
onChange={(e) => setInputValue(e.target.value)}
|
||||
onKeyDown={handleKeyDown}
|
||||
onBlur={() => inputValue && addTag()}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
149
components/tasks/task-card.tsx
Normal file
149
components/tasks/task-card.tsx
Normal file
@@ -0,0 +1,149 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { Task, WorkItemStatus } from "@/types/project";
|
||||
import { useChangeTaskStatus, useUpdateTask, useDeleteTask } from "@/lib/hooks/use-tasks";
|
||||
import { Card, CardContent, CardHeader } from "@/components/ui/card";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/components/ui/dropdown-menu";
|
||||
import { MoreHorizontal, Pencil, Trash2, Clock, User, CheckCircle2, Circle } from "lucide-react";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { TaskEditDialog } from "./task-edit-dialog";
|
||||
|
||||
interface TaskCardProps {
|
||||
task: Task;
|
||||
storyId: string;
|
||||
}
|
||||
|
||||
const priorityColors = {
|
||||
Critical: "bg-red-500 text-white",
|
||||
High: "bg-orange-500 text-white",
|
||||
Medium: "bg-yellow-500 text-white",
|
||||
Low: "bg-blue-500 text-white",
|
||||
};
|
||||
|
||||
const statusColors = {
|
||||
Backlog: "text-slate-500",
|
||||
Todo: "text-gray-500",
|
||||
InProgress: "text-blue-500",
|
||||
Done: "text-green-500",
|
||||
Blocked: "text-red-500",
|
||||
};
|
||||
|
||||
export function TaskCard({ task, storyId }: TaskCardProps) {
|
||||
const [isExpanded, setIsExpanded] = useState(false);
|
||||
const [isEditDialogOpen, setIsEditDialogOpen] = useState(false);
|
||||
const changeStatus = useChangeTaskStatus();
|
||||
const updateTask = useUpdateTask();
|
||||
const deleteTask = useDeleteTask();
|
||||
|
||||
const isDone = task.status === "Done";
|
||||
|
||||
const handleCheckboxChange = (checked: boolean) => {
|
||||
const newStatus: WorkItemStatus = checked ? "Done" : "Todo";
|
||||
changeStatus.mutate({ id: task.id, status: newStatus });
|
||||
};
|
||||
|
||||
const handleDelete = () => {
|
||||
if (confirm("Are you sure you want to delete this task?")) {
|
||||
deleteTask.mutate(task.id);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Card
|
||||
className={cn(
|
||||
"cursor-pointer transition-all duration-200 hover:shadow-md",
|
||||
isDone && "opacity-60"
|
||||
)}
|
||||
onClick={() => setIsExpanded(!isExpanded)}
|
||||
>
|
||||
<CardHeader className="p-4">
|
||||
<div className="flex items-start gap-3">
|
||||
{/* Checkbox */}
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<Checkbox
|
||||
checked={isDone}
|
||||
onCheckedChange={handleCheckboxChange}
|
||||
disabled={changeStatus.isPending}
|
||||
className="mt-1"
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Task Content */}
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="mb-2 flex items-center gap-2">
|
||||
<h4
|
||||
className={cn(
|
||||
"text-sm font-medium",
|
||||
isDone && "text-muted-foreground line-through"
|
||||
)}
|
||||
>
|
||||
{task.title}
|
||||
</h4>
|
||||
<Badge variant="secondary" className={cn("text-xs", priorityColors[task.priority])}>
|
||||
{task.priority}
|
||||
</Badge>
|
||||
</div>
|
||||
|
||||
{/* Metadata */}
|
||||
<div className="text-muted-foreground flex items-center gap-4 text-xs">
|
||||
{task.estimatedHours && (
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="h-3 w-3" />
|
||||
<span>{task.estimatedHours}h</span>
|
||||
</div>
|
||||
)}
|
||||
{task.assigneeId && (
|
||||
<div className="flex items-center gap-1">
|
||||
<User className="h-3 w-3" />
|
||||
<span>Assigned</span>
|
||||
</div>
|
||||
)}
|
||||
<div className={cn("flex items-center gap-1", statusColors[task.status])}>
|
||||
{isDone ? <CheckCircle2 className="h-3 w-3" /> : <Circle className="h-3 w-3" />}
|
||||
<span>{task.status}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Description (expanded) */}
|
||||
{isExpanded && task.description && (
|
||||
<div className="text-muted-foreground mt-3 text-sm">{task.description}</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Actions Menu */}
|
||||
<div onClick={(e) => e.stopPropagation()}>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="sm" className="h-8 w-8 p-0">
|
||||
<MoreHorizontal className="h-4 w-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => setIsEditDialogOpen(true)}>
|
||||
<Pencil className="mr-2 h-4 w-4" />
|
||||
Edit
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handleDelete} className="text-destructive">
|
||||
<Trash2 className="mr-2 h-4 w-4" />
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
|
||||
{/* Edit Dialog */}
|
||||
<TaskEditDialog task={task} open={isEditDialogOpen} onOpenChange={setIsEditDialogOpen} />
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
273
components/tasks/task-edit-dialog.tsx
Normal file
273
components/tasks/task-edit-dialog.tsx
Normal file
@@ -0,0 +1,273 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useForm } from 'react-hook-form';
|
||||
import { zodResolver } from '@hookform/resolvers/zod';
|
||||
import * as z from 'zod';
|
||||
import { Task, UpdateTaskDto, WorkItemPriority } from '@/types/project';
|
||||
import { useUpdateTask } from '@/lib/hooks/use-tasks';
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
DialogFooter,
|
||||
} from '@/components/ui/dialog';
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
FormDescription,
|
||||
} from '@/components/ui/form';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Loader2 } from 'lucide-react';
|
||||
|
||||
interface TaskEditDialogProps {
|
||||
task: Task;
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
}
|
||||
|
||||
const taskSchema = z.object({
|
||||
title: z.string().min(1, 'Title is required').max(200, 'Title must be less than 200 characters'),
|
||||
description: z.string().max(2000, 'Description must be less than 2000 characters').optional(),
|
||||
priority: z.enum(['Low', 'Medium', 'High', 'Critical']),
|
||||
estimatedHours: z
|
||||
.number()
|
||||
.min(0, 'Estimated hours must be positive')
|
||||
.max(1000, 'Estimated hours must be less than 1000')
|
||||
.optional()
|
||||
.or(z.literal('')),
|
||||
actualHours: z
|
||||
.number()
|
||||
.min(0, 'Actual hours must be positive')
|
||||
.max(1000, 'Actual hours must be less than 1000')
|
||||
.optional()
|
||||
.or(z.literal('')),
|
||||
});
|
||||
|
||||
type TaskFormValues = z.infer<typeof taskSchema>;
|
||||
|
||||
export function TaskEditDialog({ task, open, onOpenChange }: TaskEditDialogProps) {
|
||||
const updateTask = useUpdateTask();
|
||||
const [isSubmitting, setIsSubmitting] = useState(false);
|
||||
|
||||
const form = useForm<TaskFormValues>({
|
||||
resolver: zodResolver(taskSchema),
|
||||
defaultValues: {
|
||||
title: task.title,
|
||||
description: task.description || '',
|
||||
priority: task.priority,
|
||||
estimatedHours: task.estimatedHours || ('' as any),
|
||||
actualHours: task.actualHours || ('' as any),
|
||||
},
|
||||
});
|
||||
|
||||
// Reset form when task changes
|
||||
useEffect(() => {
|
||||
form.reset({
|
||||
title: task.title,
|
||||
description: task.description || '',
|
||||
priority: task.priority,
|
||||
estimatedHours: task.estimatedHours || ('' as any),
|
||||
actualHours: task.actualHours || ('' as any),
|
||||
});
|
||||
}, [task, form]);
|
||||
|
||||
async function onSubmit(data: TaskFormValues) {
|
||||
setIsSubmitting(true);
|
||||
try {
|
||||
const updateData: UpdateTaskDto = {
|
||||
title: data.title,
|
||||
description: data.description || undefined,
|
||||
priority: data.priority,
|
||||
estimatedHours: typeof data.estimatedHours === 'number' ? data.estimatedHours : undefined,
|
||||
actualHours: typeof data.actualHours === 'number' ? data.actualHours : undefined,
|
||||
};
|
||||
|
||||
await updateTask.mutateAsync({
|
||||
id: task.id,
|
||||
data: updateData,
|
||||
});
|
||||
|
||||
onOpenChange(false);
|
||||
form.reset();
|
||||
} catch (error) {
|
||||
// Error handling is done in the mutation hook
|
||||
} finally {
|
||||
setIsSubmitting(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<DialogContent className="sm:max-w-[600px]">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Edit Task</DialogTitle>
|
||||
</DialogHeader>
|
||||
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
||||
{/* Title */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="title"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Title</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
placeholder="Enter task title..."
|
||||
{...field}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Description */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="description"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Description</FormLabel>
|
||||
<FormControl>
|
||||
<Textarea
|
||||
placeholder="Enter task description..."
|
||||
rows={4}
|
||||
{...field}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
Provide additional details about this task
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{/* Priority and Estimated Hours */}
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="priority"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Priority</FormLabel>
|
||||
<Select
|
||||
onValueChange={field.onChange}
|
||||
value={field.value}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select priority" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="Low">Low</SelectItem>
|
||||
<SelectItem value="Medium">Medium</SelectItem>
|
||||
<SelectItem value="High">High</SelectItem>
|
||||
<SelectItem value="Critical">Critical</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="estimatedHours"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Estimated Hours</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="number"
|
||||
placeholder="e.g., 8"
|
||||
min="0"
|
||||
max="1000"
|
||||
step="0.5"
|
||||
{...field}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
field.onChange(value === '' ? '' : parseFloat(value));
|
||||
}}
|
||||
value={field.value === undefined ? '' : field.value}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Actual Hours */}
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="actualHours"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Actual Hours</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="number"
|
||||
placeholder="e.g., 6"
|
||||
min="0"
|
||||
max="1000"
|
||||
step="0.5"
|
||||
{...field}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
field.onChange(value === '' ? '' : parseFloat(value));
|
||||
}}
|
||||
value={field.value === undefined ? '' : field.value}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormDescription>
|
||||
Time spent on this task so far
|
||||
</FormDescription>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<DialogFooter>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={() => onOpenChange(false)}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button type="submit" disabled={isSubmitting}>
|
||||
{isSubmitting && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
||||
Save Changes
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</form>
|
||||
</Form>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
140
components/tasks/task-list.tsx
Normal file
140
components/tasks/task-list.tsx
Normal file
@@ -0,0 +1,140 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useTasks } from '@/lib/hooks/use-tasks';
|
||||
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Alert, AlertDescription } from '@/components/ui/alert';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||
import { TaskCard } from './task-card';
|
||||
import { TaskQuickAdd } from './task-quick-add';
|
||||
import { WorkItemStatus } from '@/types/project';
|
||||
|
||||
interface TaskListProps {
|
||||
storyId: string;
|
||||
}
|
||||
|
||||
type FilterType = 'all' | 'active' | 'completed';
|
||||
type SortType = 'recent' | 'alphabetical' | 'status';
|
||||
|
||||
export function TaskList({ storyId }: TaskListProps) {
|
||||
const { data: tasks, isLoading, error } = useTasks(storyId);
|
||||
const [filter, setFilter] = useState<FilterType>('all');
|
||||
const [sort, setSort] = useState<SortType>('recent');
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<Skeleton className="h-8 w-48" />
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-4">
|
||||
{[1, 2, 3].map((i) => (
|
||||
<Skeleton key={i} className="h-24 w-full" />
|
||||
))}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<Card>
|
||||
<CardContent className="pt-6">
|
||||
<Alert variant="destructive">
|
||||
<AlertDescription>
|
||||
Failed to load tasks. Please try again.
|
||||
</AlertDescription>
|
||||
</Alert>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
const filteredTasks = tasks?.filter(task => {
|
||||
if (filter === 'active') return task.status !== 'Done';
|
||||
if (filter === 'completed') return task.status === 'Done';
|
||||
return true;
|
||||
}) || [];
|
||||
|
||||
const sortedTasks = [...filteredTasks].sort((a, b) => {
|
||||
if (sort === 'alphabetical') return a.title.localeCompare(b.title);
|
||||
if (sort === 'status') return a.status.localeCompare(b.status);
|
||||
return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
|
||||
});
|
||||
|
||||
const completedCount = tasks?.filter(t => t.status === 'Done').length || 0;
|
||||
const totalCount = tasks?.length || 0;
|
||||
const progressPercentage = totalCount > 0 ? (completedCount / totalCount) * 100 : 0;
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<div>
|
||||
<CardTitle>Tasks</CardTitle>
|
||||
<CardDescription>
|
||||
{completedCount} of {totalCount} completed
|
||||
</CardDescription>
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
<Select value={filter} onValueChange={(v) => setFilter(v as FilterType)}>
|
||||
<SelectTrigger className="w-[140px]">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">All</SelectItem>
|
||||
<SelectItem value="active">Active</SelectItem>
|
||||
<SelectItem value="completed">Completed</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Select value={sort} onValueChange={(v) => setSort(v as SortType)}>
|
||||
<SelectTrigger className="w-[160px]">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="recent">Recent</SelectItem>
|
||||
<SelectItem value="alphabetical">Alphabetical</SelectItem>
|
||||
<SelectItem value="status">By Status</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
</div>
|
||||
{/* Progress bar */}
|
||||
<div className="mt-4">
|
||||
<div className="h-2 bg-secondary rounded-full overflow-hidden">
|
||||
<div
|
||||
className="h-full bg-primary transition-all duration-300"
|
||||
style={{ width: `${progressPercentage}%` }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
<TaskQuickAdd storyId={storyId} />
|
||||
|
||||
{sortedTasks.length === 0 ? (
|
||||
<div className="text-center py-12">
|
||||
<p className="text-muted-foreground">
|
||||
{filter === 'all'
|
||||
? 'No tasks yet. Create your first task above!'
|
||||
: `No ${filter} tasks found.`}
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3">
|
||||
{sortedTasks.map(task => (
|
||||
<TaskCard key={task.id} task={task} storyId={storyId} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
177
components/tasks/task-quick-add.tsx
Normal file
177
components/tasks/task-quick-add.tsx
Normal file
@@ -0,0 +1,177 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { z } from "zod";
|
||||
import { useCreateTask } from "@/lib/hooks/use-tasks";
|
||||
import { CreateTaskDto, WorkItemPriority } from "@/types/project";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Input } from "@/components/ui/input";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import {
|
||||
Form,
|
||||
FormControl,
|
||||
FormField,
|
||||
FormItem,
|
||||
FormLabel,
|
||||
FormMessage,
|
||||
} from "@/components/ui/form";
|
||||
import { Card, CardContent } from "@/components/ui/card";
|
||||
import { Plus, X } from "lucide-react";
|
||||
|
||||
interface TaskQuickAddProps {
|
||||
storyId: string;
|
||||
}
|
||||
|
||||
const taskSchema = z.object({
|
||||
title: z.string().min(1, "Title is required").max(200, "Title too long"),
|
||||
priority: z.enum(["Critical", "High", "Medium", "Low"]),
|
||||
estimatedHours: z.number().min(0).optional().or(z.literal("")),
|
||||
});
|
||||
|
||||
type TaskFormData = z.infer<typeof taskSchema>;
|
||||
|
||||
export function TaskQuickAdd({ storyId }: TaskQuickAddProps) {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const createTask = useCreateTask();
|
||||
|
||||
const form = useForm<TaskFormData>({
|
||||
resolver: zodResolver(taskSchema),
|
||||
defaultValues: {
|
||||
title: "",
|
||||
priority: "Medium",
|
||||
estimatedHours: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
const onSubmit = async (data: TaskFormData) => {
|
||||
const taskData: CreateTaskDto = {
|
||||
storyId,
|
||||
title: data.title,
|
||||
priority: data.priority as WorkItemPriority,
|
||||
estimatedHours: typeof data.estimatedHours === "number" ? data.estimatedHours : undefined,
|
||||
};
|
||||
|
||||
createTask.mutate(taskData, {
|
||||
onSuccess: () => {
|
||||
form.reset();
|
||||
// Keep form open for batch creation
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
form.reset();
|
||||
setIsOpen(false);
|
||||
};
|
||||
|
||||
if (!isOpen) {
|
||||
return (
|
||||
<Button onClick={() => setIsOpen(true)} variant="outline" className="w-full" size="sm">
|
||||
<Plus className="mr-2 h-4 w-4" />
|
||||
Add Task
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Card className="border-dashed">
|
||||
<CardContent className="pt-4">
|
||||
<Form {...form}>
|
||||
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-4">
|
||||
<div className="mb-2 flex items-center justify-between">
|
||||
<h4 className="text-sm font-medium">Quick Add Task</h4>
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={handleCancel}
|
||||
className="h-6 w-6 p-0"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="title"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Title *</FormLabel>
|
||||
<FormControl>
|
||||
<Input placeholder="e.g., Implement login API" {...field} />
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="priority"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Priority</FormLabel>
|
||||
<Select onValueChange={field.onChange} defaultValue={field.value}>
|
||||
<FormControl>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder="Select priority" />
|
||||
</SelectTrigger>
|
||||
</FormControl>
|
||||
<SelectContent>
|
||||
<SelectItem value="Critical">Critical</SelectItem>
|
||||
<SelectItem value="High">High</SelectItem>
|
||||
<SelectItem value="Medium">Medium</SelectItem>
|
||||
<SelectItem value="Low">Low</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="estimatedHours"
|
||||
render={({ field }) => (
|
||||
<FormItem>
|
||||
<FormLabel>Est. Hours</FormLabel>
|
||||
<FormControl>
|
||||
<Input
|
||||
type="number"
|
||||
placeholder="8"
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
field.onChange(value === "" ? "" : parseFloat(value));
|
||||
}}
|
||||
value={field.value === undefined ? "" : field.value}
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<Button type="submit" size="sm" disabled={createTask.isPending} className="flex-1">
|
||||
{createTask.isPending ? "Creating..." : "Add Task"}
|
||||
</Button>
|
||||
<Button type="button" variant="outline" size="sm" onClick={handleCancel}>
|
||||
Cancel
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
66
components/ui/alert.tsx
Normal file
66
components/ui/alert.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import * as React from "react"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
const alertVariants = cva(
|
||||
"relative w-full rounded-lg border px-4 py-3 text-sm grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-4 [&>svg]:translate-y-0.5 [&>svg]:text-current",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-card text-card-foreground",
|
||||
destructive:
|
||||
"text-destructive bg-card [&>svg]:text-current *:data-[slot=alert-description]:text-destructive/90",
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
function Alert({
|
||||
className,
|
||||
variant,
|
||||
...props
|
||||
}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
|
||||
return (
|
||||
<div
|
||||
data-slot="alert"
|
||||
role="alert"
|
||||
className={cn(alertVariants({ variant }), className)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="alert-title"
|
||||
className={cn(
|
||||
"col-start-2 line-clamp-1 min-h-4 font-medium tracking-tight",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
function AlertDescription({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<"div">) {
|
||||
return (
|
||||
<div
|
||||
data-slot="alert-description"
|
||||
className={cn(
|
||||
"text-muted-foreground col-start-2 grid justify-items-start gap-1 text-sm [&_p]:leading-relaxed",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export { Alert, AlertTitle, AlertDescription }
|
||||
32
components/ui/checkbox.tsx
Normal file
32
components/ui/checkbox.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
"use client"
|
||||
|
||||
import * as React from "react"
|
||||
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
|
||||
import { CheckIcon } from "lucide-react"
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
|
||||
function Checkbox({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
||||
return (
|
||||
<CheckboxPrimitive.Root
|
||||
data-slot="checkbox"
|
||||
className={cn(
|
||||
"peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<CheckboxPrimitive.Indicator
|
||||
data-slot="checkbox-indicator"
|
||||
className="grid place-content-center text-current transition-none"
|
||||
>
|
||||
<CheckIcon className="size-3.5" />
|
||||
</CheckboxPrimitive.Indicator>
|
||||
</CheckboxPrimitive.Root>
|
||||
)
|
||||
}
|
||||
|
||||
export { Checkbox }
|
||||
@@ -28,7 +28,7 @@ export const epicsApi = {
|
||||
create: async (data: CreateEpicDto): Promise<Epic> => {
|
||||
console.log('[epicsApi.create] Sending request', { url: '/api/v1/epics', data });
|
||||
try {
|
||||
const result = await api.post('/api/v1/epics', data);
|
||||
const result = await api.post<Epic>('/api/v1/epics', data);
|
||||
console.log('[epicsApi.create] Request successful', result);
|
||||
return result;
|
||||
} catch (error) {
|
||||
|
||||
31
package-lock.json
generated
31
package-lock.json
generated
@@ -15,6 +15,7 @@
|
||||
"@microsoft/signalr": "^9.0.6",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.15",
|
||||
"@radix-ui/react-avatar": "^1.1.11",
|
||||
"@radix-ui/react-checkbox": "^1.3.3",
|
||||
"@radix-ui/react-dialog": "^1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||
"@radix-ui/react-label": "^2.1.7",
|
||||
@@ -1490,6 +1491,36 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-checkbox": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-checkbox/-/react-checkbox-1.3.3.tgz",
|
||||
"integrity": "sha512-wBbpv+NQftHDdG86Qc0pIyXk5IR3tM8Vd0nWLKDcX8nNn4nXFOFwsKuqw2okA/1D/mpaAkmuyndrPJTYDNZtFw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@radix-ui/primitive": "1.1.3",
|
||||
"@radix-ui/react-compose-refs": "1.1.2",
|
||||
"@radix-ui/react-context": "1.1.2",
|
||||
"@radix-ui/react-presence": "1.1.5",
|
||||
"@radix-ui/react-primitive": "2.1.3",
|
||||
"@radix-ui/react-use-controllable-state": "1.2.2",
|
||||
"@radix-ui/react-use-previous": "1.1.1",
|
||||
"@radix-ui/react-use-size": "1.1.1"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "*",
|
||||
"@types/react-dom": "*",
|
||||
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc",
|
||||
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
},
|
||||
"@types/react-dom": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@radix-ui/react-collection": {
|
||||
"version": "1.1.7",
|
||||
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.1.7.tgz",
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
"@microsoft/signalr": "^9.0.6",
|
||||
"@radix-ui/react-alert-dialog": "^1.1.15",
|
||||
"@radix-ui/react-avatar": "^1.1.11",
|
||||
"@radix-ui/react-checkbox": "^1.3.3",
|
||||
"@radix-ui/react-dialog": "^1.1.15",
|
||||
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
||||
"@radix-ui/react-label": "^2.1.7",
|
||||
|
||||
@@ -71,6 +71,10 @@ export interface Story {
|
||||
estimatedHours?: number;
|
||||
actualHours?: number;
|
||||
assigneeId?: string;
|
||||
assigneeName?: string; // Sprint 4 Story 3: Assignee display name
|
||||
acceptanceCriteria?: string[]; // Sprint 4 Story 3: Acceptance criteria list
|
||||
tags?: string[]; // Sprint 4 Story 3: Tags/labels
|
||||
storyPoints?: number; // Sprint 4 Story 3: Story points
|
||||
tenantId: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -84,6 +88,10 @@ export interface CreateStoryDto {
|
||||
priority: WorkItemPriority;
|
||||
estimatedHours?: number;
|
||||
createdBy: string; // Required field matching backend API
|
||||
assigneeId?: string; // Sprint 4 Story 3
|
||||
acceptanceCriteria?: string[]; // Sprint 4 Story 3
|
||||
tags?: string[]; // Sprint 4 Story 3
|
||||
storyPoints?: number; // Sprint 4 Story 3
|
||||
}
|
||||
|
||||
export interface UpdateStoryDto {
|
||||
@@ -92,6 +100,10 @@ export interface UpdateStoryDto {
|
||||
priority?: WorkItemPriority;
|
||||
estimatedHours?: number;
|
||||
actualHours?: number;
|
||||
assigneeId?: string; // Sprint 4 Story 3
|
||||
acceptanceCriteria?: string[]; // Sprint 4 Story 3
|
||||
tags?: string[]; // Sprint 4 Story 3
|
||||
storyPoints?: number; // Sprint 4 Story 3
|
||||
}
|
||||
|
||||
// ==================== Task ====================
|
||||
|
||||
Reference in New Issue
Block a user