<commit_before>import React, { Component } from "react";
import logo from "./logo.svg";
import "./App.css";
import { BrowserRouter as Router, Route } from "react-router-dom";

import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.min.css";

import List from "./List.js";
import Nick from "./Nick.js";
import Admin from "./Admin.js";

import { getJson, postJson } from "./fetch.js";

class App extends Component {
  constructor(props) {
    super(props);

    this.state = {
      nick: "New User"
    };
    this.updateNick = this.updateNick.bind(this);
    this.getNick = this.getNick.bind(this);
  }

  componentDidMount() {
    this.getNick();
  }

  updateNick(newNick) {
    postJson("/me", { nick: newNick })
      .then(resp => {
        this.setState({ nick: resp.nick });
        toast.success("Nick updated successfully!");
      })
      .catch(err =>
        toast.error(`Could not update nick, not connected to server: ${err}`)
      );
  }

  getNick() {
    getJson("/me")
      .then(resp => {
        console.log("data", resp);
        if (resp.nick !== "") {
          this.setState({ nick: resp.nick });
        }
      })
      .catch(err => {
        toast.error("Could not get user");
      });
  }

  render() {
    return (
      <Router>
        <div className="App">
          <ToastContainer />
          <div className="App-header">
            <img src={logo} className="App-logo" alt="logo" />
            <br /><commit_msg>Show error message when frontend can't get user.<commit_after>import React, { Component } from "react";
import logo from "./logo.svg";
import "./App.css";
import { BrowserRouter as Router, Route } from "react-router-dom";

import { ToastContainer, toast } from "react-toastify";
import "react-toastify/dist/ReactToastify.min.css";

import List from "./List.js";
import Nick from "./Nick.js";
import Admin from "./Admin.js";

import { getJson, postJson } from "./fetch.js";

class App extends Component {
  constructor(props) {
    super(props);

    this.state = {
      nick: "New User"
    };
    this.updateNick = this.updateNick.bind(this);
    this.getNick = this.getNick.bind(this);
  }

  componentDidMount() {
    this.getNick();
  }

  updateNick(newNick) {
    postJson("/me", { nick: newNick })
      .then(resp => {
        this.setState({ nick: resp.nick });
        toast.success("Nick updated successfully!");
      })
      .catch(err =>
        toast.error(`Could not update nick, not connected to server: ${err}`)
      );
  }

  getNick() {
    getJson("/me")
      .then(resp => {
        console.log("data", resp);
        if (resp.nick !== "") {
          this.setState({ nick: resp.nick });
        }
      })
      .catch(err => {
        toast.error(`Could not get user: ${err.msg}`);
      });
  }

  render() {
    return (
      <Router>
        <div className="App">
          <ToastContainer />
          <div className="App-header">
            <img src={logo} className="App-logo" alt="logo" />
            <br />
{'fraction_non_alphanumeric': 0.16726914229378903, 'fraction_numerical': 0.0, 'mean_word_length': 2.36353591160221, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '1159116', 'n_tokens_mistral': 971, 'n_tokens_neox': 945, 'n_words': 222}