import { Checkbox, DatePicker, Form, Input, InputNumber, Radio, Space } from "antd";
import React from "react";
import { DISPLAYTYPEHUASHENG } from "../../const";


/**
 * 花生充值活动
 * @returns 
 */
const RechargeActivityLinkDTO: React.FC<BOOKLINK.BookLinkChildProps> = ({ restField, name, itemData }) => {

    return <>
        <Form.Item
            {...restField}
            name={[name, 'rechargeActivityLinkDTO', 'activityName']}
            label={<strong>活动名称</strong>}
            rules={[{ required: true, message: '请输入活动名称!' }]}
        >
            <Input placeholder="请输入活动名称" style={{ width: '100%' }} allowClear />
        </Form.Item>
        <Form.Item
            label={<strong>充值档位</strong>}
            required
        >
            <Space>
                <Form.Item
                    {...restField}
                    name={[name, 'rechargeActivityLinkDTO', 'rechargeAmount']}
                    rules={[{ required: true, message: '请输入价位!' }]}
                    noStyle
                >
                    <InputNumber addonBefore="价位" suffix="元" placeholder="请输入" style={{ width: '100%' }} />
                </Form.Item>
                <Form.Item
                    {...restField}
                    name={[name, 'rechargeActivityLinkDTO', 'giftAmount']}
                    rules={[{ required: true, message: '请输入赠送金额!' }]}
                    noStyle
                >
                    <InputNumber addonBefore="赠送" suffix="元" placeholder="请输入" style={{ width: '100%' }} />
                </Form.Item>
            </Space>
        </Form.Item>

        <Form.Item
            {...restField}
            name={[name, 'rechargeActivityLinkDTO', 'activityTime']}
            label={<strong>活动时间</strong>}
            rules={[{ required: true, message: '请选择活动时间!' }]}
        >
            <DatePicker.RangePicker />
        </Form.Item>
        <Form.Item
            {...restField}
            name={[name, 'rechargeActivityLinkDTO', 'status']}
            label={<strong>活动状态</strong>}
            rules={[{ required: true, message: '请选择活动状态!' }]}
        >
            <Radio.Group
                optionType='button'
                buttonStyle="solid"
                options={[
                    { value: 'normal', label: '上架' },
                    { value: 'del', label: '下架' }
                ]}
            />
        </Form.Item>
        <Form.Item
            {...restField}
            name={[name, 'rechargeActivityLinkDTO', 'chargeType']}
            label={<strong>限购类型</strong>}
            rules={[{ required: true, message: '请选择限购类型!' }]}
        >
            <Radio.Group
                optionType='button'
                buttonStyle="solid"
                options={[
                    { value: 0, label: '整体限购' },
                    { value: 1, label: '每天限购' }
                ]}
            />
        </Form.Item>
        <Form.Item
            {...restField}
            name={[name, 'rechargeActivityLinkDTO', 'display']}
            label={<strong>活动展示位</strong>}
        >
            <Checkbox.Group options={Object.keys(DISPLAYTYPEHUASHENG).map(key => ({ label: DISPLAYTYPEHUASHENG[key], value: key }))} />
        </Form.Item>
        <Form.Item
            {...restField}
            name={[name, 'rechargeActivityLinkDTO', 'chargeCount']}
            label={<strong>限购次数</strong>}
            rules={[{ required: true, message: '请选择充值次数!' }]}
        >
            <InputNumber placeholder="请输入" min={0} style={{ width: '100%' }} />
        </Form.Item>
        <Form.Item
            {...restField}
            name={[name, 'rechargeActivityLinkDTO', 'userType']}
            label={<strong>展示粉丝</strong>}
            rules={[{ required: true, message: '请选择展示粉丝!' }]}
        >
            <Radio.Group
                optionType='button'
                buttonStyle="solid"
                options={[
                    { value: 1, label: '全部粉丝' },
                    { value: 2, label: '条件粉丝' }
                ]}
            />
        </Form.Item>
        {itemData?.rechargeActivityLinkDTO?.userType === 2 && <>
            <Form.Item
                {...restField}
                name={[name, 'rechargeActivityLinkDTO', 'charge']}
                label={<strong>充值状态</strong>}
                rules={[{ required: true, message: '请选择充值状态!' }]}
            >
                <Radio.Group
                    optionType='button'
                    buttonStyle="solid"
                    options={[
                        { value: 0, label: '不限' },
                        { value: 1, label: '已充值' },
                        { value: 2, label: '未充值' }
                    ]}
                />
            </Form.Item>
            <Form.Item
                {...restField}
                name={[name, 'rechargeActivityLinkDTO', 'commonType']}
                label={<strong>关注时间</strong>}
                rules={[{ required: true, message: '请选择关注时间!' }]}
            >
                <Radio.Group
                    optionType='button'
                    buttonStyle="solid"
                    options={[
                        { value: 0, label: '不限' },
                        { value: 1, label: '24小时以上' },
                        { value: 2, label: '48小时以上' },
                        { value: 3, label: '72小时以上' }
                    ]}
                />
            </Form.Item>
        </>}
    </>
}

export default React.memo(RechargeActivityLinkDTO);