63 lines
No EOL
2.1 KiB
TypeScript
63 lines
No EOL
2.1 KiB
TypeScript
import React, { useState } from "react";
|
|
import { BsArrowsAngleExpand, BsArrowsAngleContract } from "react-icons/bs";
|
|
import { motion, AnimatePresence } from "framer-motion";
|
|
import { Prompt } from "../../../hooks/usePrompts";
|
|
import { useLanguage } from '../../../contexts/LanguageContext';
|
|
|
|
import DashboardChatArea from './DashboardChatArea/DashboardChatArea';
|
|
import DashboardChatHistory from './DashboardChatHistory/DashboardChatHistory';
|
|
|
|
import styles from './DashboardChat.module.css';
|
|
|
|
interface DashboardChatProps {
|
|
isExpanded: boolean;
|
|
onToggleExpand: () => void;
|
|
selectedPrompt?: Prompt | null;
|
|
onPromptUsed?: () => void;
|
|
onWorkflowIdChange?: (workflowId: string | null) => void;
|
|
onWorkflowCompletedChange?: (completed: boolean) => void;
|
|
onWorkflowResume?: (workflowId: string) => void;
|
|
}
|
|
|
|
const DashboardChat: React.FC<DashboardChatProps> = ({
|
|
isExpanded,
|
|
onToggleExpand,
|
|
selectedPrompt,
|
|
onPromptUsed,
|
|
onWorkflowIdChange,
|
|
onWorkflowCompletedChange,
|
|
onWorkflowResume
|
|
}) => {
|
|
const { t } = useLanguage();
|
|
const [activeTab, setActiveTab] = useState(t('dashboard.chat.area'));
|
|
const [resumeWorkflowId, setResumeWorkflowId] = useState<string | null>(null);
|
|
|
|
const handleWorkflowResume = (workflowId: string) => {
|
|
// Switch to Chat Area tab first
|
|
setActiveTab(t('dashboard.chat.area'));
|
|
// Set the workflow ID to resume
|
|
setResumeWorkflowId(workflowId);
|
|
// Then call the parent's resume handler
|
|
if (onWorkflowResume) {
|
|
onWorkflowResume(workflowId);
|
|
}
|
|
// Clear the resume ID after a short delay to allow processing
|
|
setTimeout(() => {
|
|
setResumeWorkflowId(null);
|
|
}, 100);
|
|
};
|
|
|
|
return (
|
|
<div className={styles.dashboard_chat}>
|
|
<DashboardChatArea
|
|
selectedPrompt={selectedPrompt}
|
|
onPromptUsed={onPromptUsed}
|
|
onWorkflowIdChange={onWorkflowIdChange}
|
|
onWorkflowCompletedChange={onWorkflowCompletedChange}
|
|
resumeWorkflowId={resumeWorkflowId}
|
|
/>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default DashboardChat; |