From a2260649b27208d37575547fae639b57df262fa7 Mon Sep 17 00:00:00 2001 From: Codarcea Alexandru-Christian Date: Sat, 25 Jan 2025 23:12:30 +0200 Subject: [PATCH] refactor authProvider to initialize state with null and simplify localStorage handling; enhance Home component with new layout and footer --- frontend/src/utils/authProvider.tsx | 23 +---- frontend/src/viewEvent/ViewEventService.ts | 1 + frontend/src/viewEvent/ViewEventView.tsx | 4 + .../EventParticipantsPanel.tsx | 2 +- frontend/src/views/Home.tsx | 91 +++++++++++++++++-- 5 files changed, 92 insertions(+), 29 deletions(-) diff --git a/frontend/src/utils/authProvider.tsx b/frontend/src/utils/authProvider.tsx index c58854a..4a69010 100644 --- a/frontend/src/utils/authProvider.tsx +++ b/frontend/src/utils/authProvider.tsx @@ -15,35 +15,16 @@ interface AuthProviderProps { } export const AuthProvider = ({ children }: AuthProviderProps): React.JSX.Element => { - const [accessToken, setAccessTokenState] = useState(() => { - // Initialize from localStorage if available - return localStorage.getItem('fb_access_token'); - }); - const [userFacebookId, setUserFacebookIdState] = useState(() => { - return localStorage.getItem('fb_user_id'); - }); - + const [accessToken, setAccessTokenState] = useState(null); + const [userFacebookId, setUserFacebookIdState] = useState(null); const isAuthenticated = !!accessToken; const setAccessToken = (token: string | null) => { setAccessTokenState(token); }; - useEffect(() => { - if (accessToken) { - localStorage.setItem('fb_access_token', accessToken); - } else { - localStorage.removeItem('fb_access_token'); - } - }, [accessToken]); - const setUserFacebookId = (facebookId: string | null) => { setUserFacebookIdState(facebookId); - if (facebookId) { - localStorage.setItem('fb_user_id', facebookId); - } else { - localStorage.removeItem('fb_user_id'); - } }; return ( diff --git a/frontend/src/viewEvent/ViewEventService.ts b/frontend/src/viewEvent/ViewEventService.ts index 9a7e9ba..3275146 100644 --- a/frontend/src/viewEvent/ViewEventService.ts +++ b/frontend/src/viewEvent/ViewEventService.ts @@ -44,6 +44,7 @@ export class ViewEventService { public async getViewEventModel(id: string, accessToken: string): Promise { try { + console.log(accessToken); const url = `${this.apiUrl}${id}`; const response = await fetch(url, { method: 'GET', diff --git a/frontend/src/viewEvent/ViewEventView.tsx b/frontend/src/viewEvent/ViewEventView.tsx index 5f38847..86bb31c 100644 --- a/frontend/src/viewEvent/ViewEventView.tsx +++ b/frontend/src/viewEvent/ViewEventView.tsx @@ -36,6 +36,10 @@ const ViewEventView = () => { refreshEvent(); }, [id, refreshEvent]); + if (accessToken === null || userFacebookId === null) { + return
Loading...
; + } + return ( <> diff --git a/frontend/src/viewEvent/eventParticipantsPanel/EventParticipantsPanel.tsx b/frontend/src/viewEvent/eventParticipantsPanel/EventParticipantsPanel.tsx index f89b840..945a5f8 100644 --- a/frontend/src/viewEvent/eventParticipantsPanel/EventParticipantsPanel.tsx +++ b/frontend/src/viewEvent/eventParticipantsPanel/EventParticipantsPanel.tsx @@ -15,7 +15,7 @@ const EventParticipantsPanel = ( { model.participants.map((participant, index) => ( - + {participant.username} diff --git a/frontend/src/views/Home.tsx b/frontend/src/views/Home.tsx index 189f66c..e2354eb 100644 --- a/frontend/src/views/Home.tsx +++ b/frontend/src/views/Home.tsx @@ -1,16 +1,93 @@ import React from 'react'; -import { Container, Typography } from '@mui/material'; +import { Container, Typography, Card, CardContent, Box, Button, Grid, Link } from '@mui/material'; +import EventIcon from '@mui/icons-material/Event'; +import GroupIcon from '@mui/icons-material/Group'; +import SecurityIcon from '@mui/icons-material/Security'; const Home = () => { return ( + <> - - Home Page - - - + + + + Welcome to VibeSync! + + + + + + + + + + + + Event Management + + + Create and manage events effortlessly with real-time updates and seamless participant tracking. + + + + + + + + + + Community Connections + + + Connect with like-minded individuals and explore personalized event recommendations. + + + + + + + + + + + Secure Platform + + + Your data is safe with us. Enjoy a secure and trustworthy environment for all your interactions. + + + + + + + +{/* Footer Section */} + + + Contact us: support@vibesync.com + + + © {new Date().getFullYear()} VibeSync. All rights reserved. + + + + ); }; -export default Home; \ No newline at end of file +export default Home;