
import NavBarNormal from "@/components/nav-bar-normal/index";
import { View } from "@tarojs/components";
import PageCustom from "@/components/page-custom/index";

import TabBarButtons from "@/components/wemeta-tabs/TabBarButtons";
import AgentSetting from './components/AgentSetting/'
import { useAgentStore } from "@/store/agentStore";
import { useEffect, useState } from "react";

export default function Index() {
  const [tabIndex, setTabIndex] = useState("1");
  const agent = useAgentStore((state)=> state.agent)
  const {fetchAgent} = useAgentStore()
  const handleTabIndexChange = (index: string) => {
    setTabIndex(index);
  };

  const tabList = [
    {
      key: "1",
      label: "智能体",
    },
    {
      key: "2",
      label: "微官网",
    },
  ];

  useEffect(()=> {
    agent?.agentId && fetchAgent(agent.agentId)
  }, [agent?.agentId])

  return (
    <PageCustom>
      <NavBarNormal backText="创建"></NavBarNormal>
      <View className="px-16 w-full flex flex-col gap-20">
        <View className="w-full">
          <TabBarButtons
            current={tabIndex}
            list={tabList}
            onTabIndexChange={handleTabIndexChange}
          ></TabBarButtons>
        </View>
        <View className={`${tabIndex === '1' ? 'block':'hidden'}`}>
          <AgentSetting></AgentSetting>
        </View>
        <View className={`${tabIndex === '2' ? 'block':'hidden'}`}>
          components
        </View>
        

        
      </View>
    </PageCustom>
  );
}
