|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { Sparkles, Clock } from "lucide-react"; |
| 4 | +import { |
| 5 | + Dialog, |
| 6 | + DialogContent, |
| 7 | + DialogDescription, |
| 8 | + DialogFooter, |
| 9 | + DialogHeader, |
| 10 | + DialogTitle, |
| 11 | +} from "@/components/ui/dialog"; |
| 12 | +import { Button } from "@/components/ui/button"; |
| 13 | +import { Checkbox } from "@/components/ui/checkbox"; |
| 14 | +import { cn } from "@/lib/utils"; |
| 15 | + |
| 16 | +// Feature count options |
| 17 | +export type FeatureCount = 20 | 50 | 100; |
| 18 | +const FEATURE_COUNT_OPTIONS: { |
| 19 | + value: FeatureCount; |
| 20 | + label: string; |
| 21 | + warning?: string; |
| 22 | +}[] = [ |
| 23 | + { value: 20, label: "20" }, |
| 24 | + { value: 50, label: "50", warning: "May take up to 5 minutes" }, |
| 25 | + { value: 100, label: "100", warning: "May take up to 5 minutes" }, |
| 26 | +]; |
| 27 | + |
| 28 | +interface ProjectSetupDialogProps { |
| 29 | + open: boolean; |
| 30 | + onOpenChange: (open: boolean) => void; |
| 31 | + projectOverview: string; |
| 32 | + onProjectOverviewChange: (value: string) => void; |
| 33 | + generateFeatures: boolean; |
| 34 | + onGenerateFeaturesChange: (value: boolean) => void; |
| 35 | + featureCount: FeatureCount; |
| 36 | + onFeatureCountChange: (value: FeatureCount) => void; |
| 37 | + onCreateSpec: () => void; |
| 38 | + onSkip: () => void; |
| 39 | + isCreatingSpec: boolean; |
| 40 | +} |
| 41 | + |
| 42 | +export function ProjectSetupDialog({ |
| 43 | + open, |
| 44 | + onOpenChange, |
| 45 | + projectOverview, |
| 46 | + onProjectOverviewChange, |
| 47 | + generateFeatures, |
| 48 | + onGenerateFeaturesChange, |
| 49 | + featureCount, |
| 50 | + onFeatureCountChange, |
| 51 | + onCreateSpec, |
| 52 | + onSkip, |
| 53 | + isCreatingSpec, |
| 54 | +}: ProjectSetupDialogProps) { |
| 55 | + return ( |
| 56 | + <Dialog |
| 57 | + open={open} |
| 58 | + onOpenChange={(open) => { |
| 59 | + onOpenChange(open); |
| 60 | + if (!open && !isCreatingSpec) { |
| 61 | + onSkip(); |
| 62 | + } |
| 63 | + }} |
| 64 | + > |
| 65 | + <DialogContent className="max-w-2xl"> |
| 66 | + <DialogHeader> |
| 67 | + <DialogTitle>Set Up Your Project</DialogTitle> |
| 68 | + <DialogDescription className="text-muted-foreground"> |
| 69 | + We didn't find an app_spec.txt file. Let us help you generate |
| 70 | + your app_spec.txt to help describe your project for our system. |
| 71 | + We'll analyze your project's tech stack and create a |
| 72 | + comprehensive specification. |
| 73 | + </DialogDescription> |
| 74 | + </DialogHeader> |
| 75 | + |
| 76 | + <div className="space-y-4 py-4"> |
| 77 | + <div className="space-y-2"> |
| 78 | + <label className="text-sm font-medium">Project Overview</label> |
| 79 | + <p className="text-xs text-muted-foreground"> |
| 80 | + Describe what your project does and what features you want to |
| 81 | + build. Be as detailed as you want - this will help us create a |
| 82 | + better specification. |
| 83 | + </p> |
| 84 | + <textarea |
| 85 | + className="w-full h-48 p-3 rounded-md border border-border bg-background font-mono text-sm resize-none focus:outline-none focus:ring-2 focus:ring-ring" |
| 86 | + value={projectOverview} |
| 87 | + onChange={(e) => onProjectOverviewChange(e.target.value)} |
| 88 | + placeholder="e.g., A project management tool that allows teams to track tasks, manage sprints, and visualize progress through kanban boards. It should support user authentication, real-time updates, and file attachments..." |
| 89 | + autoFocus |
| 90 | + /> |
| 91 | + </div> |
| 92 | + |
| 93 | + <div className="flex items-start space-x-3 pt-2"> |
| 94 | + <Checkbox |
| 95 | + id="sidebar-generate-features" |
| 96 | + checked={generateFeatures} |
| 97 | + onCheckedChange={(checked) => |
| 98 | + onGenerateFeaturesChange(checked === true) |
| 99 | + } |
| 100 | + /> |
| 101 | + <div className="space-y-1"> |
| 102 | + <label |
| 103 | + htmlFor="sidebar-generate-features" |
| 104 | + className="text-sm font-medium cursor-pointer" |
| 105 | + > |
| 106 | + Generate feature list |
| 107 | + </label> |
| 108 | + <p className="text-xs text-muted-foreground"> |
| 109 | + Automatically create features in the features folder from the |
| 110 | + implementation roadmap after the spec is generated. |
| 111 | + </p> |
| 112 | + </div> |
| 113 | + </div> |
| 114 | + |
| 115 | + {/* Feature Count Selection - only shown when generateFeatures is enabled */} |
| 116 | + {generateFeatures && ( |
| 117 | + <div className="space-y-2 pt-2 pl-7"> |
| 118 | + <label className="text-sm font-medium">Number of Features</label> |
| 119 | + <div className="flex gap-2"> |
| 120 | + {FEATURE_COUNT_OPTIONS.map((option) => ( |
| 121 | + <Button |
| 122 | + key={option.value} |
| 123 | + type="button" |
| 124 | + variant={ |
| 125 | + featureCount === option.value ? "default" : "outline" |
| 126 | + } |
| 127 | + size="sm" |
| 128 | + onClick={() => onFeatureCountChange(option.value)} |
| 129 | + className={cn( |
| 130 | + "flex-1 transition-all", |
| 131 | + featureCount === option.value |
| 132 | + ? "bg-primary hover:bg-primary/90 text-primary-foreground" |
| 133 | + : "bg-muted/30 hover:bg-muted/50 border-border" |
| 134 | + )} |
| 135 | + data-testid={`feature-count-${option.value}`} |
| 136 | + > |
| 137 | + {option.label} |
| 138 | + </Button> |
| 139 | + ))} |
| 140 | + </div> |
| 141 | + {FEATURE_COUNT_OPTIONS.find((o) => o.value === featureCount) |
| 142 | + ?.warning && ( |
| 143 | + <p className="text-xs text-amber-500 flex items-center gap-1"> |
| 144 | + <Clock className="w-3 h-3" /> |
| 145 | + { |
| 146 | + FEATURE_COUNT_OPTIONS.find((o) => o.value === featureCount) |
| 147 | + ?.warning |
| 148 | + } |
| 149 | + </p> |
| 150 | + )} |
| 151 | + </div> |
| 152 | + )} |
| 153 | + </div> |
| 154 | + |
| 155 | + <DialogFooter> |
| 156 | + <Button variant="ghost" onClick={onSkip}> |
| 157 | + Skip for now |
| 158 | + </Button> |
| 159 | + <Button onClick={onCreateSpec} disabled={!projectOverview.trim()}> |
| 160 | + <Sparkles className="w-4 h-4 mr-2" /> |
| 161 | + Generate Spec |
| 162 | + </Button> |
| 163 | + </DialogFooter> |
| 164 | + </DialogContent> |
| 165 | + </Dialog> |
| 166 | + ); |
| 167 | +} |
0 commit comments