diff --git a/source/components/conversation/Group.js b/source/components/conversation/Group.js deleted file mode 100644 index 1f1c5e4a8..000000000 --- a/source/components/conversation/Group.js +++ /dev/null @@ -1,84 +0,0 @@ -import React, {Component} from 'react' -import GroupTitle from './GroupTitle' -import classnames from 'classnames' -import { connect } from 'react-redux' -import { change} from 'redux-form' -import {submitStep, editStep} from '../actions' -import ReactCSSTransitionGroup from 'react-addons-css-transition-group' -import IgnoreStepButton from './Forms/IgnoreStepButton' -import conversationData from '../conversation-steps' -import {formValueSelector} from 'redux-form' -import StepAnswer from './Forms/StepAnswer' - - -/* Groups can be used only to avoid repeating conditions for all its children, -or to gather a set of questions that will be eventually collapsed to a final @value, -marked with the 'explicit' class */ -@connect(state => ({ - steps: state.steps, - formValue: field => formValueSelector('advancedQuestions')(state, field), - themeColours: state.themeColours -}), dispatch => ({ - editStep: name => dispatch(editStep(name)), - submitStep: (name, ignored) => dispatch(submitStep(name, ignored)), - setFormValue: (field, value) => dispatch(change('advancedQuestions', field, value)), -})) -export default class Group extends Component { - - render() { - let {visible, steps, foldTrigger, children, text, themeColours: {colour}} = this.props, - folded = foldTrigger ? steps.get(foldTrigger) && steps.get(foldTrigger) != 'editing' : false - - if (!visible) return null - - return ( -
- {this.renderHeader(folded)} -
- - {!folded &&
    - {children.map(child => -
  • - {child} -
  • )} -
} -
-
-
- ) - } - - renderHeader(folded) { - let { - steps, foldTrigger, editStep, setFormValue, submitStep, - text, valueType, formValue, themeColours - } = this.props - - if (!text) return null - - let - headerClick = () => editStep(foldTrigger), - {defaultValue, human} = conversationData[foldTrigger], - ignoreGroup = () => { - setFormValue(foldTrigger, defaultValue) - submitStep(foldTrigger, true) - }, - value = formValue(foldTrigger), - ignored = steps.get(name) === 'ignored' - - return ( -
- - { !folded && } - { folded && - - } -
- ) - - } - -} diff --git a/source/components/conversation/conversation-validate.js b/source/components/conversation/conversation-validate.js deleted file mode 100644 index e642c9538..000000000 --- a/source/components/conversation/conversation-validate.js +++ /dev/null @@ -1,14 +0,0 @@ -import steps from './conversation-steps' - -export default values => - values == null ? {} : - Object.keys(values).reduce((final, next) => { - let value = values[next], - {valueType = {}, validator} = steps[next], - {pre = (v => v), test, error} = Object.assign({}, validator, valueType.validator) - if (!test) return final - - let valid = test(pre(value)) - - return Object.assign(final, valid ? null : {[next]: error}) - }, {})