import React from 'react';
import PaymentMethodBase from './paymentmethodbase.jsx';

var id = 0;

export default class Invoice extends PaymentMethodBase {

    constructor(props){
        super(props);
        this.id = `invoice-${id++}`;
    }

    getData() {
        return {
            'email': this.emailInput.value
        };
    }

    isValid() {
        return this.emailInput.value ? true : false;
    }

    render() {
        return (
            <div className="payment__invoice">
                <label
                    htmlFor={this.id}
                    className="payment__invoice__label">
                    Your e-mail address
                </label>
                <input
                    id={this.id}
                    ref={input => { this.emailInput = input; }}
                    className="payment__invoice__text-input"
                    type="email"
                    onBlur={event => this.onInputBlur(event)} />
            </div>
        );
    }
}