import './proj-create.css'
import { useNavigate } from "react-router-dom";
import { message } from "antd";
import CardProjType from "../../components/card/CardProjType.tsx";
import { IProjCharge, ProjAdditionalType, ProjChargeType } from "../../interfaces/proj/IProj.ts";
import { useEffect, useState } from "react";
import { get } from "../../util/AjaxUtils.ts";
// import { Link } from "react-router-dom";

export default function ProjCreate() {
    const [messageApi, contextHolder] = message.useMessage();
    const [charge, setCharge] = useState<IProjCharge>({
        proj: {
            all: 0,
            materialAgent: 0,
            materialAgentUrgent: 0,
            material: 0,
            free: 0,
        },
        additional: {
            pkg: 0, 
            videoDemo: 0
        }
    });
    const nav = useNavigate();
    const height = window.innerHeight - 170;
    useEffect(() => {
        get<any>({
            messageApi: messageApi,
            url: '/api/proj/charge/get',
            onSuccess({ data }) {
                setCharge(data);
                // console.log('后面的price',data.proj.materialAgent);

            }
        })
        // sessionStorage.setItem('pathArray', JSON.stringify([ { title: <Link to={'/home'}>首页</Link> },{ title: '创建项目' }]));
        // sessionStorage.setItem('now', '创建');
    }, [])

    return (
        < >
            {contextHolder}
            <div style={{ }}>
                <div className="proj-create" style={{height: `${height}px`, overflow: 'auto' }}>
                    {/* <CardProjType
                        head={'全托'}
                        bodyLineArray={[
                            {
                                title: '提供的服务：',
                                contents: [
                                    '提供系统搭建',
                                    '系统可在线运行三年',
                                    '软著材料编写',
                                    '软著申报',
                                    '包下证',
                                    '提供系统演示视频文件',
                                    '提供系统安装包'
                                ]
                            },
                              
                        ]}
                        newArray={[
                            {
                                title: '使用流程：',
                                contents: [
                                    '系统操作手册执行',
                                ]
                            }
                        ]
                        }
                        buyArray={[
                            {
                                id: ProjChargeType.ALL,
                                price: charge.proj.all,
                                handleClick: () => {
                                    nav(`/proj-new/${ProjChargeType.ALL}`)
                                }
                            }
                        ]}
                    /> */}
                    {/* <CardProjType
                        head={'写材料+代理'}
                        bodyLineArray={[
                            {
                                title: '提供的服务：',
                                contents: [
                                    '提供系统搭建平台与客服指导',
                                    '系统可在线运行一年',
                                    '软著材料编写',
                                    '资料补正不限',
                                    '软著申报',
                                    '包下证'
                                ]
                            },
                            
                        ]}
                        newArray={[
                            {
                                title: '使用流程：',
                                contents: [
                                    '系统操作手册执行',
                                ]
                            }
                        ]
                        }
                        buyArray={[
                            {
                                id: ProjChargeType.MATERIAL_AGENT,
                                label: '普件：',
                                price: charge.proj.materialAgent,
                                handleClick: (_title, additional) => {
                                    nav(`/proj-new/${ProjChargeType.MATERIAL_AGENT}?pkg=${additional.pkg}&videoDemo=${additional.videoDemo}`)
                                }
                            },
                            {
                                id: ProjChargeType.MATERIAL_AGENT_URGENT,
                                label: '加急：',
                                price: charge.proj.materialAgentUrgent,
                                handleClick: (_title, additional) => {
                                    nav(`/proj-new/${ProjChargeType.MATERIAL_AGENT_URGENT}?pkg=${additional.pkg}&videoDemo=${additional.videoDemo}`)
                                }
                            }
                        ]}
                        chargeLineArray={[
                            {
                                id: ProjAdditionalType.PKG,
                                price: charge.additional.pkg,
                                title: `安装包 ${charge.additional.pkg / 100} 元`
                            },
                            {
                                id: ProjAdditionalType.VIDEO_DEMO,
                                price: charge.additional.videoDemo,
                                title: `系统演示视频文件 ${charge.additional.videoDemo / 100} 元`
                            }
                        ]}
                    /> */}
                     <CardProjType
                        head={'写材料'}
                        bodyLineArray={[
                            {
                                title: '提供的服务：',
                                contents: [
                                    '提供系统搭建平台与客服指导',
                                    '系统可在线运行一年',
                                    '软著材料编写',
                                    '资料补正三次',
                                   
                                ]
                            },
                        ]}
                        newArray={[
                            {
                                title: '使用流程：',
                                contents: [
                                    '系统操作手册执行',
                                   
                                ]
                            }
                        ]
                        }
                        chargeLineArray={[
                            {
                                id: ProjAdditionalType.PKG,
                                price: charge.additional.pkg,
                                title: `安装包 ${charge.additional.pkg / 100} 元`
                            },
                            {
                                id: ProjAdditionalType.VIDEO_DEMO,
                                price: charge.additional.videoDemo,
                                title: `系统演示视频文件 ${charge.additional.videoDemo / 100} 元`
                            }
                        ]}
                        buyArray={[
                            {
                                id: ProjChargeType.MATERIAL,
                                price: charge.proj.material,
                                handleClick: (_title, additional) => {
                                    nav(`/proj-new/${ProjChargeType.MATERIAL}?${additional.pkg ? 'pkg=true' : 'pkg='}&${additional.videoDemo ? 'videoDemo=true' : 'videoDemo='}`);
                                }
                            }
                        ]}
                    />
                     {/* <CardProjType
                        head={'免费试用'}
                        bodyLineArray={[
                            {
                                title: '提供的服务：',
                                contents: [
                                    '提供系统搭建平台与客服指导',
                                    '系统可在线存储三天',
                                ]
                            },
                            
                        ]}
                        newArray={[
                            {
                                title: '使用流程：',
                                contents: [
                                    '系统操作手册执行',
                                ]
                            }
                        ]
                        }
                        buyArray={[
                            {
                                id: ProjChargeType.FREE,
                                price: charge.proj.free,
                                handleClick: (_title, additional) => {
                                    nav(`/proj-new/${ProjChargeType.FREE}?${additional.pkg ? 'pkg=true' : 'pkg='}&${additional.videoDemo ? 'videoDemo=true' : 'videoDemo='}`)
                                }
                            }
                        ]}
                    /> */}
                </div>
            </div>
        </>
    )
}