import { useState } from "react";
import { ProactiveChatList } from "../features/proactive-chat/components/ProactiveChatList";
import { ProactiveChatCreate } from "../features/proactive-chat/components/ProactiveChatCreate";

export default function ProactiveChatPage() {
    const [view, setView] = useState("list"); // list | create | edit
    const [editingChat, setEditingChat] = useState<any>(null);

    const handleCreateClick = () => {
        setEditingChat(null);
        setView("create");
    };

    const handleEditClick = (chat: any) => {
        setEditingChat(chat);
        setView("edit");
    };

    if (view === "create" || view === "edit") {
        return <ProactiveChatCreate initialData={editingChat} onBack={() => {
            setView("list");
            setEditingChat(null);
        }} />;
    }

    return <ProactiveChatList onCreateClick={handleCreateClick} onEditClick={handleEditClick} />;
}

