<commit_before>import React, {Component} from 'react'
import {connect} from 'react-redux'
import {pushState } from 'redux-router'
import * as Actions from '../actions/AppActions'
import _ from 'lodash'
import * as Xbox from '../models/xbox';
import DropDown from '../components/dropdown';
import GamerTagField from '../components/newtextfield';
import CommentField from '../components/commentstextfield';
import FlatButton from 'material-ui/lib/flat-button';
const Card = require('material-ui/lib/card/card');
const CardActions = require('material-ui/lib/card/card-actions');
const CardExpandable = require('material-ui/lib/card/card-expandable');
const CardHeader = require('material-ui/lib/card/card-header');
const CardMedia = require('material-ui/lib/card/card-media');
const CardText = require('material-ui/lib/card/card-text');
const CardTitle = require('material-ui/lib/card/card-title');
// import DropDown from '../components/dropdown';

import '../css/post.scss';

@connect(
  state => ({
    login: state.login,
    messages: state.messages,
    posts: state.posts,
    gamerCardData: state.gamerCardData
  })
)
class Posts extends Component {
  componentWillMount(){
    const {login, posts, dispatch, gamerCardData} = this.props
    console.log('login info', login.toJS())

    if(!login.get('logged')){
      return dispatch(pushState(null, '/login'))
    }

    Actions.listenForPosts(login.toJS().user.uid, dispatch)
    Actions.listenForMessages(login.toJS().user.uid, dispatch)
  }

  render(){
    const {posts, messages, login, gamerCardData} = this.props
    const loginJS = login.toJS();

    const uid = (loginJS.user) ? loginJS.user.uid:null

    console.log(messages.toJS())
    console.log('GamerCARD!!!!')
    // send the message tot the user by following this url
    // https://account.xbox.com/Messages?gamerTag=${gamerTag}



    const postsData = _.map(posts.toJS(), (post, key) => {
      var gamerTagMessageLink = `https://account.xbox.com/Messages?gamerTag=${post.gamerTag}`;
      var gamerProfilePic = `http://avatar.xboxlive.com/avatar/${post.gamerTag}/avatarpic-l.png`;

      console.log('GGGGGGGGGGG ===>', gamerCardData);
      var gamerCard = gamerCardData[post.gamerTag];

      if (!gamerCard) {
        gamerCard = {tier: '', gamerscore: '', avatarBodyImagePath: ''};
      }

      return <div className="posts">
        <div className="postDiv"  key={key}>
        <img className="avatarImg" src={gamerProfilePic} />
        <div className="gameTitle">{post.game}</div>
        <div className="userMessage">
          {post.message}
        </div>
        <p>
          <span>{post.gamerTag}</span>
          <a className="gamerTag-link" href={gamerTagMessageLink} target="_blank">
            <i className="fa fa-envelope-o"></i>
          </a>
        </p>
        <div className="x">
          <p>Tier: {gamerCard.tier}</p>
          <p>Gamerscore: {gamerCard.gamerscore}</p>
        </div>
      </div>
    </div>
    })

    const sendMessage= (user) => (event) => {
      console.log('sending message', this.refs.message.value)
      Actions.sendMessage(uid, user, this.refs.message.value)
    }

    const getGamerTag= (gamerTag) => (event) => {<commit_msg>converted every post into a card<commit_after>import React, {Component} from 'react'
import {connect} from 'react-redux'
import {pushState } from 'redux-router'
import * as Actions from '../actions/AppActions'
import _ from 'lodash'
import * as Xbox from '../models/xbox';
import DropDown from '../components/dropdown';
import GamerTagField from '../components/newtextfield';
import CommentField from '../components/commentstextfield';
import FlatButton from 'material-ui/lib/flat-button';
import Card from 'material-ui/lib/card/card';
import CardActions from 'material-ui/lib/card/card-actions';
import CardExpandable from 'material-ui/lib/card/card-expandable';
import CardHeader from 'material-ui/lib/card/card-header';
import CardMedia from 'material-ui/lib/card/card-media';
import CardText from 'material-ui/lib/card/card-text';
import CardTitle from 'material-ui/lib/card/card-title';
import Avatar from 'material-ui/lib/avatar';
// import DropDown from '../components/dropdown';

import '../css/post.scss';

@connect(
  state => ({
    login: state.login,
    messages: state.messages,
    posts: state.posts,
    gamerCardData: state.gamerCardData
  })
)
class Posts extends Component {
  componentWillMount(){
    const {login, posts, dispatch, gamerCardData} = this.props
    console.log('login info', login.toJS())

    if(!login.get('logged')){
      return dispatch(pushState(null, '/login'))
    }

    Actions.listenForPosts(login.toJS().user.uid, dispatch)
    Actions.listenForMessages(login.toJS().user.uid, dispatch)
  }

  render(){
    const {posts, messages, login, gamerCardData} = this.props
    const loginJS = login.toJS();

    const uid = (loginJS.user) ? loginJS.user.uid:null

    console.log(messages.toJS())
    console.log('GamerCARD!!!!')
    // send the message tot the user by following this url
    // https://account.xbox.com/Messages?gamerTag=${gamerTag}



    const postsData = _.map(posts.toJS(), (post, key) => {
      var gamerTagMessageLink = `https://account.xbox.com/Messages?gamerTag=${post.gamerTag}`;
      var gamerProfilePic = `http://avatar.xboxlive.com/avatar/${post.gamerTag}/avatarpic-l.png`;

      console.log('GGGGGGGGGGG ===>', gamerCardData);
      var gamerCard = gamerCardData[post.gamerTag];

      if (!gamerCard) {
        gamerCard = {tier: '', gamerscore: '', avatarBodyImagePath: ''};
      }

      return <div>
      <Card initiallyExpanded={true}>
  <CardHeader
    title={post.game}
    subtitle={post.gamerTag}
    avatar={gamerProfilePic}
    actAsExpander={true}
    showExpandableButton={true}>
  </CardHeader>
  <CardText expandable={true}>
    {post.message}
  </CardText>
  <CardActions expandable={true}>
    <FlatButton label="MESSAGE via XBOX"/>
  </CardActions>
</Card>
</div>
    })

    const sendMessage= (user) => (event) => {
      console.log('sending message', this.refs.message.value)
      Actions.sendMessage(uid, user, this.refs.message.value)
    }

    const getGamerTag= (gamerTag) => (event) => {
{'fraction_non_alphanumeric': 0.15737757731958762, 'fraction_numerical': 0.0, 'mean_word_length': 3.5958549222797926, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 51, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '722821', 'n_tokens_mistral': 2015, 'n_tokens_neox': 1956, 'n_words': 403}