diff --git a/src/App.jsx b/src/App.jsx
index 14a7f684d..48a190c1f 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1,17 +1,44 @@
import './App.css';
+import { useState } from 'react';
+import messagesData from './data/messages.json';
+import ChatLog from './components/ChatLog';
const App = () => {
+ const [messageList, setMessageList] = useState(messagesData);
+
+ const likeToggleFunc = (messageId) => {
+ const messages = messageList.map(message => {
+ if (message.id === messageId) {
+ return { ...message, liked: !message.liked };
+ } else {
+ return message;
+ }
+ });
+
+ setMessageList(messages);
+ };
+
+ const totalLikes = messageList
+ .filter((message) => message.liked)
+ .length;
+
return (
-
Replace with name of sender
+
+
{props.sender}
- Replace with body of ChatEntry
- Replace with TimeStamp component
-
+ {props.body}
+ Time Sent:
+
);
};
ChatEntry.propTypes = {
- // Fill with correct proptypes
+ id: PropTypes.number.isRequired,
+ sender: PropTypes.string.isRequired,
+ senderType: PropTypes.oneOf(['local', 'remote']).isRequired,
+ body: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool.isRequired,
+ likeToggleFunc: PropTypes.func.isRequired,
};
export default ChatEntry;
+
diff --git a/src/components/ChatLog.css b/src/components/ChatLog.css
index 378848d1f..d6f4301b6 100644
--- a/src/components/ChatLog.css
+++ b/src/components/ChatLog.css
@@ -2,3 +2,6 @@
margin: auto;
max-width: 50rem;
}
+.chat-log ul {
+ list-style: none;
+}
\ No newline at end of file
diff --git a/src/components/ChatLog.jsx b/src/components/ChatLog.jsx
new file mode 100644
index 000000000..cad9965d4
--- /dev/null
+++ b/src/components/ChatLog.jsx
@@ -0,0 +1,46 @@
+import ChatEntry from './ChatEntry';
+import './ChatLog.css';
+import PropTypes from 'prop-types';
+
+const ChatLog = (props) => {
+ const messageComponents = props.entries.map((message) => {
+ const senderType = message.sender === props.localSender ? 'local' : 'remote';
+
+ 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,
+ })
+ ).isRequired,
+ likeToggleFunc: PropTypes.func.isRequired,
+ localSender: PropTypes.string.isRequired,
+
+};
+
+export default ChatLog;