From c6b4cd664e130994c08ec072f3c981f61d708ef6 Mon Sep 17 00:00:00 2001 From: Dennif Date: Wed, 11 Jun 2025 21:52:51 -0700 Subject: [PATCH 1/5] wave 01 implemented --- src/App.jsx | 7 +++++-- src/components/ChatEntry.jsx | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 14a7f684d..488233734 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,4 +1,8 @@ +import React from "react"; import './App.css'; +import ChatEntry from './components/ChatEntry'; +import chat from './data/messages.json'; + const App = () => { return ( @@ -7,8 +11,7 @@ const App = () => {

Application title

- {/* Wave 01: Render one ChatEntry component - Wave 02: Render ChatLog component */} +
); diff --git a/src/components/ChatEntry.jsx b/src/components/ChatEntry.jsx index 15c56f96b..e852f81d4 100644 --- a/src/components/ChatEntry.jsx +++ b/src/components/ChatEntry.jsx @@ -1,12 +1,17 @@ import './ChatEntry.css'; +import React from "react"; +import PropTypes from "prop-types"; +import TimeStamp from "./TimeStamp"; + + +const ChatEntry = ({sender, body, timeStamp}) => { -const ChatEntry = () => { return (
-

Replace with name of sender

+

{sender}

-

Replace with body of ChatEntry

-

Replace with TimeStamp component

+

{body}

+
@@ -14,7 +19,9 @@ const ChatEntry = () => { }; ChatEntry.propTypes = { - // Fill with correct proptypes + sender: PropTypes.string.isRequired, + body: PropTypes.string.isRequired, + timeStamp: PropTypes.string.isRequired }; export default ChatEntry; From 47ea6cc620eede03a65ed5df7d7d7cf62d3f847e Mon Sep 17 00:00:00 2001 From: Dennif Date: Wed, 11 Jun 2025 22:19:53 -0700 Subject: [PATCH 2/5] wave 02 implemented --- src/App.jsx | 3 ++- src/components/ChatEntry.jsx | 6 ++---- src/components/ChatLog.jsx | 24 ++++++++++++++++++++++++ 3 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 src/components/ChatLog.jsx diff --git a/src/App.jsx b/src/App.jsx index 488233734..041a9f9ff 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -2,6 +2,7 @@ import React from "react"; import './App.css'; import ChatEntry from './components/ChatEntry'; import chat from './data/messages.json'; +import ChatLog from './components/ChatLog'; const App = () => { @@ -11,7 +12,7 @@ const App = () => {

Application title

- +
); diff --git a/src/components/ChatEntry.jsx b/src/components/ChatEntry.jsx index e852f81d4..3102fc1b8 100644 --- a/src/components/ChatEntry.jsx +++ b/src/components/ChatEntry.jsx @@ -1,11 +1,9 @@ import './ChatEntry.css'; -import React from "react"; -import PropTypes from "prop-types"; -import TimeStamp from "./TimeStamp"; +import PropTypes from 'prop-types'; +import TimeStamp from './TimeStamp'; const ChatEntry = ({sender, body, timeStamp}) => { - return (

{sender}

diff --git a/src/components/ChatLog.jsx b/src/components/ChatLog.jsx new file mode 100644 index 000000000..16a1d190e --- /dev/null +++ b/src/components/ChatLog.jsx @@ -0,0 +1,24 @@ +import './ChatLog.css'; +import PropTypes from 'prop-types'; +import ChatEntry from './ChatEntry'; + + + +const ChatLog = ({entries}) => { + const ChatEntries = entries.map((entry, index) => { + return ( + + ); + }); + return ( +
+ {ChatEntries} +
+ ); +}; + +ChatLog.propTypes = { + entries: PropTypes.array.isRequired +}; + +export default ChatLog; \ No newline at end of file From fd2253dbf219c5280b85e9751fe89dc8c26224d4 Mon Sep 17 00:00:00 2001 From: Dennif Date: Mon, 16 Jun 2025 00:48:15 -0700 Subject: [PATCH 3/5] wave 03 implemented, like system --- src/App.jsx | 24 +++++++++++++++++++----- src/components/ChatEntry.jsx | 21 +++++++++++++++------ src/components/ChatLog.jsx | 28 ++++++++++++++++------------ 3 files changed, 50 insertions(+), 23 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 041a9f9ff..6de0c13f2 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,18 +1,32 @@ -import React from "react"; +import React, { useState } from "react"; import './App.css'; -import ChatEntry from './components/ChatEntry'; -import chat from './data/messages.json'; import ChatLog from './components/ChatLog'; - +import chat from './data/messages.json'; const App = () => { + const [chatMessages, setChatMessages] = useState(chat); + + const toggleLike = (id) => { + const updatedMessages = chatMessages.map((entry) => { + if (entry.id === id) { + return { ...entry, liked: !entry.liked }; + } else { + return entry; + } + }); + setChatMessages(updatedMessages); + }; + + const totalLikes = chatMessages.filter((entry) => entry.liked).length; + return (

Application title

+

{totalLikes} ❤️s

- +
); diff --git a/src/components/ChatEntry.jsx b/src/components/ChatEntry.jsx index 3102fc1b8..27ea1634d 100644 --- a/src/components/ChatEntry.jsx +++ b/src/components/ChatEntry.jsx @@ -2,24 +2,33 @@ import './ChatEntry.css'; import PropTypes from 'prop-types'; import TimeStamp from './TimeStamp'; +const ChatEntry = ({ id, sender, body, timeStamp, liked, onLikeToggle }) => { + // Función que se ejecuta al hacer clic en el botón del corazón + const handleLikeClick = () => { + onLikeToggle(id); + }; -const ChatEntry = ({sender, body, timeStamp}) => { return ( -
+

{sender}

{body}

- - + +
); }; ChatEntry.propTypes = { + id: PropTypes.number.isRequired, sender: PropTypes.string.isRequired, body: PropTypes.string.isRequired, - timeStamp: PropTypes.string.isRequired + timeStamp: PropTypes.string.isRequired, + liked: PropTypes.bool.isRequired, + onLikeToggle: PropTypes.func.isRequired, }; -export default ChatEntry; +export default ChatEntry; \ No newline at end of file diff --git a/src/components/ChatLog.jsx b/src/components/ChatLog.jsx index 16a1d190e..276a119ff 100644 --- a/src/components/ChatLog.jsx +++ b/src/components/ChatLog.jsx @@ -2,23 +2,27 @@ import './ChatLog.css'; import PropTypes from 'prop-types'; import ChatEntry from './ChatEntry'; - - -const ChatLog = ({entries}) => { - const ChatEntries = entries.map((entry, index) => { +const ChatLog = ({ entries, onLikeToggle }) => { + const ChatEntries = entries.map((entry) => { return ( - + ); }); - return ( -
- {ChatEntries} -
- ); + + return
{ChatEntries}
; }; ChatLog.propTypes = { - entries: PropTypes.array.isRequired + entries: PropTypes.array.isRequired, + onLikeToggle: PropTypes.func.isRequired }; -export default ChatLog; \ No newline at end of file +export default ChatLog; From 2fbc3a58dd4a27f917cc446077c47a730848fb37 Mon Sep 17 00:00:00 2001 From: Dennif Date: Mon, 16 Jun 2025 00:57:06 -0700 Subject: [PATCH 4/5] deploy pipeline added --- .github/workflows/deploy.yml | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 000000000..0542b110d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,49 @@ +name: Deploy + +on: + push: + branches: + - main + +jobs: + build: + name: Build + runs-on: ubuntu-latest + + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup Node + uses: actions/setup-node@v4 + + - name: Install dependencies + uses: bahmutov/npm-install@v1 + + - name: Build project + run: npm run build + + - name: Upload production-ready build files + uses: actions/upload-artifact@v4 + with: + name: production-files + path: ./dist + + deploy: + name: Deploy + needs: build + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: production-files + path: ./dist + + - name: Deploy to GitHub Pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist \ No newline at end of file From 9820170e2bac58771d11795b7105075f907303a2 Mon Sep 17 00:00:00 2001 From: Dennif Date: Mon, 16 Jun 2025 01:06:35 -0700 Subject: [PATCH 5/5] base public path fixed --- vite.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/vite.config.js b/vite.config.js index 2e8881a23..4ec159c17 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,6 +4,7 @@ import react from '@vitejs/plugin-react' // https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], + base: '/react-chatlog/', test: { // jest config here reporters: ['verbose'],