import React from 'react'; import { Text, View, TouchableOpacity, ScrollView } from 'react-native'; import { DrawerContentComponentProps } from '@react-navigation/drawer'; import Icon from 'react-native-vector-icons/Ionicons'; import { menuItems } from '@mock-data'; import { useTheme } from '@theme'; import { DrawerItemProps } from '@interfaces'; import { getStyles } from './customDrawerContent.style'; import { useAppDispatch, logout } from '@store'; const DrawerItem = ({ label, iconName, focused, onPress }: DrawerItemProps) => { const { theme: colors } = useTheme(); const styles = getStyles(colors); return ( {label} ); }; export const CustomDrawerContent = (props: DrawerContentComponentProps) => { const { state, navigation } = props; const { theme: colors } = useTheme(); const styles = getStyles(colors); const dispatch = useAppDispatch(); const handleLogout = async () => { try { dispatch(logout()); } catch (e) { console.error(e); } navigation.reset({ index: 0, routes: [{ name: 'AuthStack' }], // root-level stack name stays as-is }); }; const activeRouteName = state.routeNames[state.index]; return ( {/* Drawer Header Profile */} Convex CRM admin@convex.com {menuItems.map(item => { const isFocused = activeRouteName === item.route; return ( navigation.navigate(item.route)} /> ); })} {/* Drawer Footer / Sign Out */} Log Out ); };