diff --git a/src/App.js b/src/App.js
index c10859093..a6a1d2df3 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,44 @@
-import React from 'react';
+import React, { useState } from 'react';
import './App.css';
+import ChatLog from './components/ChatLog';
import chatMessages from './data/messages.json';
const App = () => {
+ const [entries, setEntries] = useState(chatMessages);
+
+ const heartCount = () => {
+ let count = 0;
+ for (let entry of entries) {
+ if (entry.liked) {
+ count++;
+ }
+ }
+ return count;
+ };
+
+ const updateMessageData = (updateMessage) => {
+ const messages = entries.map((message) => {
+ if (message.id === updateMessage.id) {
+ return updateMessage;
+ } else {
+ return message;
+ }
+ });
+ setEntries(messages);
+ };
+
return (
-
Replace with name of sender
+
+
{props.sender}
- Replace with body of ChatEntry
- Replace with TimeStamp component
-
+ {props.body}
+
+
+
+
);
};
ChatEntry.propTypes = {
- //Fill with correct proptypes
+ id: PropTypes.number.isRequired,
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string,
+ onUpdate: PropTypes.func.isRequired,
+ liked: PropTypes.bool.isRequired,
};
export default ChatEntry;
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..fcaf434a4
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,40 @@
+import React from 'react';
+import ChatEntry from './ChatEntry';
+import PropTypes from 'prop-types';
+
+const ChatLog = (props) => {
+ const getChats = props.entries.map((entry, index) => {
+ return (
+
+ );
+ });
+ return (
+
+ );
+};
+
+ChatLog.propTypes = {
+ entries: PropTypes.arrayOf(
+ PropTypes.shape({
+ id: PropTypes.number.isRequired,
+ sender: PropTypes.string.isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string,
+ liked: PropTypes.bool.isRequired,
+ }).isRequired
+ ),
+ onUpdateLikes: PropTypes.func.isRequired,
+};
+
+export default ChatLog;