diff --git a/src/components/EnrollmentForms/EnrollmentForms.module.css b/src/components/EnrollmentForms/EnrollmentForms.module.css new file mode 100644 index 0000000..e69de29 diff --git a/src/components/EnrollmentForms/index.js b/src/components/EnrollmentForms/index.js new file mode 100644 index 0000000..761c3e0 --- /dev/null +++ b/src/components/EnrollmentForms/index.js @@ -0,0 +1,101 @@ +// author: @ortonomy, Feb 2018 + +// react +import React, { Component } from 'react'; + +// library dependencies +//import { Link } from 'react-router-dom'; +import { connect } from 'react-redux'; +//import { bindActionCreators } from 'redux'; + +// component dependencies +import FormInputAnimated from '../FormInputAnimated/FormInputAnimated'; +import FormButton from '../FormButton'; +import ErrorMessage from '../ErrorMessage'; + +// styles +//import styles from './EnrollmentForms.module.css'; + +//debug +import Debug from '../../utils/Debug'; + +@connect( + null, + null +) +class EnrollmentForm extends Component { + constructor (props) { + super(props); + + this.state = { + type: 'ENROLLMENTFORM', + validOrgName: false, + orgName: '' + } + + this.handleOrgName = this.handleOrgName.bind(this); + this.submit = this.submit.bind(this); + this.validityCheck = this.validityCheck.bind(this); + this.keyPress = this.keyPress.bind(this); + } + + componentDidMount() { + Debug.log('[componentDidMount] of : ', this.props); + //this.props.setErrors({lastEnrollmentError: null}); + } + + handleOrgName (value, validity) { + this.setState ( (pS) => { + return { + validOrgName: validity, + orgName: value + } + }); + } + + submit() { + this.validityCheck(); + if ( this.state.validOrgName ) { + this.props.submit(this.state); + } + } + + keyPress({key}) { + if ( key === 'Enter' ) { + this.submit(); + } + } + + validityCheck() { + Debug.log('[validityCheck] of : ', this.state); + const nulled = [this.state.email, this.state.password].some( el => { + if ( el ) { + return false; + } + return true; + }); + if ( nulled ) { + this.props.setErrors({lastEnrollmentError: 'Resolve errors to enable submit. E.g. empty fields'}); + } else { + this.props.setErrors({lastEnrollmentError: null}); + } + } + + render() { + Debug.log('[render] of : ', this.props); + const f = ( +
+ +
+ { + // this.props.Org.lastEnrollmentError && ( ) + } +
+ + + ); + return f; + } +} + +export default EnrollmentForm; \ No newline at end of file diff --git a/src/containers/OrgEnrolment/component.js b/src/containers/OrgEnrolment/component.js index e0eb422..92574d1 100644 --- a/src/containers/OrgEnrolment/component.js +++ b/src/containers/OrgEnrolment/component.js @@ -1,9 +1,14 @@ +// author: @ortonomy, Feb 2018 v1 + // react import React, { Component } from 'react'; //library dependencies import { Link } from 'react-router-dom'; +// component dependencies +import EnrollmentForms from '../../components/EnrollmentForms'; + // styles import styles from './style.module.css'; @@ -16,10 +21,10 @@ class OrgEnrolment extends Component {
- Fling + Fling
-

Some Content

+