diff --git a/frontend/src/App.js b/frontend/src/App.js index 587e81c..0c50505 100644 --- a/frontend/src/App.js +++ b/frontend/src/App.js @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useState, useEffect} from 'react'; // import logo from './logo.svg'; import './App.css'; import Login from './Components/Login'; @@ -7,11 +7,9 @@ import Navigation from './Components/Navigation'; import Profile from './Components/Profile'; import Status from './Components/Status'; import {useSelector} from 'react-redux'; // import useSelector from react-redux -import { Route, Navigate, Routes } from 'react-router-dom'; // import Route and Navigate from react-router-dom +import { Route, Navigate, Routes, useNavigate } from 'react-router-dom'; // import Route and Navigate from react-router-dom import Scheduling from './Components/Scheduling'; -import{ supabase } from './supabaseclient'; - - +// import{ supabase } from './supabaseclient'; function App() { @@ -47,6 +45,16 @@ function App() { console.log("LOGIN USER", user?.user?.id); console.log("LOGIN", user); + const RedirectToHome = () => { + const navigate = useNavigate(); + + useEffect(() => { + navigate('/home'); + }, [navigate]); + + return null; // This component does not render anything to the DOM + } + const Wrapper = () => { return (
@@ -56,17 +64,6 @@ function App() { onGroupSizeChange={handleGroupSizeChange} // Changed from props.onGroupSizeChange onTimeSlotChange={handleTimeSlotChange} /> -
@@ -81,7 +78,23 @@ function App() { {user ? ( //routes that will be available ONLY when user is logged in //add additional routes here + <> + } /> } path="/home" /> + + } path="/profile" /> + ) : ( // } path="/home" /> //will redirect to '/' from any url if no user is logged in