Commit 1064cd4e authored by Xabi's avatar Xabi

d7-end

parent 08f19e21
import React from "react";
import "./Avatar.css";
const Avatar = (props) => {
return(
<div className="Avatar">
<img src={`./avatars/${props.author}.png`} alt="logo" />
<div>{props.name}</div>
</div>
)};
const Avatar = props => {
return (
<div
className="Avatar"
onClick={props.authorChanger}>
{/* onClick={e => props.authorChanger(e, props.author)}> */}
<img src={`./avatars/${props.author}.png`} alt="logo" />
<div>{props.name}</div>
</div>
);
};
export default Avatar;
\ No newline at end of file
export default Avatar;
......@@ -3,35 +3,28 @@ import "./ChatRoom.css";
import Message from "./Message";
import ChatRoomHeader from "./ChatRoomHeader";
const SERVER = 'http://localhost:3004';
class ChatRoom extends Component {
constructor(props) {
super(props);
this.state = {
messages: [
{
id: 1,
author: 456317,
body:
"mensaje 0 con un texto algo largo. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
date: "2019-03-26T18:33:00"
},
{
id: 2,
author: 456317,
body:
"mensaje 1 de texto suficientemente largo Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
date: "2019-03-26T18:33:02"
},
{
author: 456326,
body: "Yo... no soy tu padre",
date: "2019-03-27T09:33:41.579Z",
id: 3
}
]
messages: []
};
}
componentDidMount(){
fetch(`${SERVER}/messages`)
.then(res => res.json())
.then(res => {
this.setState({ messages: res });
})
.catch(err => {
console.error("Error:", err);
this.setState({ messages: [] });
});
}
render() {
const getAuthorName = authorId =>
this.props.people.filter(person => person.id === authorId)[0].name;
......
......@@ -38,7 +38,6 @@ class ProfileSelector extends Component {
<a
className={isSelected(person)}
key={person.id}
onClick={e => this.handleClick(e, person.id)}
href="/#"
style={{
textDecoration: "none",
......@@ -46,7 +45,8 @@ class ProfileSelector extends Component {
}}
>
<Avatar
authorChanger={this.handleClick}
// authorChanger={this.handleClick}
authorChanger={e => this.handleClick(e, person.id)}
author={person.id}
name={person.name}
/>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment