<commit_before>import React, { Component } from 'react'
import fire from '../../fire'
import shuffle from 'shuffle-array'
import WhoAmI from './WhoAmI'
import Rules from './Rules'
import Alerts from './DealingHandsAlert'
import EpiAlerts from './EpidemicAlerts'
import HandLimit from './HandLimitAlert'
import { Menu, Button, Transition } from 'semantic-ui-react'
const db = fire.database()
// Get the auth API from Firebase.
const auth = fire.auth()

export default class NavBar extends Component {
  constructor(props) {
    super(props)
    this.state = {
      gameState: {},
      currPlayer: '',
      players: {},
      loading: true, 
      isCurrPlayer: false
    }
    this.handleLogout = this.handleLogout.bind(this)
  }
  componentDidMount() {
    // component listens for changes in the game state (tiles, infection rate, outbreaks, etc.)
    db.ref(`/rooms/${this.props.roomName}/state`).on('value', snapshot => {
      const gameState = snapshot.val()
      if (gameState && gameState.blueTiles) this.setState({ gameState: gameState })
    })

    db.ref(`/rooms/${this.props.roomName}`).on('value', snapshot => {
      const currPlayer = snapshot.val().state.currPlayer
      const players = snapshot.val().players
      const researchCenter = snapshot.val().state.researchCenter
      this.setState({
        currPlayer: currPlayer,
        players: players,
        researchCenter: researchCenter,
        isCurrPlayer: currPlayer === auth.currentUser.uid
      })
    })

    setTimeout(() => {
      this.setState({loading: false})
    }, 1000)
  }

  handleLogout(e) {
    auth.signOut()
    this.props.history.push('/')
  }

  render() {
    const { players, currPlayer, isCurrPlayer } = this.state
    let currPlayerName = ''
    if (currPlayer) {
      currPlayerName = players[currPlayer].name
    }
    if (this.state.loading) {
      return (
        <div>
          <div className='loading-state'>Loading...</div>
        </div>
      )
    } else {
      return (
        <Menu inverted>
        <Menu.Item>
          <img className='navbar-icon' src={'/images/redIcon.png'} />
          {this.state.gameState.redTiles}
          <img className='navbar-icon' src={'/images/blackIcon.png'} />
          {this.state.gameState.blackTiles}
          <img className='navbar-icon' src={'/images/blueIcon.png'} />
          {this.state.gameState.blueTiles}
          <img className='navbar-icon' src={'/images/yellowIcon.png'} />
          {this.state.gameState.yellowTiles}
          <img className='navbar-icon' src={'/images/infectionMarker.jpg'} />
          {this.state.gameState.infectionRate}
          <img className='navbar-icon' src={'/images/OutbreakMarker.png'} />
          {this.state.gameState.outbreaks}
          <img className='navbar-icon' src={'/images/researchCenter.png'} />
          {this.state.gameState.researchCenters}
        </Menu.Item>
         <Transition
            animation='flash'
            duration='1000'
            transitionOnMount={true}>
        <Menu.Item>
          Current Turn: {currPlayerName}
          <Alerts />
        </Menu.Item>
        </Transition>
        <Menu.Item>
         <Rules />
        </Menu.Item>
        <Menu.Item>
          {`Welcome, ${auth.currentUser.displayName}! `}
        </Menu.Item>
        <Menu.Item>
          <Button size="mini" color="violet"
          onClick={this.handleLogout}>Logout</Button>
        </Menu.Item>
        {
          isCurrPlayer ?
          <HandLimit roomName={this.props.roomName} currPlayer={this.state.currPlayer}/> :
          ''
        }
        <Alerts roomName={this.props.roomName} currPlayer={this.state.currPlayer}/>
        <EpiAlerts roomName={this.props.roomName} currPlayer={this.state.currPlayer}/>
      </Menu>
      )
    }
  }
}<commit_msg>fix: disable hand modal<commit_after>import React, { Component } from 'react'
import fire from '../../fire'
import shuffle from 'shuffle-array'
import WhoAmI from './WhoAmI'
import Rules from './Rules'
import EpiAlerts from './EpidemicAlerts'
import HandLimit from './HandLimitAlert'
import { Menu, Button, Transition } from 'semantic-ui-react'
const db = fire.database()
// Get the auth API from Firebase.
const auth = fire.auth()

export default class NavBar extends Component {
  constructor(props) {
    super(props)
    this.state = {
      gameState: {},
      currPlayer: '',
      players: {},
      loading: true, 
      isCurrPlayer: false
    }
    this.handleLogout = this.handleLogout.bind(this)
  }
  componentDidMount() {
    // component listens for changes in the game state (tiles, infection rate, outbreaks, etc.)
    db.ref(`/rooms/${this.props.roomName}/state`).on('value', snapshot => {
      const gameState = snapshot.val()
      if (gameState && gameState.blueTiles) this.setState({ gameState: gameState })
    })

    db.ref(`/rooms/${this.props.roomName}`).on('value', snapshot => {
      const currPlayer = snapshot.val().state.currPlayer
      const players = snapshot.val().players
      const researchCenter = snapshot.val().state.researchCenter
      this.setState({
        currPlayer: currPlayer,
        players: players,
        researchCenter: researchCenter,
        isCurrPlayer: currPlayer === auth.currentUser.uid
      })
    })

    setTimeout(() => {
      this.setState({loading: false})
    }, 1000)
  }

  handleLogout(e) {
    auth.signOut()
    this.props.history.push('/')
  }

  render() {
    const { players, currPlayer, isCurrPlayer } = this.state
    let currPlayerName = ''
    if (currPlayer) {
      currPlayerName = players[currPlayer].name
    }
    if (this.state.loading) {
      return (
        <div>
          <div className='loading-state'>Loading...</div>
        </div>
      )
    } else {
      return (
        <Menu inverted>
        <Menu.Item>
          <img className='navbar-icon' src={'/images/redIcon.png'} />
          {this.state.gameState.redTiles}
          <img className='navbar-icon' src={'/images/blackIcon.png'} />
          {this.state.gameState.blackTiles}
          <img className='navbar-icon' src={'/images/blueIcon.png'} />
          {this.state.gameState.blueTiles}
          <img className='navbar-icon' src={'/images/yellowIcon.png'} />
          {this.state.gameState.yellowTiles}
          <img className='navbar-icon' src={'/images/infectionMarker.jpg'} />
          {this.state.gameState.infectionRate}
          <img className='navbar-icon' src={'/images/OutbreakMarker.png'} />
          {this.state.gameState.outbreaks}
          <img className='navbar-icon' src={'/images/researchCenter.png'} />
          {this.state.gameState.researchCenters}
        </Menu.Item>
         <Transition
            animation='flash'
            duration='1000'
            transitionOnMount={true}>
        <Menu.Item>
          Current Turn: {currPlayerName}
          <Alerts />
        </Menu.Item>
        </Transition>
        <Menu.Item>
         <Rules />
        </Menu.Item>
        <Menu.Item>
          {`Welcome, ${auth.currentUser.displayName}! `}
        </Menu.Item>
        <Menu.Item>
          <Button size="mini" color="violet"
          onClick={this.handleLogout}>Logout</Button>
        </Menu.Item>
        {
          isCurrPlayer ?
          <HandLimit roomName={this.props.roomName} currPlayer={this.state.currPlayer}/> :
          ''
        }
        <EpiAlerts roomName={this.props.roomName} currPlayer={this.state.currPlayer}/>
      </Menu>
      )
    }
  }
}
{'fraction_non_alphanumeric': 0.1453231633881975, 'fraction_numerical': 0.002141041081225746, 'mean_word_length': 2.3455684870188005, 'pattern_counts': {'":': 0, '<': 66, '<?xml version=': 0, '>': 72, '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': '324784', 'n_tokens_mistral': 2257, 'n_tokens_neox': 2230, 'n_words': 416}