{"size": 1944, "ext": "js", "max_stars_repo_path": "client/src/components/users/Users.js", "max_stars_repo_name": "CorentinBrtx/modvice", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/src/components/users/Users.js", "max_issues_repo_name": "CorentinBrtx/modvice", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/src/components/users/Users.js", "max_forks_repo_name": "CorentinBrtx/modvice", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.2467532468, "max_line_length": 93, "alphanum_fraction": 0.441872428}
import React from 'react';
import { BrowserRouter as Router, Route, Link } from "react-router-dom";
import './Users.css';
import superagent from 'superagent';


function Users ({match}) {

    const [user, setUser] = React.useState(null);
    const [notes, setNotes] = React.useState(null);

     
      React.useEffect(() => {
         superagent
         .get("http://localhost:5000/application/user/"+match.params.username)
         .then(response => setUser(response.body.user));
     }, []);

     React.useEffect(() => {
        superagent
        .get("http://localhost:5000/application/Notation/user/"+match.params.username)
        .then(response => setNotes(response.body.notations))
        }, []);


        console.log(user)

    return((notes && user) ?

        <div> 
            <div className="accueil">
                <Link to={"/home/"+match.params.username} className="linkLeft">Accueil</Link>
            </div>


            <div className="title">            
                <h1>Mon espace</h1>    
            </div>
            


            <div className="column-layout">               

                <div className="Infos">
                    <h2>Mes infos</h2>
                    <ul>
                        <li>Mon nom d'utilisateur : {user.username}</li>
                        <br></br>
                        <li>Mon age : {user.age} ans</li>
                    </ul>
                </div>

                <div className="notes">
                    <h2>Mes notes : </h2>              
                    <ul> 
                        <div dangerouslySetInnerHTML={{ __html: notes.map(
                            note => ("<li>"+note.movie_title+" : "+note.value+"/10 </li>")
                            ).join("<br>")} } />
                    </ul>
                </div>

            </div>
        </div>



        : <div>Loading</div>    

        )}



    
    
 export default Users;

