diff --git a/src/App.jsx b/src/App.jsx
index 14a7f684d..fbb1accf0 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,14 +1,44 @@
import './App.css';
+import ChatEntry from './components/ChatEntry';
+import ChatLog from './components/Chatlog';
+import chatData from './data/messages.json';
+import React, { useState } from 'react';
+
+
+// const Chat = {
+// id: 1,
+// sender:'Vladimir',
+// body:'why are you arguing with me',
+// timeStamp:'2018-05-29T22:49:06+00:00',
+// liked: false
+// };
const App = () => {
+ const [entries, setEntries] = useState(chatData);
+
+ const toggleLike = (id) => {
+ const updatedEntries = entries.map((entry) =>
+ entry.id === id ? { ...entry, liked: !entry.liked } : entry
+ );
+ setEntries(updatedEntries);
+ };
+
+ const totalLikes = entries.filter((entry) => entry.liked).length;
+
return (
- Application title
+ Ellie Chat Log
+ {totalLikes} ❤️s
- {/* Wave 01: Render one ChatEntry component
- Wave 02: Render ChatLog component */}
+ {/* Wave 01: Render one ChatEntry component */}
+ {/* */}
+ {/* Wave 02: Render ChatLog component */}
+
);
diff --git a/src/components/ChatEntry.css b/src/components/ChatEntry.css
index 05c3baa44..0b5088e81 100644
--- a/src/components/ChatEntry.css
+++ b/src/components/ChatEntry.css
@@ -97,4 +97,9 @@ button {
.chat-entry.remote .entry-bubble:hover::before {
background-color: #a9f6f6;
+}
+
+button.like {
+ font-size: 1.5rem;
+ margin-top: 0.5rem;
}
\ No newline at end of file
diff --git a/src/components/ChatEntry.jsx b/src/components/ChatEntry.jsx
index 15c56f96b..07c57e365 100644
--- a/src/components/ChatEntry.jsx
+++ b/src/components/ChatEntry.jsx
@@ -1,20 +1,35 @@
+// components/ChatEntry.js
import './ChatEntry.css';
+import PropTypes from 'prop-types';
+import TimeStamp from './TimeStamp';
+
+const ChatEntry = ({ id, sender, body, timeStamp, liked, onLikeToggle }) => {
+ const heart = liked ? '❤️' : '🤍';
+
-const ChatEntry = () => {
return (
-
Replace with name of sender
+
{sender}
- Replace with body of ChatEntry
- Replace with TimeStamp component
-
+ {body}
+
+
+
+
);
};
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,
+ onLikeToggle: PropTypes.func.isRequired,
};
export default ChatEntry;
diff --git a/src/components/ChatEntry.test.jsx b/src/components/ChatEntry.test.jsx
index 85eff9256..2f2a67c30 100644
--- a/src/components/ChatEntry.test.jsx
+++ b/src/components/ChatEntry.test.jsx
@@ -6,11 +6,13 @@ describe('Wave 01: ChatEntry', () => {
beforeEach(() => {
render(
);
});
diff --git a/src/components/Chatlog.jsx b/src/components/Chatlog.jsx
new file mode 100644
index 000000000..307fa3731
--- /dev/null
+++ b/src/components/Chatlog.jsx
@@ -0,0 +1,37 @@
+// components/ChatLog.js
+import './Chatlog.css';
+import PropTypes from 'prop-types';
+import ChatEntry from './ChatEntry';
+
+const ChatLog = ({ entries , onLikeToggle }) => {
+ return (
+
+ {entries.map((entry) => (
+
+ ))}
+
+ );
+};
+
+ChatLog.propTypes = {
+ entries: PropTypes.arrayOf(
+ PropTypes.shape({
+ id: PropTypes.number.isRequired,
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool.isRequired,
+ })
+ ).isRequired,
+ onLikeToggle: PropTypes.func.isRequired,
+};
+
+export default ChatLog;
\ No newline at end of file
diff --git a/src/components/TimeStamp.jsx b/src/components/TimeStamp.jsx
index e8892b4d4..5a896e80c 100644
--- a/src/components/TimeStamp.jsx
+++ b/src/components/TimeStamp.jsx
@@ -13,4 +13,4 @@ TimeStamp.propTypes = {
time: PropTypes.string.isRequired,
};
-export default TimeStamp;
+export default TimeStamp;
\ No newline at end of file