import useNewToken from '@/Hook/useNewToken';
import LookMsg from '@/pages/weComTask/components/previewMsg/lookMsg';
import { getMsgData } from '@/pages/weComTask/page/businessPlan/create/components/massSending/showContent';
import { welcomeContentData } from '@/pages/weComTask/page/businessPlan/create/const';
import { Empty, Tabs, Typography } from 'antd';
import React, { useState } from 'react';
const { Text } = Typography;

interface PreviewGroupUserProps {
    strategyList: { [x: string]: any }[];
}

/**
 * 朋友圈内容预览
 * @param param0 
 * @returns 
 */
const PreviewMomentsContent: React.FC<PreviewGroupUserProps> = ({ strategyList }) => {

    /****************************************/
    const [activeKey, setActiveKey] = useState<string>('1')
    const { token } = useNewToken()
    /****************************************/

    return <Tabs
        activeKey={activeKey}
        tabPosition='left'
        style={{
            height: '100%',
            width: '100%'
        }}
        onChange={(key) => { setActiveKey(key) }}
        items={strategyList.map((item, index) => {
            return {
                label: <div style={{ maxWidth: 100 }}><Text>{item.strategyName}</Text></div>,
                key: `${index + 1}`,
                children: <div style={{ width: '100%', height: 282, overflow: 'hidden', overflowY: 'auto' }}>
                    {item?.taskDetail?.contentDTO?.length > 0 ? <>
                        <div style={{ backgroundColor: token.colorPrimary, padding: 4, color: '#FFF', fontSize: 12 }}>
                            <div>
                                发送模式：{welcomeContentData?.find(i => i.value === item?.taskDetail?.sendMode)?.label}
                            </div>
                        </div>
                        {item?.taskDetail?.contentDTO?.map((item, index) => {
                            return <div key={index} style={{ marginTop: 5, backgroundColor: '#f1f1f1', borderRadius: 6, padding: '5px 10px 16px' }}>
                                <h3 style={{ textAlign: 'center' }}>内容{index + 1}</h3>
                                <LookMsg data={getMsgData(item, token)} />
                            </div>
                        })}
                    </> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />}
                </div>
            }
        })}
    />;
};

export default PreviewMomentsContent;