import React, { useState, useEffect } from 'react'; import { motion } from 'framer-motion'; import { useNavigate } from 'react-router-dom'; import Sidebar from './navigation/Sidebar'; import UserProfileImage from './ui/UserProfileImage'; import { FiMoon, FiSun } from 'react-icons/fi'; import { cn } from '../lib/utils'; import { useConfigStore } from '../stores/configStore'; import { fetchUserProfile as fetchProfileViaFactory } from '../services/hcs10ClientFactory'; import { useWalletStore } from '../stores/walletStore'; import type { UserProfile } from '../types/userProfile'; interface LayoutProps { children: React.ReactNode; } const ThemeToggle: React.FC = () => { const { config, setTheme } = useConfigStore(); const currentTheme = config && (config as any).advanced && (config as any).advanced.theme ? (config as any).advanced.theme : 'light'; const toggleTheme = async () => { const newTheme = currentTheme === 'light' ? 'dark' : 'light'; await setTheme(newTheme); }; return ( {currentTheme === 'light' ? ( ) : ( )} ); }; const ProfileButton: React.FC = () => { const navigate = useNavigate(); const { config } = useConfigStore(); const wallet = useWalletStore(); const [userProfile, setUserProfile] = useState(null); const [isLoadingProfile, setIsLoadingProfile] = useState(false); useEffect(() => { const fetchUserProfile = async () => { const effectiveAccountId = wallet.isConnected ? wallet.accountId : config?.hedera?.accountId; const effectiveNetwork = wallet.isConnected ? wallet.network : (config?.hedera?.network as ('mainnet'|'testnet'|undefined)); if (effectiveAccountId && effectiveNetwork && !isLoadingProfile) { setIsLoadingProfile(true); try { const resp = await fetchProfileViaFactory( effectiveAccountId as string, effectiveNetwork as any, { walletConnected: wallet.isConnected, operatorId: config?.hedera?.accountId, privateKey: config?.hedera?.privateKey, } ); if (resp.success) { setUserProfile(resp.profile as unknown as UserProfile); } else if (wallet.isConnected) { setUserProfile({ display_name: 'Wallet Account' } as UserProfile); } } catch (error) { } finally { setIsLoadingProfile(false); } } }; fetchUserProfile(); }, [wallet.isConnected, wallet.accountId, wallet.network, config?.hedera?.accountId, config?.hedera?.network]); return ( navigate('/hcs10-profile')} whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.95 }} className={cn( 'ml-3 p-2 rounded-xl transition-all duration-200', 'bg-gradient-to-r from-[#a679f0]/10 to-[#5599fe]/10 hover:from-[#a679f0]/20 hover:to-[#5599fe]/20', 'text-gray-600 dark:text-gray-400 hover:text-gray-800 dark:hover:text-white', 'border border-gray-200/50 dark:border-white/10' )} aria-label='View profile' title='My Profile' > ); }; const Layout: React.FC = ({ children }) => { return (
{/* Static gradient line */}
{children}
); }; export default Layout;