import { MyPageContainer } from '@/common';
import { Apis } from '@/gen/Apis';
import { ProCard } from '@ant-design/pro-components';
import { useParams } from '@umijs/max';
import { Tabs } from 'antd';
import { useEffect, useState } from 'react';
import HouseInfo from './components/HouseInfo';
import OccupantsNow from './table/OccupantsNow';

export default function Show({ title = '房屋详情' }) {
  const { id } = useParams<{ id: string }>();
  const [data, setShow] = useState<any>({});
  const loadShow = () => {
    let paramsId: any = { id: id ?? 0 };
    Apis.Asset.AssetHouses.Show(paramsId).then((res) => {
      setShow(res?.data);
    });
  };
  useEffect(() => {
    loadShow();
  }, [id]);

  let items = [
    {
      label: '当前档案',
      key: '1',
      closable: false,
      children: (
        <OccupantsNow
          item={{ asset_houses_id: id }}
          reload={() => loadShow()}
        />
      ),
    },
    {
      label: '历史档案',
      key: '2',
      closable: false,
      // children: <MyAssetBuildings item={data} />,
    },
  ];

  return (
    <MyPageContainer title={title}>
      <HouseInfo item={data} />
      <ProCard>
        <Tabs type="card" items={items} />
      </ProCard>
    </MyPageContainer>
  );
}
