'use client'; /** * Mobile Bottom Bar Navigation * * Fixed bottom navigation for mobile devices (< 768px). * Shows three buttons: Convo, Edit, Galaxy * Highlights the active mode based on app state machine. */ import { Group, Button, Paper, ActionIcon, Box, Stack, Text } from '@mantine/core'; import { IconMessageCircle, IconEdit, IconChartBubbleFilled, IconUser } from '@tabler/icons-react'; import { useSelector } from '@xstate/react'; import { useAppMachine } from '@/hooks/useAppMachine'; import { UserMenu } from '@/components/UserMenu'; import { useState, useEffect } from 'react'; interface UserProfile { did: string; handle: string; displayName: string | null; avatar: string | null; } export function MobileBottomBar() { const actor = useAppMachine(); const state = useSelector(actor, (state) => state); const send = actor.send; const [profile, setProfile] = useState(null); useEffect(() => { fetch('/api/user/profile') .then((res) => res.json()) .then((data) => { if (!data.error) { setProfile(data); } }) .catch((error) => { console.error('Failed to fetch profile:', error); }); }, []); const handleNavigation = (target: 'convo' | 'edit' | 'galaxy') => { console.log('[Mobile Nav] Navigating to:', target); if (target === 'convo') { send({ type: 'NAVIGATE_TO_CONVO' }); } else if (target === 'edit') { send({ type: 'NAVIGATE_TO_EDIT' }); } else if (target === 'galaxy') { send({ type: 'NAVIGATE_TO_GALAXY' }); } }; const isConvo = state.matches('convo'); const isEdit = state.matches('edit'); const isGalaxy = state.matches('galaxy'); console.log('[Mobile Nav] Current state:', state.value, { isConvo, isEdit, isGalaxy, }); return ( handleNavigation('convo')} style={{ cursor: 'pointer' }}> Convo handleNavigation('edit')} style={{ cursor: 'pointer' }}> Manual handleNavigation('galaxy')} style={{ cursor: 'pointer' }}> Galaxy Profile ); }