diff --git a/App.tsx b/App.tsx index 485ed7f..f762b1c 100644 --- a/App.tsx +++ b/App.tsx @@ -50,8 +50,6 @@ export default function App() { }, [initialRoute]); if (!initialRoute) { - console.log("heh"); - return null; } return ( diff --git a/src/components/DrawerSettings/CustomDrawerContent.tsx b/src/components/DrawerSettings/CustomDrawerContent.tsx index de521b6..39be406 100644 --- a/src/components/DrawerSettings/CustomDrawerContent.tsx +++ b/src/components/DrawerSettings/CustomDrawerContent.tsx @@ -11,67 +11,111 @@ import HomeIcon from "../../icons/HomeIcon/HomeIcon"; import LoginIcon from "../../icons/LoginIcon/LoginIcon"; import SignupIcon from "../../icons/SignupIcon/SignupIcon"; import DrawerButton from "../Button/DrawerButton"; -import AddIcon from "../../icons/AddIcon/AddIcon"; +import { useDispatch, useSelector } from "react-redux"; +import { RootState } from "../../features/redux/Store/Store"; +import LogoutIcon from "../../icons/LogoutIcon/LogoutIcon"; +import { clear } from "../../features/redux/slices/AuthSlice/AuthSlice"; +import AsyncStorage from "@react-native-async-storage/async-storage"; export default function CustomDrawerContent(props: {}) { const navigation = useNavigation(); - return ( - - - - Stud-E - - { - navigation.navigate("Home"); - }} - > - - Home - - { - navigation.navigate("Login"); - }} - > - - Login - - { - navigation.navigate("Register"); - }} - > - - Register - - {/* { - navigation.navigate("Revalidation"); - }} - > - - Revalidation - - { - navigation.navigate("Activation"); - }} - > - - Activation - - */} - + const logged_in = useSelector( + (state: RootState) => state.auth.creds.logged_in ); + const dispatch = useDispatch(); + if (logged_in) { + return ( + + + + Stud-E + + { + navigation.navigate("Home"); + }} + > + + Home + + { + dispatch(await clear()); + AsyncStorage.clear(); + }} + > + + Logout + + + ); + } else { + return ( + + + + Stud-E + + { + navigation.navigate("Home"); + }} + > + + Home + + { + navigation.navigate("Login"); + }} + > + + Login + + { + dispatch(clear()); + navigation.navigate("Login"); + }} + > + + Register + + {/* + Debug buttons for accessing revalidation and activation page + { + navigation.navigate("Revalidation"); + }} + > + Revalidation + + { + navigation.navigate("Activation"); + }} + > + Activation + + */} + + ); + } }