import { useParams, Link } from 'react-router-dom' import { ArrowLeft } from 'lucide-react' import { formatDistanceToNow } from 'date-fns' import { Skeleton } from '@/components/ui/skeleton' import { Separator } from '@/components/ui/separator' import { StatusBadge } from '@/components/bugs/StatusBadge' import { LabelEditor } from '@/components/bugs/LabelEditor' import { TitleEditor } from '@/components/bugs/TitleEditor' import { Timeline } from '@/components/bugs/Timeline' import { CommentBox } from '@/components/bugs/CommentBox' import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar' import { useBugDetailQuery } from '@/__generated__/graphql' import { useRepo } from '@/lib/repo' // Issue detail page (/:repo/issues/:id). Shows title, status, timeline of // comments and events, and a sidebar with labels and participants. export function BugDetailPage() { const { id } = useParams<{ id: string }>() const repo = useRepo() const { data, loading, error } = useBugDetailQuery({ variables: { ref: repo, prefix: id! }, }) if (error) { return (
Failed to load issue: {error.message}
) } if (loading && !data) { return } const bug = data?.repository?.bug if (!bug) { return (
Issue not found.
) } const issuesHref = repo ? `/${repo}/issues` : '/issues' const authorHref = repo ? `/${repo}/user/${bug.author.humanId}` : `/user/${bug.author.humanId}` return (
Back to issues {/* Title row — hover reveals edit button when logged in */}
{bug.author.displayName} {' '} opened this issue {formatDistanceToNow(new Date(bug.createdAt), { addSuffix: true })}
{/* Timeline + comment box */}
{/* Sidebar */}
) } function BugDetailSkeleton() { return (
{Array.from({ length: 3 }).map((_, i) => (
))}
) }