import { View } from "@tarojs/components";
import RoundedLabel from "../RoundedLabel";
import IconFilterFeeds from "@/components/icon/IconFilterFeeds";
import IconFilterBatch from "@/components/icon/IconFilterBatch";
import IconFilterList from "@/components/icon/IconFilterList";
import EmptyData from "@/components/empty-data";

import Popup from "@/components/popup/popup";
import WemetaSwitch from "@/components/WemetaSwitch";
import { useState } from "react";

import ViewStyleListCorrection from "../view-style/ViewStyleListCorrection";

import { TEntItem } from "@/types/user";

import CompanyList from '../CompanyList'
import { TCorrectionItem } from "@/types/correction";

type TListStyle = "card" | "list";

const Index = () => {
  // const [checked, setChecked] = useState(false);
  // const [showPopup, setShowPopup] = useState(false);
  const [listStyle, setListStyle] = useState<TListStyle>("card");
  const [ent, setEnt] = useState<TEntItem|null>(null)
  const [list, setList] = useState<TCorrectionItem[]>();

  const extraEnt: TEntItem[] = [{
    entName: '个人知识库',
    entId: undefined,
    expireTime: '0',
    isExpired: false,
    knowledgeCnt: 0
  }]


  // 渲染数据内容
  const renderScrollContent = () => {
    if (listStyle === "card") {
      return (
        <ViewStyleListCorrection
          setData={setList}
          entId={ent?.entId}
          viewStyle="card"
        />
      );
    }
    // return (
    //   <ViewStyleListCorrection
    //     setData={setList}
    //     entId={ent?.entId}
    //     viewStyle="list"
    //   />
    // );
  };
  console.log('渲染纠错模块')
  // 渲染主体
  const renderEmpty = () => {
    // 空数据
    if (list && !list.length) {
      return (
        <View className="flex-center pt-40">
          <EmptyData type={'whiteboard'}>
            <View className="text-center text-14 leading-28 text-gray-45 mb-44 w-[296px]">
              <View className="text-center text-16 leading-24 font-medium text-black">
                还没有纠正过的内容
              </View>
              <View>当你发现 AI 理解有误的知识点并进行修改后，</View>
              <View>会汇总在这里，用于优化AI回答。</View>
            </View>
          </EmptyData>
        </View>
      );
    }
    return <></>
  };

  return (
    <>
      <View className="px-16 h-full">
        <CompanyList currentEnt={ent} setCurrentEnt={setEnt} extraEnt={extraEnt}></CompanyList>
        {renderEmpty()}
        {renderScrollContent()}
      </View>
    </>
  );
};

export default Index;
