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 MyAssetBuildings from './components/AssetBuildings';
import MyInfo from './components/info';
import Update from './modals/Update';
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.AssetProjects.Show(paramsId).then((res) => {
      setShow(res?.data);
    });
  };
  useEffect(() => {
    loadShow();
  }, [id]);

  let items = [
    {
      label: '楼栋管理',
      key: 'asset_buildings',
      closable: false,
      children: <MyAssetBuildings item={data} />,
    },
  ];
  return (
    <MyPageContainer title={title}>
      <MyInfo
        item={data}
        extra={<Update item={data} reload={() => loadShow()} title="项目" />}
      />
      <ProCard>
        <Tabs type="card" items={data?.id ? items : []} />
      </ProCard>
    </MyPageContainer>
  );
}
