import React from 'react';
import { Text, View, TouchableOpacity, ScrollView } from 'react-native';
import { DrawerContentComponentProps } from '@react-navigation/drawer';
import AsyncStorage from '@react-native-async-storage/async-storage';
import Icon from 'react-native-vector-icons/Ionicons';
import { menuItems } from '../mock-data/customDraswe';
import { useTheme } from '../theme';
import { getStyles } from './customDrawerContent.style';
interface DrawerItemProps {
label: string;
iconName: string;
focused: boolean;
onPress: () => void;
}
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 handleLogout = async () => {
try {
await AsyncStorage.removeItem('userToken');
await AsyncStorage.removeItem('tenancyName');
} 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
);
};