From de476be64ad60a47ee4d444999ba747086367ce0 Mon Sep 17 00:00:00 2001 From: Eduardolans Date: Fri, 2 Aug 2024 17:25:48 +0200 Subject: [PATCH] add confirm & alert compos & integrate them in app (alert only in home); #136 --- .../socialcode/app/src/views/Home.jsx | 13 +++- .../app/src/views/components/Alert/index.css | 37 +++++++++++ .../app/src/views/components/Alert/index.jsx | 15 +++++ .../src/views/components/Confirm/index.css | 15 +++++ .../src/views/components/Confirm/index.jsx | 16 +++++ .../app/src/views/components/Post.jsx | 61 ++++++++++++++----- 6 files changed, 139 insertions(+), 18 deletions(-) create mode 100644 staff/eduardo-sanchez/socialcode/app/src/views/components/Alert/index.css create mode 100644 staff/eduardo-sanchez/socialcode/app/src/views/components/Alert/index.jsx create mode 100644 staff/eduardo-sanchez/socialcode/app/src/views/components/Confirm/index.css create mode 100644 staff/eduardo-sanchez/socialcode/app/src/views/components/Confirm/index.jsx diff --git a/staff/eduardo-sanchez/socialcode/app/src/views/Home.jsx b/staff/eduardo-sanchez/socialcode/app/src/views/Home.jsx index 3a56987e7..3e8f971e2 100644 --- a/staff/eduardo-sanchez/socialcode/app/src/views/Home.jsx +++ b/staff/eduardo-sanchez/socialcode/app/src/views/Home.jsx @@ -10,6 +10,7 @@ import Footer from './components/Footer' import CreatePostForm from './components/CreatePostForm' import Hello from './components/Hello' import Search from './components/Search' +import Alert from './components/Alert' import Button from '../components/core/Button' import Heading from '../components/core/Heading' @@ -26,7 +27,9 @@ function Home({ onUserLoggedOut }) { const [view, setView] = useState('') const [postListRefreshStamp, setPostListRefreshStamp] = useState(0) - const navigate = useNavigate() + // const navigate = useNavigate() + + const [message, setMessage] = useState(null) const handleLogout = () => { logic.logoutUser() @@ -47,7 +50,9 @@ function Home({ onUserLoggedOut }) { .catch(error => { console.error(error) - alert(error.message) + // alert(error.message + " " + "HELL") + + setMessage(error.message) }) } catch (error) { @@ -73,6 +78,8 @@ function Home({ onUserLoggedOut }) { // navigate('/about') // } + const handleAlertAccept = () => setMessage(null) + return
@@ -110,6 +117,8 @@ function Home({ onUserLoggedOut }) {