diff --git a/src/App.js b/src/App.js
index c10859093..d7bd4e42d 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,19 +1,45 @@
import React from 'react';
import './App.css';
import chatMessages from './data/messages.json';
+import TimeStamp from './components/TimeStamp';
+import ChatEntry from './components/ChatEntry';
+import ChatLog from './components/ChatLog';
+import { useState } from 'react';
const App = () => {
+ const [messages, setMessages] = useState(chatMessages);
+
+ const handleLike = (id) => {
+ const updatedMessages = messages.map((message) => {
+ if (message.id === id) {
+ return {
+ ...message,
+ liked: !message.liked,
+ };
+ }
+ return message;
+ });
+
+ setMessages(updatedMessages);
+ };
+
+ const likedMessagesCount = messages.reduce(
+ (count, message) => (message.liked ? count + 1 : count),
+ 0
+ );
+
return (
-
Replace with name of sender
-
- Replace with body of ChatEntry
- Replace with TimeStamp component
-
-
+
+
{props.sender}
+
+ {props.body}
+
+
+
);
};
ChatEntry.propTypes = {
- //Fill with correct proptypes
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timestamp: PropTypes.element.isRequired,
};
export default ChatEntry;
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..85d953b43
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,33 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import ChatEntry from './ChatEntry';
+
+const ChatLog = ({ entries, handleLike }) => {
+ return (
+
+ {entries.map((entry) => (
+
+ ))}
+
+ );
+ };
+
+ ChatLog.propTypes = {
+ entries: PropTypes.arrayOf(
+ PropTypes.shape({
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ TimeStamp: PropTypes.string.isRequired,
+ })
+ ).isRequired,
+ };
+
+export default ChatLog;
\ No newline at end of file