import { useEffect, useState } from 'react'; import { httpGet } from '../lib/http'; import { useAuth } from '../hooks/use-auth'; import { pageProgressMessage } from '../stores/page'; import { useToast } from '../hooks/use-toast'; import { type UserTeamItem } from './TeamDropdown/TeamDropdown'; export function TeamsList() { const [teamList, setTeamList] = useState([]); const user = useAuth(); const toast = useToast(); async function getAllTeam() { const { response, error } = await httpGet( `${import.meta.env.PUBLIC_API_URL}/v1-get-user-teams` ); if (error || !response) { toast.error(error?.message || 'Something went wrong'); return; } setTeamList(response); } useEffect(() => { getAllTeam().finally(() => { pageProgressMessage.set(''); }); }, []); return (
  • {user?.name Personal Account
  • {teamList.map((team) => { let pageLink = ''; if (team.status === 'invited') { pageLink = `/respond-invite?i=${team.memberId}`; } else if (team.status === 'joined') { pageLink = `/team/activity?t=${team._id}`; } return (
  • {team.name {team.name}
  • ); })}
+ New Team
); }