diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/package.json b/package.json index eeabcb7..bfd3136 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@mui/material": "^5.14.20", "@mui/styles": "^5.14.13", "@mui/system": "^5.14.1", + "@mui/x-charts": "^6.18.4", "@mui/x-data-grid": "^6.16.2", "@mui/x-date-pickers": "^6.10.1", "@nivo/line": "^0.83.0", diff --git a/src/App.js b/src/App.js index e887de4..dc6177e 100644 --- a/src/App.js +++ b/src/App.js @@ -1,369 +1,14 @@ -// // Note: Main App Component -// import React, { useCallback, useEffect, useRef, useState } from 'react'; -// import { -// BrowserRouter as Router, -// Route, -// Routes, -// useNavigate, -// } from 'react-router-dom'; -// import { Helmet } from 'react-helmet'; +// App.js +import React from 'react'; +import Main from './Main'; +import WithPageProvider from './context/WithPageProvider'; -// // Component Imports -// import Header from './components/headings/header/Header'; -// import PrivateRoute from './components/reusable/PrivateRoute'; -// import LoginDialog from './components/dialogs/LoginDialog'; - -// // Page Imports -// import { -// HomePage, -// StorePage, -// CartPage, -// ProfilePage, -// CollectionPage, -// DeckBuilderPage, -// NotFoundPage, -// LoginPage, -// } from './pages'; - -// import { -// useUserContext, -// useCollectionStore, -// useDeckStore, -// useCartStore, -// useCardImages, -// useAuthContext, -// usePageContext, -// } from './context'; -// import { AppContainer } from './pages/pageStyles/StyledComponents'; - -// const App = () => { -// const { fetchAllCollectionsForUser } = useCollectionStore(); -// const { fetchAllDecksForUser } = useDeckStore(); -// const { fetchUserCart } = useCartStore(); -// const { user } = useUserContext(); -// const { logoutTimerRef, resetLogoutTimer } = useAuthContext(); -// const { -// isPageLoading, -// setIsPageLoading, -// displaySplashPage, -// handleLoadingTimeout, -// } = usePageContext(); -// const navigate = useNavigate(); -// const loadingTimeoutRef = useRef(null); -// const userId = user?.id; -// const [showLoginDialog, setShowLoginDialog] = useState(!userId); -// // const [toolbarHeight, setToolbarHeight] = useState('64px'); // Default height - -// const handleLoginSuccess = (isLoggedIn, userId) => { -// setShowLoginDialog(false); -// setIsPageLoading(false); -// if (isLoggedIn && userId) { -// resetLogoutTimer(); -// } -// }; - -// useEffect(() => { -// if (userId) { -// window.addEventListener('mousemove', resetLogoutTimer); -// window.addEventListener('keypress', resetLogoutTimer); -// } - -// return () => { -// window.removeEventListener('mousemove', resetLogoutTimer); -// window.removeEventListener('keypress', resetLogoutTimer); -// if (logoutTimerRef.current) { -// clearTimeout(logoutTimerRef.current); -// } -// }; -// }, [userId, resetLogoutTimer]); - -// useEffect(() => { -// console.log('useEffect triggered for fetch data'); - -// const fetchData = async () => { -// try { -// if (userId && typeof userId === 'string') { -// console.log('Fetching user data'); -// await Promise.all([ -// fetchAllCollectionsForUser(), -// fetchAllDecksForUser(), -// // fetchUserCart(), -// ]); -// } -// } catch (error) { -// console.error('Error fetching data:', error); -// } finally { -// setIsPageLoading(false); -// } -// }; - -// fetchData(); -// }, [userId, fetchAllCollectionsForUser, fetchAllDecksForUser]); - -// useEffect(() => { -// if (isPageLoading) { -// loadingTimeoutRef.current = setTimeout(() => { -// handleLoadingTimeout(); -// navigate('/login'); -// }, 45000); // 45 seconds -// } -// return () => { -// if (loadingTimeoutRef.current) { -// clearTimeout(loadingTimeoutRef.current); -// } -// }; -// }, [isPageLoading, navigate, handleLoadingTimeout]); - -// useEffect(() => { -// if (window.location.pathname === '/login') { -// setShowLoginDialog(true); -// setIsPageLoading(false); -// // setIsLoading(false); -// } -// }, []); -// return ( -// <> -// -// -// -// -// {' '} -// {displaySplashPage()} -// {!userId ? ( -// setShowLoginDialog(false)} -// onLogin={handleLoginSuccess} -// /> -// ) : ( -// -//
-// -// } /> -// } /> -// } /> -// -// -// -// } -// /> -// -// -// -// } -// /> -// -// -// -// } -// /> -// -// -// -// } -// /> -// } /> -// } /> -// {/* } /> */} -// {/* } /> */} -// } />{' '} -// -// {/*