import { FC, ReactElement } from 'react'; import { Link } from 'react-router'; import { useMyTeams, useMyInvitations, useRespondToInvitation, useAuthStore, } from '@imphnen-frontend-service/service'; import { toast } from 'sonner'; import { Button } from '@imphnen-frontend-service/ui/atoms'; const DashboardPage: FC = (): ReactElement => { const { session } = useAuthStore(); const { data: teamsData } = useMyTeams(); const { data: invitationsData } = useMyInvitations(); const { mutateAsync: respondToInvitation } = useRespondToInvitation(); const user = session?.user; const myTeams = teamsData?.data || []; const invitations = invitationsData?.data || []; const handleAcceptInvitation = async (invitationId: string) => { try { await respondToInvitation({ invitationId, action: 'accept' }); toast.success('Invitation accepted! You are now a team member.'); } catch (error) { console.error('Failed to accept invitation:', error); toast.error('Failed to accept invitation'); } }; const handleRejectInvitation = async (invitationId: string) => { try { await respondToInvitation({ invitationId, action: 'reject' }); toast.success('Invitation declined'); } catch (error) { console.error('Failed to reject invitation:', error); toast.error('Failed to decline invitation'); } }; return (

Welcome, {user?.fullname || user?.email?.split('@')[0] || 'User'}!

{user?.location && (

Location: {user.location}

)}
{invitations.length > 0 && (

Team Invitations ({invitations.length})

{invitations.map((invitation) => (

{invitation.team.name}

Invited by {invitation.inviter.fullname}

))}
)} {myTeams.length > 0 ? (

My Team

{myTeams.map((team) => ( {team.banner && {team.name}}
{team.logo && {team.name}}

{team.name}

City: {team.city}

{team.description}

))}
) : (
👋

You are not in a team yet

Use the sidebar to browse teams or create your own

)}
{user?.avatar ? ( {user.fullname ) : (
User
)}

{user?.fullname || user?.email?.split('@')[0] || 'Unnamed User'}

{user?.location ? (

{user.location}

) : ( Complete your profile )}
{user?.location && ( Edit Profile )}
{user?.bio && (

About

{user.bio}

)}

Contact

{user?.email}
{user?.skills && user.skills.length > 0 && (

Skills

{user.skills.map((skill: string) => ( {skill} ))}
)}
); }; export default DashboardPage;