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
    //     },
    //     projTypes:[
    //         {}
    //     ]
    // });
    const [charge, setCharge] = useState<any>({}) //安装包信息
    const [allInfo, setAllInfo] = useState<any>({}) //全部托管信息
    const [materialInfo, setMaterialInfo] = useState<any>({}) //写材料信息
    const [freeInfo, setFreeInfo] = useState<any>({}) //免费托管信息
    const [ freeCount,setFreeCount] = useState(0) //免费次数
    const nav = useNavigate();
    const height = window.innerHeight - 170;
    useEffect(() => {
        get<any>({
            messageApi: messageApi,
            url: '/api/proj/charge/get',
            onSuccess({ data }) {
                setCharge(data.additional);
                console.log("创建数据", data);
                // console.log(charge.projTypes[0].price);
                setAllInfo(data.projTypes[0])
                setMaterialInfo(data.projTypes[1])
                setFreeInfo(data.projTypes[2])
                // console.log('后面的price',data.proj.materialAgent);
                setFreeCount(data.freeCount)
            }
        })
        // sessionStorage.setItem('pathArray', JSON.stringify([ { title: <Link to={'/home'}>首页</Link> },{ title: '创建项目' }]));
        // sessionStorage.setItem('now', '创建');
        console.log(allInfo);
        
    }, [])

    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: allInfo.price,
                                handleClick: () => {
                                    nav(`/proj-new/${ProjChargeType.ALL}`)
                                }
                            }
                        ]}
                    isShow = {allInfo.isShow}
                    isClickable = {allInfo.isClickable}
                    />
                    {/* <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.pkg,
                                title: `安装包 ${charge.pkg / 100} 元`
                               
                            },
                            {
                                id: ProjAdditionalType.VIDEO_DEMO,
                                price: charge.videoDemo,
                                title: `系统演示视频文件 ${charge.videoDemo / 100} 元`
                               
                            }
                        ]}
                        buyArray={[
                            {
                                id: ProjChargeType.MATERIAL,
                                price: materialInfo.price,
                                handleClick: (_title, additional) => {
                                    nav(`/proj-new/${ProjChargeType.MATERIAL}?${additional.pkg ? 'pkg=true' : 'pkg='}&${additional.videoDemo ? 'videoDemo=true' : 'videoDemo='}`);
                                }
                            }
                        ]}
                        isShow = {materialInfo.isShow}
                        isClickable = {materialInfo.isClickable}
                    />
                    <CardProjType
                        head={`免费试用${freeCount}次`}
                        bodyLineArray={[
                            {
                                title: '提供的服务：',
                                contents: [
                                    '提供系统搭建平台与客服指导',
                                    '系统可在线存储三天',
                                ]
                            },
                            
                        ]}
                        newArray={[
                            {
                                title: '使用流程：',
                                contents: [
                                    '系统操作手册执行',
                                ]
                            }
                        ]
                        }
                        buyArray={[
                            {
                                id: ProjChargeType.FREE,
                                price: freeInfo.price,
                                handleClick: (_title, additional) => {
                                    nav(`/proj-new/${ProjChargeType.FREE}?${additional.pkg ? 'pkg=true' : 'pkg='}&${additional.videoDemo ? 'videoDemo=true' : 'videoDemo='}`)
                                }
                            }
                        ]}
                        isShow = {freeInfo.isShow}
                        isClickable = {freeInfo.isClickable}
                    />
                </div>
            </div>
        </>
    )
}