diff --git a/src/App.js b/src/App.js
index c1085909..18994290 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,38 @@
import React from 'react';
+import { useState } from 'react';
import './App.css';
import chatMessages from './data/messages.json';
+import ChatLog from './components/ChatLog';
+
+let countLikes =0;
const App = () => {
+ const [chatEntry, setChatEntry ] = useState(chatMessages);
+ const updateChatEntry = (toUpdate) => {
+ const chats = chatEntry.map((chat) => {
+ if (chat.id === toUpdate.id){
+ countLikes = toUpdate.liked ? countLikes +1 : countLikes -1
+ return toUpdate;
+ }
+ return chat;
+ });
+ setChatEntry(chats);
+ };
+
+
+
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,
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool,
+ onUpdateChat: PropTypes.func
};
export default ChatEntry;
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 00000000..d0475e67
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,35 @@
+import PropTypes from 'prop-types';
+import ChatEntry from './ChatEntry';
+import './ChatLog.css';
+
+const ChatLog = ({entries, onUpdateChat}) => {
+ const messages = entries.map((message) => {
+ return(
+
+ );
+ });
+ return(messages);
+};
+
+ChatLog.propTypes = {
+ entries: PropTypes.arrayOf(
+ PropTypes.shape({
+ id: PropTypes.number,
+ sender: PropTypes.string,
+ body: PropTypes.string,
+ timeStamp: PropTypes.string,
+ liked: PropTypes.bool,
+ onUpdateChat:PropTypes.func
+ })).isRequired
+}
+
+export default ChatLog
\ No newline at end of file