<commit_before>import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import {firebase, firebaseDb} from '../../utils/firebase';
import {Link} from 'react-router';
import { fetchUser } from '../../actions/firebase_actions';

import Loading from '../helpers/loading';
import moment from 'moment';

class RecomendationsSubmit extends Component {

    constructor(props) {
        super(props);
        this.props.fetchUser();


        this.state = {
            message: '',
            text: '',
        };
    }
    componentDidMount(){
                    console.log("USR NOW RECOMEDNATIONS", this.props.currentUser);


    }

    onFormSubmit(event) {
        event.preventDefault();
        const recomendationText = this.refs.recomendation.value;
        const fireRecomendationsRef = firebaseDb.ref("recomendations").child(this.props.pefId);

                console.log("USER PASSED TO RENDER IN RECOMENDATIONS", this.props.currentUser);
                console.log("Recomendation text", recomendationText);
        if (recomendationText.length > 5) {
                  console.log("PARAMS", this.props);

            fireRecomendationsRef.push().set({
                text: recomendationText,
                author: {
                    uid: this.props.currentUser.uid,
                    name: this.props.currentUser.displayName,
                    email: this.props.currentUser.email,
                    photoURL: this.props.currentUser.photoURL,
                },
                timestamp: moment().valueOf(),
            });

            this.setState({message: ''});
        } else {
            this.setState({message: "Recomendation has to be longer than 5 symbols"});
        }
    }

    componentWillReceiveProps(nextProps){
        console.log("NEW PROPS?", nextProps);
        if (nextProps.reply) {
            var modifiedText = nextProps.reply.text.split('\n').map(s => `> ${s}`).join('\n');
            this.setState({text: modifiedText+"\n"+this.state.text });
        }
    }
    handleTyping(e){
        this.setState({text: e.target.value});
    }

    render() {
        if (!this.props.currentUser ) {
            return <Loading />;
        }
        console.log("REPLAY STATE", this.props.reply);
        return (
            <div className="col-md-12">
                <form id="frmProfile" role="form" onSubmit={this.onFormSubmit.bind(this)}>
                    <p>{this.state.message}</p>
                    <div className="form-group">
                        <label htmlFor="recomendation">Recomendation: </label>
                        <textarea 
                        className="form-control" rows="5" id="recomendation" 
                        ref="recomendation" name="recomendation" value={this.state.text}  onChange={this.handleTyping.bind(this)}></textarea>

                    </div>
                    
                    <button type="submit" className="btn btn-primary">Send</button>
                </form>
            </div>
        );<commit_msg>Reply style update<commit_after>import React, { Component } from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import {firebase, firebaseDb} from '../../utils/firebase';
import {Link} from 'react-router';
import { fetchUser } from '../../actions/firebase_actions';

import Loading from '../helpers/loading';
import moment from 'moment';

class RecomendationsSubmit extends Component {

    constructor(props) {
        super(props);
        this.props.fetchUser();


        this.state = {
            message: '',
            text: '',
        };
    }
    componentDidMount(){
                    console.log("USR NOW RECOMEDNATIONS", this.props.currentUser);


    }

    onFormSubmit(event) {
        event.preventDefault();
        const recomendationText = this.refs.recomendation.value;
        const fireRecomendationsRef = firebaseDb.ref("recomendations").child(this.props.pefId);

                console.log("USER PASSED TO RENDER IN RECOMENDATIONS", this.props.currentUser);
                console.log("Recomendation text", recomendationText);
        if (recomendationText.length > 5) {
                  console.log("PARAMS", this.props);

            fireRecomendationsRef.push().set({
                text: recomendationText,
                author: {
                    uid: this.props.currentUser.uid,
                    name: this.props.currentUser.displayName,
                    email: this.props.currentUser.email,
                    photoURL: this.props.currentUser.photoURL,
                },
                timestamp: moment().valueOf(),
            });

            this.setState({message: '', text: ''});
        } else {
            this.setState({message: "Recomendation has to be longer than 5 symbols"});
        }
    }

    componentWillReceiveProps(nextProps){
        console.log("NEW PROPS?", nextProps);
        if (nextProps.reply) {
            var modifiedText = nextProps.reply.text+'\n by '+nextProps.reply.author.name+' on '+moment(nextProps.reply.timestamp).format('YYYY-MM-DD HH:ss');
            modifiedText = modifiedText.split('\n').map(s => `> ${s}`).join('\n');
            this.setState({text: modifiedText+"\n"+this.state.text });
        }
    }
    handleTyping(e){
        this.setState({text: e.target.value});
    }

    render() {
        if (!this.props.currentUser ) {
            return <Loading />;
        }
        console.log("REPLAY STATE", this.props.reply);
        return (
            <div className="col-md-12">
                <form id="frmProfile" role="form" onSubmit={this.onFormSubmit.bind(this)}>
                    <p>{this.state.message}</p>
                    <div className="form-group">
                        <label htmlFor="recomendation">Recomendation: </label>
                        <textarea 
                        className="form-control" rows="5" id="recomendation" 
                        ref="recomendation" name="recomendation" value={this.state.text}  onChange={this.handleTyping.bind(this)}></textarea>

                    </div>
                    
                    <button type="submit" className="btn btn-primary">Send</button>
                </form>
            </div>
        );
{'fraction_non_alphanumeric': 0.13556644019592354, 'fraction_numerical': 0.0015800284405119293, 'mean_word_length': 1.8851412944393802, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 39, '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': '1079448', 'n_tokens_mistral': 1785, 'n_tokens_neox': 1698, 'n_words': 306}