-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompetitorAnalysisDialog.tsx
More file actions
165 lines (152 loc) · 6.63 KB
/
Copy pathCompetitorAnalysisDialog.tsx
File metadata and controls
165 lines (152 loc) · 6.63 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
import { useState, useEffect } from 'react';
import { useTranslation } from 'react-i18next';
import { Search, Globe, AlertTriangle, TrendingUp, UserPlus } from 'lucide-react';
import {
AlertDialog,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogAction,
AlertDialogCancel,
} from './ui/alert-dialog';
import { Button } from './ui/button';
import { AddCompetitorDialog } from './AddCompetitorDialog';
interface CompetitorAnalysisDialogProps {
open: boolean;
onOpenChange: (open: boolean) => void;
onAccept: () => void;
onDecline: () => void;
projectId: string;
}
export function CompetitorAnalysisDialog({
open,
onOpenChange,
onAccept,
onDecline,
projectId,
}: CompetitorAnalysisDialogProps) {
const { t } = useTranslation(['dialogs']);
const [showAddDialog, setShowAddDialog] = useState(false);
const [addedCount, setAddedCount] = useState(0);
// Reset addedCount when dialog reopens
useEffect(() => {
if (open) {
setAddedCount(0);
}
}, [open]);
const handleAccept = () => {
onAccept();
onOpenChange(false);
};
const handleDecline = () => {
onDecline();
onOpenChange(false);
};
const handleCompetitorAdded = (_competitorId: string) => {
setAddedCount((prev) => prev + 1);
};
return (
<>
<AlertDialog open={open} onOpenChange={onOpenChange}>
<AlertDialogContent className="sm:max-w-[500px]">
<AlertDialogHeader>
<AlertDialogTitle className="flex items-center gap-2 text-foreground">
<TrendingUp className="h-5 w-5 text-primary" />
{t('dialogs:competitorAnalysis.title', 'Enable Competitor Analysis?')}
</AlertDialogTitle>
<AlertDialogDescription className="text-muted-foreground">
{t('dialogs:competitorAnalysis.description', 'Enhance your roadmap with insights from competitor products')}
</AlertDialogDescription>
</AlertDialogHeader>
<div className="py-4 space-y-4">
{/* What it does */}
<div className="rounded-lg bg-primary/5 border border-primary/20 p-4">
<h4 className="text-sm font-medium text-foreground mb-2">
{t('dialogs:competitorAnalysis.whatItDoes', 'What competitor analysis does:')}
</h4>
<ul className="text-sm text-muted-foreground space-y-2">
<li className="flex items-start gap-2">
<Search className="h-4 w-4 mt-0.5 text-primary flex-shrink-0" />
<span>{t('dialogs:competitorAnalysis.identifiesCompetitors', 'Identifies 3-5 main competitors based on your project type')}</span>
</li>
<li className="flex items-start gap-2">
<Globe className="h-4 w-4 mt-0.5 text-primary flex-shrink-0" />
<span>
{t('dialogs:competitorAnalysis.searchesAppStores', 'Searches app stores, forums, and social media for user feedback and pain points')}
</span>
</li>
<li className="flex items-start gap-2">
<TrendingUp className="h-4 w-4 mt-0.5 text-primary flex-shrink-0" />
<span>
{t('dialogs:competitorAnalysis.suggestsFeatures', 'Suggests features that address gaps in competitor products')}
</span>
</li>
</ul>
</div>
{/* Privacy notice */}
<div className="rounded-lg bg-warning/10 border border-warning/30 p-4">
<div className="flex items-start gap-3">
<AlertTriangle className="h-5 w-5 text-warning flex-shrink-0 mt-0.5" />
<div className="flex-1">
<h4 className="text-sm font-medium text-foreground">
{t('dialogs:competitorAnalysis.webSearchesTitle', 'Web searches will be performed')}
</h4>
<p className="text-xs text-muted-foreground mt-1">
{t('dialogs:competitorAnalysis.webSearchesDescription', 'This feature will perform web searches to gather competitor information. Your project name and type will be used in search queries. No code or sensitive data is shared.')}
</p>
</div>
</div>
</div>
{/* Optional info */}
<p className="text-xs text-muted-foreground">
{t('dialogs:competitorAnalysis.optionalInfo', 'You can generate a roadmap without competitor analysis if you prefer. The roadmap will still be based on your project structure and best practices.')}
</p>
</div>
{/* Add Known Competitors section */}
<div className="border-t border-border pt-4">
<div className="flex items-center justify-between">
<div className="flex-1">
<p className="text-sm text-muted-foreground">
{t('dialogs:competitorAnalysis.knowYourCompetitors', 'Already know your competitors?')}
</p>
<p className="text-xs text-muted-foreground/70 mt-0.5">
{t('dialogs:competitorAnalysis.addThemDirectly', 'Add them directly to improve analysis accuracy')}
</p>
</div>
<Button
variant="outline"
size="sm"
className="flex items-center gap-1.5"
onClick={() => setShowAddDialog(true)}
>
<UserPlus className="h-3.5 w-3.5" />
{t('dialogs:competitorAnalysis.addKnownCompetitors', 'Add Known Competitors')}
{addedCount > 0 && (
<span className="ml-1 rounded-full bg-primary px-1.5 py-0.5 text-[10px] font-medium text-primary-foreground">
{t('dialogs:competitorAnalysis.competitorsAdded', '{{count}} added', { count: addedCount })}
</span>
)}
</Button>
</div>
</div>
<AlertDialogFooter>
<AlertDialogCancel onClick={handleDecline}>
{t('dialogs:competitorAnalysis.skipAnalysis', 'No, Skip Analysis')}
</AlertDialogCancel>
<AlertDialogAction onClick={handleAccept}>
{t('dialogs:competitorAnalysis.enableAnalysis', 'Yes, Enable Analysis')}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
<AddCompetitorDialog
open={showAddDialog}
onOpenChange={setShowAddDialog}
onCompetitorAdded={handleCompetitorAdded}
projectId={projectId}
/>
</>
);
}