-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoadmap.tsx
More file actions
231 lines (214 loc) · 7.94 KB
/
Copy pathRoadmap.tsx
File metadata and controls
231 lines (214 loc) · 7.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Archive } from 'lucide-react';
import { RoadmapGenerationProgress } from './RoadmapGenerationProgress';
import { CompetitorAnalysisDialog } from './CompetitorAnalysisDialog';
import { ExistingCompetitorAnalysisDialog } from './ExistingCompetitorAnalysisDialog';
import { CompetitorAnalysisViewer } from './CompetitorAnalysisViewer';
import { AddFeatureDialog } from './AddFeatureDialog';
import { RoadmapHeader } from './roadmap/RoadmapHeader';
import { RoadmapEmptyState } from './roadmap/RoadmapEmptyState';
import { RoadmapTabs } from './roadmap/RoadmapTabs';
import { FeatureDetailPanel } from './roadmap/FeatureDetailPanel';
import {
AlertDialog,
AlertDialogContent,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogCancel,
AlertDialogAction,
} from './ui/alert-dialog';
import { useRoadmapData, useFeatureActions, useRoadmapGeneration, useRoadmapSave, useFeatureDelete } from './roadmap/hooks';
import { getCompetitorInsightsForFeature } from './roadmap/utils';
import type { RoadmapFeature } from '../../shared/types';
import type { RoadmapProps } from './roadmap/types';
export function Roadmap({ projectId, onGoToTask }: RoadmapProps) {
const { t } = useTranslation('common');
// State management
const [selectedFeature, setSelectedFeature] = useState<RoadmapFeature | null>(null);
const [activeTab, setActiveTab] = useState('kanban');
const [showAddFeatureDialog, setShowAddFeatureDialog] = useState(false);
const [showCompetitorViewer, setShowCompetitorViewer] = useState(false);
const [pendingArchiveFeatureId, setPendingArchiveFeatureId] = useState<string | null>(null);
// Custom hooks
const { roadmap, competitorAnalysis, generationStatus } = useRoadmapData(projectId);
const { convertFeatureToSpec } = useFeatureActions();
const { saveRoadmap } = useRoadmapSave(projectId);
const { deleteFeature } = useFeatureDelete(projectId);
const {
competitorAnalysisDate,
// New dialog for existing analysis
showExistingAnalysisDialog,
setShowExistingAnalysisDialog,
handleUseExistingAnalysis,
handleRunNewAnalysis,
handleSkipAnalysis,
// Original dialog for no existing analysis
showCompetitorDialog,
setShowCompetitorDialog,
handleGenerate,
handleRefresh,
handleCompetitorDialogAccept,
handleCompetitorDialogDecline,
handleStop,
} = useRoadmapGeneration(projectId);
// Event handlers
const handleConvertToSpec = async (feature: RoadmapFeature) => {
await convertFeatureToSpec(projectId, feature, selectedFeature, setSelectedFeature);
};
const handleGoToTask = (specId: string) => {
if (onGoToTask) {
onGoToTask(specId);
}
};
const handleArchiveFeature = (featureId: string) => {
setPendingArchiveFeatureId(featureId);
};
const confirmArchiveFeature = async () => {
if (!pendingArchiveFeatureId) return;
try {
await deleteFeature(pendingArchiveFeatureId);
if (selectedFeature?.id === pendingArchiveFeatureId) {
setSelectedFeature(null);
}
} finally {
setPendingArchiveFeatureId(null);
}
};
// Show generation progress
if (generationStatus.phase !== 'idle' && generationStatus.phase !== 'complete') {
return (
<div className="flex h-full items-center justify-center">
<RoadmapGenerationProgress
generationStatus={generationStatus}
className="w-full max-w-md"
onStop={handleStop}
/>
</div>
);
}
// Show empty state
if (!roadmap) {
return (
<>
<RoadmapEmptyState onGenerate={handleGenerate} />
{/* Dialog for projects WITHOUT existing competitor analysis */}
<CompetitorAnalysisDialog
open={showCompetitorDialog}
onOpenChange={setShowCompetitorDialog}
onAccept={handleCompetitorDialogAccept}
onDecline={handleCompetitorDialogDecline}
projectId={projectId}
/>
{/* Dialog for projects WITH existing competitor analysis */}
<ExistingCompetitorAnalysisDialog
open={showExistingAnalysisDialog}
onOpenChange={setShowExistingAnalysisDialog}
onUseExisting={handleUseExistingAnalysis}
onRunNew={handleRunNewAnalysis}
onSkip={handleSkipAnalysis}
analysisDate={competitorAnalysisDate}
projectId={projectId}
/>
</>
);
}
// Main roadmap view
return (
<div className="h-full flex flex-col overflow-hidden">
{/* Header */}
<RoadmapHeader
roadmap={roadmap}
competitorAnalysis={competitorAnalysis}
onAddFeature={() => setShowAddFeatureDialog(true)}
onRefresh={handleRefresh}
onViewCompetitorAnalysis={() => setShowCompetitorViewer(true)}
/>
{/* Content */}
<div className="flex-1 overflow-hidden">
<RoadmapTabs
roadmap={roadmap}
activeTab={activeTab}
onTabChange={setActiveTab}
onFeatureSelect={setSelectedFeature}
onConvertToSpec={handleConvertToSpec}
onGoToTask={handleGoToTask}
onSave={saveRoadmap}
onArchive={handleArchiveFeature}
/>
</div>
{/* Feature Detail Panel */}
{selectedFeature && (
<FeatureDetailPanel
feature={selectedFeature}
onClose={() => setSelectedFeature(null)}
onConvertToSpec={handleConvertToSpec}
onGoToTask={handleGoToTask}
onDelete={deleteFeature}
onArchive={handleArchiveFeature}
competitorInsights={getCompetitorInsightsForFeature(selectedFeature, competitorAnalysis)}
/>
)}
{/* Competitor Analysis Permission Dialog (no existing analysis) */}
<CompetitorAnalysisDialog
open={showCompetitorDialog}
onOpenChange={setShowCompetitorDialog}
onAccept={handleCompetitorDialogAccept}
onDecline={handleCompetitorDialogDecline}
projectId={projectId}
/>
{/* Competitor Analysis Options Dialog (existing analysis) */}
<ExistingCompetitorAnalysisDialog
open={showExistingAnalysisDialog}
onOpenChange={setShowExistingAnalysisDialog}
onUseExisting={handleUseExistingAnalysis}
onRunNew={handleRunNewAnalysis}
onSkip={handleSkipAnalysis}
analysisDate={competitorAnalysisDate}
projectId={projectId}
/>
{/* Competitor Analysis Viewer */}
<CompetitorAnalysisViewer
analysis={competitorAnalysis}
open={showCompetitorViewer}
onOpenChange={setShowCompetitorViewer}
projectId={projectId}
/>
{/* Add Feature Dialog */}
<AddFeatureDialog
phases={roadmap.phases}
open={showAddFeatureDialog}
onOpenChange={setShowAddFeatureDialog}
/>
{/* Archive Confirmation Dialog */}
<AlertDialog
open={!!pendingArchiveFeatureId}
onOpenChange={(open) => { if (!open) setPendingArchiveFeatureId(null); }}
>
<AlertDialogContent>
<AlertDialogHeader>
<div className="flex items-center gap-2">
<Archive className="h-5 w-5 text-muted-foreground" />
<AlertDialogTitle>{t('roadmap.archiveFeatureConfirmTitle')}</AlertDialogTitle>
</div>
<AlertDialogDescription>
{t('roadmap.archiveFeatureConfirmDescription', {
title: pendingArchiveFeatureId
? roadmap.features.find((f) => f.id === pendingArchiveFeatureId)?.title ?? ''
: '',
})}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>{t('buttons.cancel')}</AlertDialogCancel>
<AlertDialogAction onClick={confirmArchiveFeature}>
{t('roadmap.archiveFeature')}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
</div>
);
}