import React, { useMemo } from 'react'
import TableData from '../../components/TableData'
import { columns } from './tableConfig'
import { useModel } from 'umi'
import HocError from '@/Hoc/HocError'
/**公众号付费粉丝30日激活趋势 */
function Page() {
    const { state: { dataSource }, getChannelActive } = useModel('useData.useTableData')
    //加工数据
    const data = useMemo(() => {
        if (dataSource) {
            return dataSource?.map((item: any, index: number) => {
                item['id'] = index
                return item
            })
        }
        return []
    }, [dataSource])
    //  //获取排序列表
     const sortArr = useMemo(() => {
        let arr: any[] = []
        columns().map((item: any) => {
            if (typeof item.title === 'string') {
                arr.push({ title: item.title, value: item.dataIndex ,key:item.dataIndex })
            }
            if(typeof item.title === 'object' && typeof  item.title.props.children[0] === 'string' ){
                arr.push({ title: item.title, value: item.dataIndex ,key:item.dataIndex })
            }
        })
        return arr
    }, [columns])
    return <>
        <TableData
            isGroupTab={false}
            isAdmin
            isSelctAcc
            isUserId
            isDataSelectPitcher
            isDataSelectPitcher_isDisabled
            isTableDateArr
            sortArr={sortArr}
            columns={columns}
            dataSource={data}
            ajax={getChannelActive}
            title='公众号付费粉丝30日激活趋势'
            scroll={{x:1000,y:600}}
            // isTdColor
        />
    </>
}

export default HocError(Page)