import * as React from "react";
import Util from "../../../util/utils";
import CouponWrapper from '../commen/wrapper'
import CouponItem from '../commen/item'
import CouponFun from "../commen/util";
import CouponCon from "../commen/couponCon";

/*
* 左右锯齿状优惠券
*/
class CouponTwo extends React.Component<any, any> {
    constructor(props) {
        super(props);
        this.state = {
            list: []
        }
    }

    componentDidMount(): void {

    }

    render(): React.ReactElement<any> | string | number | {} | React.ReactNodeArray | React.ReactPortal | boolean | null | undefined {
        let list = this.props.list;

        if (list && list.length > 0) {
            let len = list.length;
            return (
                <div className={'MCoupon_container_two'}>
                    <CouponWrapper className={(list.length <= 2 ? 'MCoupon_wrapper_flex' : '')
                    + (list.length == 1 ? ' MCoupon_wrapper_1' : '')}
                    >
                        {
                            list.map((item, index) => (
                                <CouponItem key={index}>
                                    <CouponCon data={item}
                                               {...CouponFun.initParams(this.props)}
                                               index={index}
                                               length={len}
                                               bgColor={this.props.bgColor}
                                               vars={['topCircle', 'bottomCircle']}
                                    ></CouponCon>
                                </CouponItem>
                            ))
                        }
                    </CouponWrapper>
                </div>
            );
        } else {
            return null;
        }


    }
}

export default CouponTwo;