Skip to content
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

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Chatlog #102

wants to merge 11 commits into from

Conversation

SydneyALV
Copy link

No description provided.

<p className="entry-time">
<TimeStamp time={timeStamp} />
</p>
<button className="like" onClick={() => likeMessage(id)}>

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

Comment on lines +11 to +17
const bubbleClass = colorChoice[sender] ?? 'black'

// console.log(bubbleClass)

const stateMessage = (sender) => {
return sender === 'Vladimir' ? 'local' : 'remote';
};

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

Comment on lines 35 to +41
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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +6 to +16
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}
/>

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 👍🏾

Comment on lines +24 to +26
<p className="entry-time">
<TimeStamp time={timeStamp} />
</p>

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!

Comment on lines +4 to +10
const ColorChoice = ({ setColorCallback, sender }) => {
return (
<div>
<p>{`${sender}'s Color:`}</p>
<ul>
<li onClick={() => setColorCallback(sender, 'red')}>🔴</li>
<li onClick={() => setColorCallback(sender, 'orange')}>🟠</li>

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);

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.

Comment on lines +10 to +17
const likeMessage = (id) => {
setMessages(
messages.map((message) => (message.id === id ? {
...message,
liked: !message.liked
} : message))
);
};
Copy link

@ameerrah9 ameerrah9 Jul 11, 2023

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.

Comment on lines +37 to +43
let totalHearts = 0;

for (let message of messages) {
if (message.liked) {
totalHearts++
}
}

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

Copy link

@ameerrah9 ameerrah9 left a 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants