'use client'; import { useState } from 'react'; import { X, Link2, ChevronRight } from 'lucide-react'; import { BugStatusBadge } from './BugStatusBadge'; import { useBugStore } from '@/stores/useBugStore'; import { useTestCaseStore } from '@/stores/useTestCaseStore'; import { useRequirementStore } from '@/stores/useRequirementStore'; import { BUG_ALLOWED_TRANSITIONS, BUG_STATUS_LABEL, BUG_SEVERITY_LABEL, BUG_SEVERITY_COLOR } from '@/lib/bug'; import type { BugStatus } from '@/lib/bug'; interface Props { bugId: string; onClose: () => void; } export function BugDetailDrawer({ bugId, onClose }: Props) { const { bugs, changeStatus } = useBugStore(); const { testCases } = useTestCaseStore(); const { requirements } = useRequirementStore(); const bug = bugs.find((b) => b.id === bugId); if (!bug) return null; const tc = testCases.find((c) => c.id === bug.testCaseId); const requirement = tc ? requirements.find((r) => r.id === tc.requirementId) : null; const nextStatuses = BUG_ALLOWED_TRANSITIONS[bug.status]; const [resolution, setResolution] = useState(bug.resolution || ''); const [showResolutionInput, setShowResolutionInput] = useState(false); const handleTransition = (to: BugStatus) => { if (to === 'fixed') { setShowResolutionInput(true); return; } changeStatus(bug.id, to); }; const confirmFix = () => { changeStatus(bug.id, 'fixed', { resolution: resolution.trim() || undefined }); setShowResolutionInput(false); }; return (
{bug.description}
{bug.resolution}