import { reduxForm } from 'redux-form';

import { createShuffle } from '../actions';
import ShuffleNew from '../components/ShuffleNew';

function validate(values) {
    const errors = {};

    if (!values.name) errors.name = 'Enter a name';
    if (!values.date) errors.date = 'Enter a date';
    if (!values.costPerTicket) errors.costPerTicket = 'Enter a cost per ticket';
    if (!values.numberOfTickets) errors.numberOfTickets = 'Enter the number of tickets';

    return errors;
}

export default reduxForm({
    form: 'ShuffleNew',
    fields: ['name', 'date', 'costPerTicket', 'numberOfTickets'],
    validate
}, null, { createShuffle })(ShuffleNew);
