/** * IdeationView - Main view for brainstorming and idea management * Dashboard-first design with Generate Ideas flow */ import { useCallback, useState } from 'react'; import { useIdeationStore } from '@/store/ideation-store'; import { useAppStore } from '@/store/app-store'; import { PromptCategoryGrid } from './components/prompt-category-grid'; import { PromptList } from './components/prompt-list'; import { IdeationDashboard } from './components/ideation-dashboard'; import { useGuidedPrompts } from '@/hooks/use-guided-prompts'; import { Button } from '@/components/ui/button'; import { ArrowLeft, ChevronRight, Lightbulb, CheckCheck, Loader2 } from 'lucide-react'; import type { IdeaCategory } from '@automaker/types'; import type { IdeationMode } from '@/store/ideation-store'; // Breadcrumb component - compact inline breadcrumbs function IdeationBreadcrumbs({ currentMode, selectedCategory, onNavigate, }: { currentMode: IdeationMode; selectedCategory: IdeaCategory | null; onNavigate: (mode: IdeationMode, category?: IdeaCategory | null) => void; }) { const { getCategoryById } = useGuidedPrompts(); const categoryInfo = selectedCategory ? getCategoryById(selectedCategory) : null; // On dashboard, no breadcrumbs needed (it's the root) if (currentMode === 'dashboard') { return null; } return ( ); } // Header shown on all pages - matches other view headers function IdeationHeader({ currentMode, selectedCategory, onNavigate, onGenerateIdeas, onBack, acceptAllReady, acceptAllCount, onAcceptAll, isAcceptingAll, }: { currentMode: IdeationMode; selectedCategory: IdeaCategory | null; onNavigate: (mode: IdeationMode, category?: IdeaCategory | null) => void; onGenerateIdeas: () => void; onBack: () => void; acceptAllReady: boolean; acceptAllCount: number; onAcceptAll: () => void; isAcceptingAll: boolean; }) { const { getCategoryById } = useGuidedPrompts(); const showBackButton = currentMode === 'prompts'; // Get subtitle text based on current mode const getSubtitle = (): string => { if (currentMode === 'dashboard') { return 'Review and accept generated ideas'; } if (currentMode === 'prompts') { if (selectedCategory) { const categoryInfo = getCategoryById(selectedCategory); return `Select a prompt from ${categoryInfo?.name || 'category'}`; } return 'Select a category to generate ideas'; } return ''; }; const subtitle = getSubtitle(); return (
{showBackButton && ( )}

Ideation

{currentMode === 'dashboard' ? (

{subtitle}

) : ( )}
{currentMode === 'dashboard' && acceptAllReady && ( )}
); } export function IdeationView() { const currentProject = useAppStore((s) => s.currentProject); const { currentMode, selectedCategory, setMode, setCategory } = useIdeationStore(); // Accept all state const [acceptAllReady, setAcceptAllReady] = useState(false); const [acceptAllCount, setAcceptAllCount] = useState(0); const [acceptAllHandler, setAcceptAllHandler] = useState<(() => Promise) | null>(null); const [isAcceptingAll, setIsAcceptingAll] = useState(false); const handleAcceptAllReady = useCallback( (isReady: boolean, count: number, handler: () => Promise) => { setAcceptAllReady(isReady); setAcceptAllCount(count); setAcceptAllHandler(() => handler); }, [] ); const handleAcceptAll = useCallback(async () => { if (acceptAllHandler) { setIsAcceptingAll(true); try { await acceptAllHandler(); } finally { setIsAcceptingAll(false); } } }, [acceptAllHandler]); const handleNavigate = useCallback( (mode: IdeationMode, category?: IdeaCategory | null) => { setMode(mode); if (category !== undefined) { setCategory(category); } else if (mode !== 'prompts') { setCategory(null); } }, [setMode, setCategory] ); const handleSelectCategory = useCallback( (category: IdeaCategory) => { setCategory(category); }, [setCategory] ); const handleBackFromPrompts = useCallback(() => { // If viewing a category, go back to category grid if (selectedCategory) { setCategory(null); return; } // Otherwise, go back to dashboard setMode('dashboard'); }, [selectedCategory, setCategory, setMode]); const handleGenerateIdeas = useCallback(() => { setMode('prompts'); setCategory(null); }, [setMode, setCategory]); if (!currentProject) { return (

Open a project to start brainstorming ideas

); } return (
{/* Header with breadcrumbs - always shown */} {/* Dashboard - main view */} {currentMode === 'dashboard' && ( )} {/* Prompts - category selection */} {currentMode === 'prompts' && !selectedCategory && ( )} {/* Prompts - prompt selection within category */} {currentMode === 'prompts' && selectedCategory && ( )}
); }