-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Chatlog #102
base: main
Are you sure you want to change the base?
Chatlog #102
Conversation
<p className="entry-time"> | ||
<TimeStamp time={timeStamp} /> | ||
</p> | ||
<button className="like" onClick={() => likeMessage(id)}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 We need a function that will update the state of the entry that is click
const bubbleClass = colorChoice[sender] ?? 'black' | ||
|
||
// console.log(bubbleClass) | ||
|
||
const stateMessage = (sender) => { | ||
return sender === 'Vladimir' ? 'local' : 'remote'; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work completing this optional alignment feature
ChatEntry.propTypes = { | ||
//Fill with correct proptypes | ||
id: PropTypes.number.isRequired, | ||
sender: PropTypes.string.isRequired, | ||
body: PropTypes.string.isRequired, | ||
timeStamp: PropTypes.string.isRequired, | ||
liked: PropTypes.bool.isRequired, | ||
colorChoice: PropTypes.func |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
const entryComponents = entries.map(entry => { | ||
return ( | ||
<ChatEntry | ||
id= {entry.id} | ||
sender= {entry.sender} | ||
body= {entry.body} | ||
timeStamp= {entry.timeStamp} | ||
liked= {entry.liked} | ||
likeMessage= {likeMessage} | ||
colorChoice={colorChoice} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job utilizing this map feature to iterate over the entries 👍🏾
<p className="entry-time"> | ||
<TimeStamp time={timeStamp} /> | ||
</p> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job utilizing the TimeStamp component provided!
const ColorChoice = ({ setColorCallback, sender }) => { | ||
return ( | ||
<div> | ||
<p>{`${sender}'s Color:`}</p> | ||
<ul> | ||
<li onClick={() => setColorCallback(sender, 'red')}>🔴</li> | ||
<li onClick={() => setColorCallback(sender, 'orange')}>🟠</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎉
|
||
const App = () => { | ||
const [messages, setMessages] = React.useState(chatMessages); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 We need a piece of state to track changes to our messages, initialized from the json file we loaded.
const likeMessage = (id) => { | ||
setMessages( | ||
messages.map((message) => (message.id === id ? { | ||
...message, | ||
liked: !message.liked | ||
} : message)) | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an optimal approach to update the state of the heart without needing the entire entry, all you need to do is send the id of the liked entry up to App.js.
let totalHearts = 0; | ||
|
||
for (let message of messages) { | ||
if (message.liked) { | ||
totalHearts++ | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an optimal approach to calculating the number of likes, great job 😁
This is a great place to calculate & display the total likes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, team! 🥳
Thank you for your patience as we catch up on grading. Nice work getting situated with React. This project is green 🟢
Keep it up, you're doing amazing
No description provided.