'use client' import { useState, useRef } from 'react' import { motion, AnimatePresence } from 'motion/react' import { Search, Bot, ChevronLeft, ChevronRight, Loader2, Check } from 'lucide-react' import { useLanguage } from '@/lib/i18n' import { DashboardWidgetTitleRow } from '@/components/dashboard-widget-title-row' export interface AgentSuggestion { id: string topic: string reason: string relatedNoteCount: number suggestedFrequency: string } export interface CreatedAgentNotice { id: string | null topic: string } export interface DashboardAgentCarouselProps { suggestions: AgentSuggestion[] loading?: boolean actingId: string | null formatFrequency: (f: string) => string onAccept: (id: string) => void onDismiss: (id: string) => void createdAgent?: CreatedAgentNotice | null onOpenCreated?: () => void onClearCreated?: () => void prefersReducedMotion?: boolean } export function DashboardAgentCarousel({ suggestions, loading, actingId, formatFrequency, onAccept, onDismiss, createdAgent, onOpenCreated, onClearCreated, prefersReducedMotion, }: DashboardAgentCarouselProps) { const { t } = useLanguage() const [idx, setIdx] = useState(0) const directionRef = useRef(1) const safeIdx = suggestions.length === 0 ? 0 : Math.min(idx, suggestions.length - 1) const goPrev = () => { directionRef.current = -1 setIdx(i => Math.max(0, i - 1)) } const goNext = () => { directionRef.current = 1 setIdx(i => Math.min(suggestions.length - 1, i + 1)) } const showCreated = !!createdAgent const showNav = !showCreated && suggestions.length > 1 const navActions = showNav ? (
{t('homeDashboard.agentsEmpty')}
{t('homeDashboard.agentCreatedInCard')}
{topic ? ({topic}
) : null}{current.topic}
{current.reason}
{current.relatedNoteCount} {t('homeDashboard.notes')} ยท {formatFrequency(current.suggestedFrequency)}