
import HocError from '@/Hoc/HocError'
import { Tabs } from 'antd'
import React, { useState } from 'react'
import { useModel } from 'umi'
import './index.less'
import Monitor from './monitor'
import PlanList from './planList'
/**广告监控 */
function AdMonitorList() {

    // 变量开始
    const [tab, setTab] = useState<string>('monitor')  // tab切换
    const { getPlanList, getPlanDetailList, getAllPlanList } = useModel('useLaunch.useMonitor')
    // 变量结束
    
    return <div className="adMonitorList">
        <Tabs activeKey={tab} className="adMonitorListTab" type="card" onChange={(activeKey: string) => { 
            if (activeKey === 'monitor') {
                getAllPlanList.mutate([])
            } else {
                getPlanList.mutate([])
                getPlanDetailList.mutate([])
            }
            setTab(activeKey) 
        }}>
            <Tabs.TabPane tab="今日起量广告监控" key="monitor" />
            <Tabs.TabPane tab="广告列表" key="list" />
        </Tabs>
        {tab === 'monitor' ? <Monitor onChange={() => { setTab('list') }} /> : tab === 'list' ? <PlanList /> : null}
    </div>
}

export default HocError(AdMonitorList)