diff --git a/src/App.js b/src/App.js
index c10859093..26a1b857a 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,44 @@
import React from 'react';
import './App.css';
import chatMessages from './data/messages.json';
+import ChatLog from './components/ChatLog';
+import { useState } from 'react';
const App = () => {
+
+ const [chatData, setChatData] = useState(chatMessages);
+ const [likeCount, setLikeCount] = useState(0);
+
+
+ const updateChatData = (updatedChat) => {
+ const entries = chatData.map((entry) => {
+ if (entry.id === updatedChat.id) {
+ if (entry.liked !== updatedChat.liked) {
+ const likeCountChange = updatedChat.liked ? 1 : -1;
+ setLikeCount((prevCount) => prevCount + likeCountChange);
+ }
+ return updatedChat;
+ } else {
+ return entry;
+ }
+ });
+ setChatData(entries);
+ };
+
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,
+ updateChatData: PropTypes.func,
};
export default ChatEntry;
+
\ No newline at end of file
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..30fd945ac
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,39 @@
+import React from 'react';
+import './ChatLog.css';
+import PropTypes from 'prop-types';
+import ChatEntry from './ChatEntry';
+
+const ChatLog = (props) => {
+ const chatComponents = props.entries.map((entry) => {
+ return (
+
+ );
+ });
+
+ return (
+
+ )
+};
+
+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,
+ })),
+ updateChatData: PropTypes.func
+};
+
+export default ChatLog;