import React from 'react';
import ReactDOM from 'react-dom';
import { BankAccount } from 'web-foundation';

const bankAccount = new BankAccount.Model();

class BankAccountExample extends React.Component {
    onClick() {
        console.log('errors:', this._account.model.errors); // eslint-disable-line
        console.log(bankAccount.out()); // eslint-disable-line
    }

    validate() {
        this._account.formValidate();
    }

    render() {
        return (
            <div>
                <BankAccount.View
                    inlineErrors
                    ref={ (n) => (this._account = n) }
                    model={ bankAccount } />
                <button onClick={ this.onClick.bind(this) }>out</button>
                <button onClick={ this.validate.bind(this) }>validate</button>
            </div>
        );
    }
}

export default function() {
    ReactDOM.render(
        <BankAccountExample />,
        document.getElementById('bank-account')
    );
}
