import React from "react";
import { Prompt } from "../../../hooks/usePrompts";

import DashboardChatArea from './DashboardChatArea.tsx';

import styles from './DashboardChatAreaStyles/DashboardChat.module.css';

interface DashboardChatProps {
    isExpanded: boolean;
    onToggleExpand: () => void;
    selectedPrompt?: Prompt | null;
    onPromptUsed?: () => void;
    onWorkflowIdChange?: (workflowId: string | null) => void;
    onWorkflowCompletedChange?: (completed: boolean) => void;
    currentWorkflowId?: string | null;
}

const DashboardChat: React.FC<DashboardChatProps> = ({ 
    selectedPrompt, 
    onPromptUsed,
    onWorkflowIdChange,
    onWorkflowCompletedChange,
    currentWorkflowId
}) => {
    // Pass the current workflow ID directly to the chat area
    // This handles both dropdown selection and workflow resume scenarios
    const effectiveWorkflowId = currentWorkflowId;

    return (
        <div className={styles.dashboard_chat}>
            <DashboardChatArea 
            selectedPrompt={selectedPrompt}
            onPromptUsed={onPromptUsed}
            onWorkflowIdChange={onWorkflowIdChange}
            onWorkflowCompletedChange={onWorkflowCompletedChange}
            resumeWorkflowId={effectiveWorkflowId}
            />
        </div>
    );
};

export default DashboardChat;