import { Avatar, Badge, Space, Tooltip } from "antd"
import { ColumnsType } from "antd/es/table"
import { UserOutlined } from '@ant-design/icons'


export function corpExternalUserListConfig(): ColumnsType<any> {
    let arr: ColumnsType<any> = [
        {
            title: '客户',
            dataIndex: 'name',
            key: 'name',
            width: 90,
            render: (a: string, b: any) => {
                return <Space>
                    <Avatar shape="square" size="small" icon={<UserOutlined />} src={b?.avatar} />
                    <span>{a}</span>
                </Space>
            }
        },
        {
            title: '性别',
            dataIndex: 'gender',
            key: 'gender',
            align: 'center',
            width: 80,
            render: (a) => {
                return a === 1 ? '男性' : a === 2 ? '女性' : '未知'
            }
        },
        {
            title: '所属企业',
            dataIndex: 'corpName',
            key: 'corpName',
            align: 'center',
            width: 120,
        },
        {
            title: '企微号',
            dataIndex: 'corpUserName',
            key: 'corpUserName',
            align: 'center',
            width: 80,
        },
        {
            title: '发送时间',
            dataIndex: 'createTime',
            key: 'createTime',
            align: 'center',
            width: 80,
        },
        {
            title: '状态',
            dataIndex: 'sendStatus',
            key: 'sendStatus',
            align: 'center',
            width: 80,
            render: (a, b) => {
                return <Badge text={a ? '已送达' : '未送达'} status={a ? 'success' : 'default'} />
            }
        },
        {
            title: '发送日志',
            dataIndex: 'sendLog',
            key: 'sendLog',
            align: 'center',
            width: 250,
            ellipsis: {
                showTitle: false
            },
            render: (a) => {
                return a ? <Tooltip title={a}>
                    <span>{a}</span>
                </Tooltip> : ''
            }
        },
    ]
    return arr
}

export function WelcomeMsgCorpUserListConfig(): ColumnsType<any> {
    let arr: ColumnsType<any> = [
        {
            title: '企微号',
            dataIndex: 'corpUserName',
            key: 'corpUserName',
            align: 'center',
            width: 80,
        },
        {
            title: '所属企业',
            dataIndex: 'corpName',
            key: 'corpName',
            align: 'center',
            width: 120,
        },
        {
            title: '添加时间',
            dataIndex: 'configTime',
            key: 'configTime',
            align: 'center',
            width: 80,
            render: (a: string) => {
                return a || '暂未添加'
            }
        },
    ]
    return arr
}