import React, { use, useEffect } from 'react'; import { useSelector } from 'react-redux'; import { Link, useParams } from 'react-router-dom'; import { FaCog } from 'react-icons/fa'; import { IoIosNotifications } from 'react-icons/io'; import { RootState } from '../../store/store'; import { UserState } from '../../store/slices/userSlice'; import api from '../../config/api'; // const fetchAccountData = async (accountId: string) => { // try { // if(!accountId) return null; // const response = await api.get(`/api/accounts/${accountId}`); // return response.data; // } catch (error) { // console.error("Error fetching account data:", error); // throw error; // } // } // const fetchTransactionData = async (accountId: string, transactionId: string) => { // try { // if(!accountId || !transactionId) return null; // const response = await api.get(`/api/accounts/${accountId}/transactions/${transactionId}`); // return response.data; // } catch (error) { // console.error("Error fetching account data:", error); // throw error; // } // } interface AccountNavProps { accountName: string | null; transactionName: string | null; } const AccountNav: React.FC = ({ accountName = null, transactionName = null }) => { const user: UserState = useSelector((state: RootState) => state.user); const initials = user.username ? user.username .split(' ') .map((n) => n[0]) .join('') .slice(0, 2) .toUpperCase() : 'U'; // useEffect(() => { // if (accountId) { // api.get(`/api/accounts/${accountId}`) // .then(response => { // // Handle the account data if needed // console.log(response.data, "Line 29"); // }) // .catch(error => { // console.error("Error fetching account data:", error); // }); // } // }, [accountId, transactionId]); return (

Account {accountName ? ` > ${accountName}` : ''} {transactionName ? ` > ${transactionName}` : ''}

{/*

Account

*/}
{/* Notification + Settings with smaller gap */}
{/* Avatar with separate spacing */}
{user.picture ? ( User avatar ) : ( initials )}
); }; export default AccountNav;