import React, { useState } from 'react';
import { Tabs } from 'antd';
import { useIntl } from 'umi';
import BaseInfoTab from './component/BaseInfoTab';
import QualificationTab from './component/QualificationTab';
import InvoiceTab from './component/InvoiceTab';
import AttachmentsTab from './component/AttachmentsTab';
import ContactsInfoTab from './component/ContactsInfoTab';
import BankInfoTab from './component/BankInfoTab';

interface CompanyInfoProps {
  viewType?: boolean;
}

const { TabPane } = Tabs;

const CompanyInfo: React.FC<CompanyInfoProps> = (props) => {
  const { viewType = false } = props;
  const intl = useIntl();
  // 切换tab
  const [subTab, setSubTab] = useState<string>('base');

  return (
    <Tabs activeKey={subTab} onChange={setSubTab}>
      <TabPane tab={intl.formatMessage({ id: 'page.workbench.base' })} key="base">
        <BaseInfoTab viewType={viewType} />
      </TabPane>
      <TabPane tab={intl.formatMessage({ id: 'page.workbench.qualification' })} key="qualification">
        <QualificationTab viewType={viewType} />
      </TabPane>
      <TabPane tab={intl.formatMessage({ id: 'page.workbench.invoice' })} key="invoice">
        <InvoiceTab viewType={viewType} />
      </TabPane>
      <TabPane tab={intl.formatMessage({ id: 'page.workbench.bank' })} key="bank">
        <BankInfoTab viewType={viewType} />
      </TabPane>
      <TabPane tab={intl.formatMessage({ id: 'page.workbench.attachments' })} key="attachments">
        <AttachmentsTab viewType={viewType} />
      </TabPane>
      <TabPane tab={intl.formatMessage({ id: 'page.workbench.contacts' })} key="contacts">
        <ContactsInfoTab />
      </TabPane>
    </Tabs>
  );
};

export default CompanyInfo;