import React, {Component} from 'react';
import {WeaSwitch} from 'comsMobx'

export default class CustComp extends Component{
    onChangeHandle = v => {
        const {fieldConfig: field, form: formFull, hrmAdd} = this.props;
        if (field.domkey[0]=='companystartdate' || field.domkey[0]=='workstartdate') {
            let value = 0.00;
            let obj = {};
            let domKey = '';

            if (field.domkey[0]=='companystartdate') {
              domKey = 'companyworkyear';
            }else if(field.domkey[0]=='workstartdate'){
              domKey = 'workyear';
            }
            value = hrmAdd.calYear(v[field.domkey[0]].value);
            obj[domKey]={value};
            formFull.updateFields(obj);
          }
    }

    render(){
        return (
            <WeaSwitch ecId={`${this && this.props && this.props.ecId || ''}_WeaSwitch@p6e1kr@custcomq`} 
                {...this.props}
                onChange={this.onChangeHandle}
            />
        )
    }
}