|
| 1 | +"use client"; |
| 2 | + |
| 3 | +import { BudgetRangeDefinition, ComplexityLevel, FeatureDefinition, ProjectType, TimelineChoice } from "../types"; |
| 4 | + |
| 5 | +interface SelectionsSummaryProps { |
| 6 | + projectType: ProjectType | null; |
| 7 | + projectTypeLabel: string | null; |
| 8 | + selectedFeatures: FeatureDefinition[]; |
| 9 | + complexity: ComplexityLevel; |
| 10 | + timeline: TimelineChoice; |
| 11 | + budgetRange: BudgetRangeDefinition | null; |
| 12 | +} |
| 13 | + |
| 14 | +function formatTimelineLabel(timeline: TimelineChoice): string { |
| 15 | + switch (timeline) { |
| 16 | + case "rush": |
| 17 | + return "Rush"; |
| 18 | + case "standard": |
| 19 | + return "Standard"; |
| 20 | + case "flexible": |
| 21 | + return "Flexible"; |
| 22 | + case "extended": |
| 23 | + return "Extended"; |
| 24 | + case "not-sure": |
| 25 | + default: |
| 26 | + return "Not sure yet"; |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +export function SelectionsSummary({ |
| 31 | + projectType, |
| 32 | + projectTypeLabel, |
| 33 | + selectedFeatures, |
| 34 | + complexity, |
| 35 | + timeline, |
| 36 | + budgetRange, |
| 37 | +}: SelectionsSummaryProps) { |
| 38 | + const featureCount = selectedFeatures.length; |
| 39 | + const visibleFeatures = selectedFeatures |
| 40 | + .filter((feature) => !feature.isBase) |
| 41 | + .slice(0, 3); |
| 42 | + const remainingFeatures = Math.max(0, selectedFeatures.filter((f) => !f.isBase).length - visibleFeatures.length); |
| 43 | + |
| 44 | + return ( |
| 45 | + <section className="space-y-2 rounded-lg border border-neutral-800 bg-neutral-950/40 p-3 text-[11px] text-neutral-300"> |
| 46 | + <div className="flex items-center justify-between"> |
| 47 | + <span className="font-semibold text-neutral-100">Your choices so far</span> |
| 48 | + {projectType && ( |
| 49 | + <span className="rounded-full border border-neutral-700 px-2 py-0.5 text-[10px] uppercase tracking-wide text-neutral-300"> |
| 50 | + Step preview |
| 51 | + </span> |
| 52 | + )} |
| 53 | + </div> |
| 54 | + |
| 55 | + {!projectType && ( |
| 56 | + <p className="text-[11px] text-neutral-500"> |
| 57 | + Start by choosing what you need built. I'll keep a running summary of your choices here. |
| 58 | + </p> |
| 59 | + )} |
| 60 | + |
| 61 | + {projectType && ( |
| 62 | + <div className="grid grid-cols-1 gap-2 sm:grid-cols-2"> |
| 63 | + <div className="space-y-1"> |
| 64 | + <div className="flex items-center justify-between"> |
| 65 | + <span className="text-neutral-400">Project type</span> |
| 66 | + <span className="font-medium text-neutral-100">{projectTypeLabel}</span> |
| 67 | + </div> |
| 68 | + <div className="flex items-center justify-between"> |
| 69 | + <span className="text-neutral-400">Features</span> |
| 70 | + <span className="font-medium text-neutral-100">{featureCount} selected</span> |
| 71 | + </div> |
| 72 | + {visibleFeatures.length > 0 && ( |
| 73 | + <p className="text-[11px] text-neutral-500"> |
| 74 | + {visibleFeatures.map((feature) => feature.label).join(", ")} |
| 75 | + {remainingFeatures > 0 && ` +${remainingFeatures} more`} |
| 76 | + </p> |
| 77 | + )} |
| 78 | + </div> |
| 79 | + |
| 80 | + <div className="space-y-1"> |
| 81 | + <div className="flex items-center justify-between"> |
| 82 | + <span className="text-neutral-400">Complexity</span> |
| 83 | + <span className="font-medium text-neutral-100 capitalize">{complexity}</span> |
| 84 | + </div> |
| 85 | + <div className="flex items-center justify-between"> |
| 86 | + <span className="text-neutral-400">Timeline</span> |
| 87 | + <span className="font-medium text-neutral-100">{formatTimelineLabel(timeline)}</span> |
| 88 | + </div> |
| 89 | + <div className="flex items-center justify-between"> |
| 90 | + <span className="text-neutral-400">Budget</span> |
| 91 | + <span className="font-medium text-neutral-100"> |
| 92 | + {budgetRange ? budgetRange.label : "Not set yet"} |
| 93 | + </span> |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + </div> |
| 97 | + )} |
| 98 | + </section> |
| 99 | + ); |
| 100 | +} |
0 commit comments