"use client";
import React, {useState} from 'react'
import PopupHby from "@/app/[locale]/(TabBar)/(entire)/promo/PopupHby";
import Box from "@/components/Box";


const Promo =  ({promotion}:any) => {
    const [isShowRedPacket, setIsShowRedPacket] = useState<any>(false);
   

    const onGoPromo = (e:any,item:any) => {
        e.stopPropagation();
        console.log('onGoPromo',item)
        // 4:跳转弹窗,action_params==>red_packet:代表红包雨弹窗
        if(item.action_type === 4 && item.action_params === 'red_packet'){
          setIsShowRedPacket(true)
        }
    }

    return (
        <>
            {promotion.map((item:any, index:number) => (
                <Box key={item.id} action={item.action_type} actionData={item.action_params} >
                    <img
                        width={0}
                        height={0}
                        src={item.content!}
                        alt={"Image"}
                        className={"h-[1.16rem] w-[100%] rounded-[0.0833rem]"}
                        onClick={(e) => onGoPromo(e,item)}
                    />
                </Box>
            ))}
            {/* 红包弹窗 */}
            {
              isShowRedPacket && (<PopupHby  onClose={()=>{setIsShowRedPacket(false)}} />)
            }
        </>
    );
};

export default Promo;
