<commit_before>import { Components, registerComponent, withMessages } from 'meteor/vulcan:core';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import classNames from 'classnames';
import withUser from '../common/withUser';
import Tooltip from '@material-ui/core/Tooltip';

const styles = theme => ({
  root: {
    maxWidth:650,
    [theme.breakpoints.down('md')]: {
      marginLeft: "auto",
      marginRight: "auto"
    }
  },
  chooseResponseType: {
    borderTop: "solid 3px rgba(0,0,0,.87)",
    display: "flex",
    justifyContent: "space-between",
    padding: theme.spacing.unit,
  },
  responseType: {
    ...theme.typography.commentStyle,
    fontSize: 16,
    width: "calc(33.3% - 12px)",
    textAlign: "center",
    padding: theme.spacing.unit*2,
    color: theme.palette.grey[500],
    marginRight: theme.spacing.unit*1.5,
    cursor: "pointer",
    '&:hover': {
      color: "rgba(0,0,0,.87)",
      borderBottom: "solid 1px rgba(0,0,0,.2)"
    }
  },
  selected: {
    color: "rgba(0,0,0,.87)",
    borderBottom: "solid 1px rgba(0,0,0,.4)"
  },
  responseForm: {
    padding: theme.spacing.unit*1.5,
  },
  disabled: {
    cursor: "default",
    color: theme.palette.grey[400],
    '&:hover': {
      color: theme.palette.grey[400],
      borderBottom: "unset"
    }
  }
})

class NewAnswerCommentQuestionForm extends PureComponent {
  state = { selection: "answer"}

  getNewForm = () => {
    const { post } = this.props
    const { selection } = this.state
    const { NewAnswerForm, CommentsNewForm } = Components

    switch(selection) {
      case "answer": 
        return <NewAnswerForm post={post} />
      case "comment":
        return <CommentsNewForm
          alignmentForumPost={post.af}
          postId={post._id}
          type="comment"
        />
    }
  }

  render () {
    const { classes } = this.props
    const { selection } = this.state

    return (
      <div className={classes.root}>
        <div className={classes.chooseResponseType}>
          <Tooltip title="Write an answer or partial-answer to the question (i.e. something that gives the question author more information, or helps others to do so)">
            <div onClick={()=>this.setState({selection: "answer"})} 
              className={classNames(classes.responseType, {[classes.selected]: selection === "answer"})}
            >
              New Answer
            </div>
          </Tooltip>
          <Tooltip title="Discuss the question or ask clarifying questions">
            <div onClick={()=>this.setState({selection: "comment"})} <commit_msg>Fix crash caused by merge<commit_after>import { Components, registerComponent, withMessages } from 'meteor/vulcan:core';
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import classNames from 'classnames';
import withUser from '../common/withUser';
import Tooltip from '@material-ui/core/Tooltip';

const styles = theme => ({
  root: {
    maxWidth:650,
    [theme.breakpoints.down('md')]: {
      marginLeft: "auto",
      marginRight: "auto"
    }
  },
  chooseResponseType: {
    borderTop: "solid 3px rgba(0,0,0,.87)",
    display: "flex",
    justifyContent: "space-between",
    padding: theme.spacing.unit,
  },
  responseType: {
    ...theme.typography.commentStyle,
    fontSize: 16,
    width: "calc(33.3% - 12px)",
    textAlign: "center",
    padding: theme.spacing.unit*2,
    color: theme.palette.grey[500],
    marginRight: theme.spacing.unit*1.5,
    cursor: "pointer",
    '&:hover': {
      color: "rgba(0,0,0,.87)",
      borderBottom: "solid 1px rgba(0,0,0,.2)"
    }
  },
  selected: {
    color: "rgba(0,0,0,.87)",
    borderBottom: "solid 1px rgba(0,0,0,.4)"
  },
  responseForm: {
    padding: theme.spacing.unit*1.5,
  },
  disabled: {
    cursor: "default",
    color: theme.palette.grey[400],
    '&:hover': {
      color: theme.palette.grey[400],
      borderBottom: "unset"
    }
  }
})

class NewAnswerCommentQuestionForm extends PureComponent {
  state = { selection: "answer"}

  getNewForm = () => {
    const { post } = this.props
    const { selection } = this.state
    const { NewAnswerForm, CommentsNewForm } = Components

    switch(selection) {
      case "answer": 
        return <NewAnswerForm post={post} />
      case "comment":
        return <CommentsNewForm
          alignmentForumPost={post.af}
          post={post}
          type="comment"
        />
    }
  }

  render () {
    const { classes } = this.props
    const { selection } = this.state

    return (
      <div className={classes.root}>
        <div className={classes.chooseResponseType}>
          <Tooltip title="Write an answer or partial-answer to the question (i.e. something that gives the question author more information, or helps others to do so)">
            <div onClick={()=>this.setState({selection: "answer"})} 
              className={classNames(classes.responseType, {[classes.selected]: selection === "answer"})}
            >
              New Answer
            </div>
          </Tooltip>
          <Tooltip title="Discuss the question or ask clarifying questions">
            <div onClick={()=>this.setState({selection: "comment"})} 
{'fraction_non_alphanumeric': 0.14766741911211437, 'fraction_numerical': 0.018811136192626036, 'mean_word_length': 2.797857142857143, 'pattern_counts': {'":': 4, '<': 23, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4742169', 'n_tokens_mistral': 1703, 'n_tokens_neox': 1630, 'n_words': 374}