import { DatePicker, Form, Input, InputNumber, Select } from "antd";
import React from "react";


interface Props extends BOOKLINK.BookLinkChildProps {
    vipDuration?: number;
}
/**
 * 年卡活动链接
 * @returns 
 */
const GiftActivityLinkDTO: React.FC<Props> = ({ restField, name, vipDuration = 1 }) => {
    console.log('-------->', vipDuration)

    return <>
        <Form.Item
            {...restField}
            name={[name, 'giftActivityLinkDTO', 'activityName']}
            label={<strong>活动名称</strong>}
            rules={[{ required: true, message: '请输入活动名称!' }]}
        >
            <Input placeholder="请输入活动名称" style={{ width: '100%' }} allowClear />
        </Form.Item>

        <Form.Item
            {...restField}
            name={[name, 'giftActivityLinkDTO', 'activityTime']}
            label={<strong>活动时间</strong>}
            rules={[{ required: true, message: '请选择活动时间!' }]}
        >
            <DatePicker.RangePicker />
        </Form.Item>
        <Form.Item
            {...restField}
            name={[name, 'giftActivityLinkDTO', 'vipDuration']}
            label={<strong>会员时长</strong>}
            rules={[{ required: true, message: '请选择会员时长!' }]}
        >
            <Select
                showSearch
                placeholder="请选择会员时长"
                filterOption={(input, option) =>
                    ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
                }
                allowClear
                options={[1, 2, 3, 4, 5].map(item => ({ label: item + '年', value: item }))}
            />
        </Form.Item>
        <Form.Item
            {...restField}
            name={[name, 'giftActivityLinkDTO', 'activityPrice']}
            rules={[{ required: true, message: `请输入活动价格（${300 * vipDuration}~5000）!` }]}
            label={<strong>活动价格</strong>}
        >
            <InputNumber suffix="元" min={300 * vipDuration} max={5000} placeholder={`请输入活动价格（${300 * vipDuration}~5000）!`} style={{ width: '100%' }} />
        </Form.Item>
        <Form.Item
            {...restField}
            name={[name, 'giftActivityLinkDTO', 'originalPrice']}
            rules={[{ required: true, message: '请输入原价!' }]}
            label={<strong>原价</strong>}
        >
            <InputNumber suffix="元" placeholder="请输入原价" style={{ width: '100%' }} />
        </Form.Item>
        <Form.Item
            {...restField}
            name={[name, 'giftActivityLinkDTO', 'rechargeCount']}
            label={<strong>充值次数</strong>}
            rules={[{ required: true, message: '请选择充值次数!' }]}
        >
            <Select
                showSearch
                placeholder="请选择充值次数"
                filterOption={(input, option) =>
                    ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
                }
                allowClear
                options={[{ label: '1次', value: 1 }, { label: '2次', value: 2 }, { label: '3次', value: 3 }]}
            />
        </Form.Item>
    </>
}

export default React.memo(GiftActivityLinkDTO);