{"size": 1850, "ext": "js", "max_stars_repo_path": "client/src/components/company/modals/ProfileModal.js", "max_stars_repo_name": "TWstartups/twstartups", "max_stars_repo_stars_event_min_datetime": "2020-09-11T05:32:43.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-11T05:32:43.000Z", "max_issues_repo_path": "client/src/components/company/modals/ProfileModal.js", "max_issues_repo_name": "TWstartups/twstartup", "max_issues_repo_issues_event_min_datetime": "2020-08-06T06:09:30.000Z", "max_issues_repo_issues_event_max_datetime": "2020-08-06T06:09:30.000Z", "max_forks_repo_path": "client/src/components/company/modals/ProfileModal.js", "max_forks_repo_name": "TWstartups/twstartups", "max_forks_repo_forks_event_min_datetime": "2020-08-05T04:57:20.000Z", "max_forks_repo_forks_event_max_datetime": "2020-08-05T04:57:20.000Z"}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 43.023255814, "max_line_length": 279, "alphanum_fraction": 0.6956756757}
import React from 'react'
import ReactDOM from 'react-dom'
import { connect } from 'react-redux'
import ProfileForm from './ProfileForm'
import { editComp } from '../../../actions/index'
import _ from 'lodash'

class ProfileModal extends React.Component {
  onSubmit = (formValues) => {
    console.log('formValues', formValues)
    const socialLinks = _.pick(formValues, ['facebook', 'instagram', 'linkedIn', 'twitter', 'angelList', 'crunchbase'])
    const bodyToSend = _.pick(formValues, ['companyNameEn', 'companyEmail', 'website', 'introduction'])
    console.log('tosend', { ...bodyToSend, socialLinks })
    this.props.editComp(this.props.company._id, { ...bodyToSend, socialLinks })
    this.props.hideModal()
  }

  getInitialValue = () => {
    const inputs = _.pick(this.props.company, ['companyNameEn', 'introduction', 'companyEmail', 'website', 'socialLinks'])
    const initialValues = { ...inputs, facebook: inputs.socialLinks.facebook, instagram: inputs.socialLinks.instagram, linkedin: inputs.socialLinks.linkedIn, twitter: inputs.socialLinks.twitter, angelList: inputs.socialLinks.angelList, crunchbase: inputs.socialLinks.crunchbase }
    return initialValues
  }

  render () {
    return ReactDOM.createPortal(
      <div className="ui dimmer modals visible active">
        <div onClick={(e) => e.stopPropagation() } className="ui standard modal visible active">
          <div className="header">Edit Basic Profile</div>
          <div className="content">
            <ProfileForm onSubmit={this.onSubmit} initialValues={this.getInitialValue()} hideModal={this.props.hideModal}/></div>
        </div>
      </div>,
      document.querySelector('#modal')
    )
  }
}

const mapStateToProps = ({ company }) => {
  return { company: company.currentCompany }
}

export default connect(mapStateToProps, { editComp })(ProfileModal)
