content: // @flow
  import React from 'react';
  import { flowRight } from 'lodash';
  import { connect } from 'react-redux';
  import Form from 'components/internships/Form';
  import { Button } from 'ui-kit';
  import { form } from '@client/hoc/form';
  import { closePanel } from '@client/actions/panels';
  import internshipActions from '@client/actions/internships';
  import { createStructuredSelector } from 'reselect';
  import userSelectors from '@client/selectors/users';
  
  export class CreateInternshipPanel extends React.PureComponent {
    render() {
      const { props } = this;
      return (
        <div>
          <h1>Create Mentorship</h1>
          {<Form {...props} Wrapper="div" create />}
          <Button {...props.actions.submit} />
        </div>
      );
    }
  }
  
  const fieldsSelector = props => {
    return {
      name: {},
      location: {
        initialValue: props.currentUser.location,
        value: props.currentUser.location,
        isValid: true,
      },
      description: { value: '' },
      status: { value: 1, isValid: true },
      type: { value: 1, isValid: true },
      // duration: {value: ''},
      // remote: {},
    };
  };
  
  const actionsSelector = props => {
    return {
      submit: props.createInternship,
    };
  };
  
  const mapStateToProps = createStructuredSelector({
    currentUser: userSelectors.getUserFromSession(),
  });
  
  const mapDispatchToProps = dispatch => ({
    createInternship: (...args) =>
      dispatch(internshipActions.create(...args)).then(internshipId => {
        dispatch(closePanel());
        return dispatch(internshipActions.goTo(internshipId));
      }),
  });
  
  export default flowRight([
    connect(mapStateToProps, mapDispatchToProps),
    form(fieldsSelector, actionsSelector),
  ])(CreateInternshipPanel);
  