<commit_before>import React from "react";
import idx from "idx";
import { connect } from "react-redux";
import { withRouter } from "react-router-dom";
import { Form, Field, FormSpy } from "react-final-form";
import arrayMutators from "final-form-arrays";
import { FieldArray } from "react-final-form-arrays";
import { PlusIcon, XIcon } from "react-open-iconic-svg";
import { Input, NumberInput, Select } from "../form/Fields.jsx";
import { FormContainer, InlineFormContainer, PlainFormContainer } from "../form/Fields.jsx";
import { editTodo, updateTodo, fetchCountries, fetchTodoList } from "../../actions/todoActions";
import Modal from "../Modal.jsx";

// const FormInput = Input(FormContainer);
// const FormNumberInput = NumberInput(FormContainer);
// const FormSelect = Select(FormContainer);

const InlineContainer = InlineFormContainer(2);
const BaseInput = Input(FormContainer);
const FormInput = Input(InlineContainer);
const FormNumberInput = NumberInput(InlineContainer);
const FormSelect = Select(InlineContainer);

const PlainFormInput = Input(PlainFormContainer);

const EditTodo = ({ editTodo, typeList, countryList, onCancel, onSave }) => {
    return (
        <Modal show={editTodo != null} title="Form" onCancel={onCancel}>
            <Form
                subscription={{ submitting: true, pristine: true }}
                mutators={{
                    ...arrayMutators
                }}
                initialValues={editTodo}
                validate={validate}
                onSubmit={onSave}
            >
                {({
                    handleSubmit,
                    submitting,
                    form,
                    form: {
                        mutators: { push, pop }
                    }
                }) => (
                    <form onSubmit={handleSubmit}>
                        <Field name="task" component={BaseInput} type="text" label="Task" />
                        <Field name="email" component={BaseInput} type="email" label="Email" />
                        <hr/>
                        <Field name="hour" component={FormNumberInput} label="Hour" prefix="" decimalScale={2} fixedDecimalScale={true} />
                        <Field name="type" component={FormSelect} label="Account Type" options={typeList} />
                        <FormSpy subscription={{ values: true }}>
                            {props => {
                                const isWork = idx(props, _ => _.values.type) == "work";
                                const countries = !isWork ? countryList : countryList.filter(country => country.value == "AU");
                                return <Field name="country" component={FormSelect} label="Country" options={countries} />;
                            }}
                        </FormSpy>
                        <hr/><commit_msg>fix modal title<commit_after>import React from "react";
import idx from "idx";
import { connect } from "react-redux";
import { withRouter } from "react-router-dom";
import { Form, Field, FormSpy } from "react-final-form";
import arrayMutators from "final-form-arrays";
import { FieldArray } from "react-final-form-arrays";
import { PlusIcon, XIcon } from "react-open-iconic-svg";
import { Input, NumberInput, Select } from "../form/Fields.jsx";
import { FormContainer, InlineFormContainer, PlainFormContainer } from "../form/Fields.jsx";
import { editTodo, updateTodo, fetchCountries, fetchTodoList } from "../../actions/todoActions";
import Modal from "../Modal.jsx";

// const FormInput = Input(FormContainer);
// const FormNumberInput = NumberInput(FormContainer);
// const FormSelect = Select(FormContainer);

const InlineContainer = InlineFormContainer(2);
const BaseInput = Input(FormContainer);
const FormInput = Input(InlineContainer);
const FormNumberInput = NumberInput(InlineContainer);
const FormSelect = Select(InlineContainer);

const PlainFormInput = Input(PlainFormContainer);

const EditTodo = ({ editTodo, typeList, countryList, onCancel, onSave }) => {
    return (
        <Modal show={editTodo != null} title="Todo" onCancel={onCancel}>
            <Form
                subscription={{ submitting: true, pristine: true }}
                mutators={{
                    ...arrayMutators
                }}
                initialValues={editTodo}
                validate={validate}
                onSubmit={onSave}
            >
                {({
                    handleSubmit,
                    submitting,
                    form,
                    form: {
                        mutators: { push, pop }
                    }
                }) => (
                    <form onSubmit={handleSubmit}>
                        <Field name="task" component={BaseInput} type="text" label="Task" />
                        <Field name="email" component={BaseInput} type="email" label="Email" />
                        <hr/>
                        <Field name="hour" component={FormNumberInput} label="Hour" prefix="" decimalScale={2} fixedDecimalScale={true} />
                        <Field name="type" component={FormSelect} label="Account Type" options={typeList} />
                        <FormSpy subscription={{ values: true }}>
                            {props => {
                                const isWork = idx(props, _ => _.values.type) == "work";
                                const countries = !isWork ? countryList : countryList.filter(country => country.value == "AU");
                                return <Field name="country" component={FormSelect} label="Country" options={countries} />;
                            }}
                        </FormSpy>
                        <hr/>
{'fraction_non_alphanumeric': 0.12297962052002812, 'fraction_numerical': 0.0007027406886858749, 'mean_word_length': 1.9574025974025975, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6067143', 'n_tokens_mistral': 1430, 'n_tokens_neox': 1377, 'n_words': 335}