diff --git a/src/App.js b/src/App.js
index c10859093..e206d524d 100644
--- a/src/App.js
+++ b/src/App.js
@@ -1,16 +1,39 @@
-import React from 'react';
+import React, { useState } from 'react';
import './App.css';
-import chatMessages from './data/messages.json';
+import entries from './data/messages.json';
+import ChatLog from './components/ChatLog';
+import ChatEntry from './components/ChatEntry';
+
+
const App = () => {
+ const [messages, setMessages] = useState(entries)
+
+ const numLikes = messages.filter((message) => message.liked).length;
+
+ // going to write a helper function for messages
+ const setLikes = (id) => {
+ const newMessages = messages.map((message) => {
+ if (id === message.id){
+ return {...message, liked: !message.liked};
+
+ }
+
+ return message
+ });
+
+ setMessages(newMessages)
+
+ }
+
return (
- {/* Wave 01: Render one ChatEntry component
- Wave 02: Render ChatLog component */}
+
);
diff --git a/src/components/ChatEntry.js b/src/components/ChatEntry.js
index b92f0b7b2..59e3d8d66 100644
--- a/src/components/ChatEntry.js
+++ b/src/components/ChatEntry.js
@@ -1,22 +1,31 @@
-import React from 'react';
+import React, { useState } from 'react';
import './ChatEntry.css';
import PropTypes from 'prop-types';
+import TimeStamp from './TimeStamp';
const ChatEntry = (props) => {
- return (
-
-
Replace with name of sender
+
+
+ const heart = props.liked? '❤️': '🤍';
+
+
+ return(
+
+
{props.sender}
- Replace with body of ChatEntry
- Replace with TimeStamp component
-
+ {props.body}
+
+
-
+
);
};
ChatEntry.propTypes = {
- //Fill with correct proptypes
+ body: PropTypes.string.isRequired,
+ sender: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ id: PropTypes.number.isRequired,
};
export default ChatEntry;
diff --git a/src/components/ChatLog.js b/src/components/ChatLog.js
new file mode 100644
index 000000000..a69cde1f6
--- /dev/null
+++ b/src/components/ChatLog.js
@@ -0,0 +1,38 @@
+import ChatEntry from './ChatEntry';
+import PropTypes from 'prop-types';
+
+
+const ChatLog = (props) => {
+ const data = props.entries.map((entry, index) => {
+ return (
+
+
+
+ );
+ });
+ return (
+
+
+ );
+};
+ChatLog.propTypes = {
+ entries: PropTypes.arrayOf(PropTypes.shape({
+ body: PropTypes.string.isRequired,
+ sender: PropTypes.string.isRequired,
+ timeStamp: PropTypes.string.isRequired,
+ liked: PropTypes.bool.isRequired
+ }))
+};
+
+export default ChatLog;
diff --git a/src/components/TimeStamp.js b/src/components/TimeStamp.js
index e8892b4d4..5f4759573 100644
--- a/src/components/TimeStamp.js
+++ b/src/components/TimeStamp.js
@@ -2,11 +2,11 @@ import { DateTime } from 'luxon';
import PropTypes from 'prop-types';
const TimeStamp = (props) => {
- const time = DateTime.fromISO(props.time);
- const absolute = time.toFormat('MMMM Do YYYY, h:mm:ss a');
- const relative = time.toRelative();
+ const compTime = DateTime.fromISO(props.time);
+ const absolute = compTime.toFormat('MMMM Do YYYY, h:mm:ss a');
+ const relative = compTime.toRelative();
- return {relative};
+ return {relative};
};
TimeStamp.propTypes = {