diff --git a/javascripts/src/components/common/fields.tsx b/javascripts/src/components/common/fields.tsx index d5cf690b..998fe103 100644 --- a/javascripts/src/components/common/fields.tsx +++ b/javascripts/src/components/common/fields.tsx @@ -5,15 +5,16 @@ import {Field} from "../../../../types/mobx-react-form"; import LabeledFieldComponent from "./LabeledFieldComponent"; import {injectIntl, InjectedIntl} from 'react-intl'; import {HoudiniField} from "../../lib/houdini_form"; +import ReactInput from "./form/ReactInput"; -export const BasicField = injectIntl(observer((props:{field:Field, intl?:InjectedIntl, wrapperClassName?:string}) =>{ +export const BasicField = observer((props:{field:Field, placeholder?:string, label?:string, wrapperClassName?:string}) =>{ let field = props.field as HoudiniField return - + -})) \ No newline at end of file +}) \ No newline at end of file diff --git a/javascripts/src/components/common/form/ReactForm.tsx b/javascripts/src/components/common/form/ReactForm.tsx index 0abe4b5c..c61a828b 100644 --- a/javascripts/src/components/common/form/ReactForm.tsx +++ b/javascripts/src/components/common/form/ReactForm.tsx @@ -10,7 +10,8 @@ export interface ReactFormProps } ///Mostly useless class but, at some point, will replace all our form elements -class ReactForm extends React.Component { +@observer +export class ReactForm extends React.Component { @@ -43,7 +44,6 @@ class ReactForm extends React.Component { } } -export default observer(ReactForm) diff --git a/javascripts/src/components/common/form/ReactInput.spec.tsx b/javascripts/src/components/common/form/ReactInput.spec.tsx index 204e9982..b2a030fe 100644 --- a/javascripts/src/components/common/form/ReactInput.spec.tsx +++ b/javascripts/src/components/common/form/ReactInput.spec.tsx @@ -3,11 +3,11 @@ import * as React from 'react'; import 'jest'; import ReactInput from './ReactInput' import {Form} from "mobx-react-form"; -import ReactForm from "./ReactForm"; import {mount} from 'enzyme'; import {toJS, observable, action, runInAction} from 'mobx'; import {observer} from 'mobx-react'; import {InputHTMLAttributes} from 'react'; +import {ReactForm} from "./ReactForm"; @@ -99,7 +99,9 @@ describe('ReactInput', () => { let res = mount() - let f = res.find('ReactForm').instance() as ReactForm + // The two casts are needed because Typescript was going blowing up without the 'any' first. + // Why was it? *shrugs* + let f = res.find('ReactForm').instance() as any as ReactForm expect(f.form.size).toEqual(1) res.find('input').simulate('change', {target: { value: 'something' } }) @@ -146,7 +148,7 @@ describe('ReactInput', () => { let res = mount( ) - let f = res.find('ReactForm').instance() as ReactForm + let f = res.find('ReactForm').instance() as any as ReactForm res.find('input').simulate('change', {target: { value: 'something' } }) expect(f.form.$('name').value).toEqual('something') diff --git a/javascripts/src/components/common/form/ReactInput.tsx b/javascripts/src/components/common/form/ReactInput.tsx index 53fb4da4..d63d756c 100644 --- a/javascripts/src/components/common/form/ReactInput.tsx +++ b/javascripts/src/components/common/form/ReactInput.tsx @@ -6,12 +6,13 @@ import {Field} from "mobx-react-form"; import {observable, action, toJS, runInAction} from 'mobx'; import {InputHTMLAttributes} from 'react'; + + export interface ReactInputProps { field:Field label?:string placeholder?:string - children: React.ReactElement> } function castToNullIfUndef(i:any){ diff --git a/javascripts/src/components/registration_page/NonprofitInfoForm.tsx b/javascripts/src/components/registration_page/NonprofitInfoForm.tsx index 03cb577c..1299920c 100644 --- a/javascripts/src/components/registration_page/NonprofitInfoForm.tsx +++ b/javascripts/src/components/registration_page/NonprofitInfoForm.tsx @@ -17,47 +17,31 @@ export interface NonprofitInfoFormProps export const FieldDefinitions : Array = [ { name: 'organization_name', - label: 'registration.wizard.nonprofit.name.label', - placeholder: 'registration.wizard.nonprofit.name.placeholder', - type: 'text', validators: [Validations.isFilled] }, { name: 'website', - label: 'registration.wizard.nonprofit.website.label', - placeholder: 'registration.wizard.nonprofit.website.placeholder', validators: [Validations.optional(Validations.isUrl)] }, { name: 'org_email', - label: 'registration.wizard.nonprofit.email.label', - placeholder: 'registration.wizard.nonprofit.email.placeholder', validators: [Validations.optional(Validations.isEmail)] }, { name: 'org_phone', - label: 'registration.wizard.nonprofit.phone.label', - placeholder: 'registration.wizard.nonprofit.phone.placeholder', type: "tel" }, { name: 'city', - label: 'registration.wizard.nonprofit.city.label', - placeholder: 'registration.wizard.nonprofit.city.placeholder', validators: [Validations.isFilled] }, { name: 'state', - label: 'registration.wizard.nonprofit.state.label', - placeholder: 'registration.wizard.nonprofit.state.placeholder', - type: 'text', validators: [Validations.isFilled] }, { name: 'zip', - label: 'registration.wizard.nonprofit.zip.label', - placeholder: 'registration.wizard.nonprofit.zip.placeholder', validators: [Validations.isFilled] } ] @@ -67,17 +51,33 @@ class NonprofitInfoForm extends React.Component - - + + + - - + + - - - + + + diff --git a/javascripts/src/components/registration_page/RegistrationWizard.tsx b/javascripts/src/components/registration_page/RegistrationWizard.tsx index e7a7b8c6..d3d58258 100644 --- a/javascripts/src/components/registration_page/RegistrationWizard.tsx +++ b/javascripts/src/components/registration_page/RegistrationWizard.tsx @@ -175,24 +175,6 @@ export class InnerRegistrationWizard extends React.Component diff --git a/javascripts/src/components/registration_page/UserInfoForm.tsx b/javascripts/src/components/registration_page/UserInfoForm.tsx index 89140939..553a1b23 100644 --- a/javascripts/src/components/registration_page/UserInfoForm.tsx +++ b/javascripts/src/components/registration_page/UserInfoForm.tsx @@ -12,8 +12,6 @@ import {areWeOrAnyParentSubmitting} from "../../lib/houdini_form"; export const FieldDefinitions : Array = [ { name: 'name', - label: 'registration.wizard.contact.name.label', - placeholder: 'registration.wizard.contact.name.placeholder', validators: [Validations.isFilled] }, { @@ -24,14 +22,12 @@ export const FieldDefinitions : Array = [ }, { name: 'password', - label: 'registration.wizard.contact.password.label', type: 'password', validators: [Validations.isFilled], related: ['userTab.password_confirmation'] }, { name: 'password_confirmation', - label: 'registration.wizard.contact.password_confirmation.label', type: 'password', validators: [Validations.shouldBeEqualTo("userTab.password")] } @@ -50,12 +46,22 @@ class UserInfoForm extends React.Component - - + + - - + + = [ { name: 'email', - label: 'email', type: 'text', validators: [Validations.isFilled] }, { name: 'password', - label: 'password', type: 'password', validators: [Validations.isFilled] } @@ -100,20 +98,14 @@ class InnerSessionLoginForm extends React.Component
{(this.form as any).error}
: '' return
- - + + {errorDiv}