import { useEffect, useState } from 'react'; import { Link, useParams } from 'react-router-dom'; import { getUserProjects, type ProjectResponse } from '../services/projectService'; import { useAuthStore } from '../store/useAuthStore'; import { AppHeader } from '../components/layout/AppHeader'; import './UserProfilePage.css'; export const UserProfilePage: React.FC = () => { const { username } = useParams<{ username: string }>(); const user = useAuthStore((s) => s.user); const [projects, setProjects] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(''); useEffect(() => { if (!username) return; setLoading(true); getUserProjects(username) .then(setProjects) .catch(() => setError('User not found.')) .finally(() => setLoading(false)); }, [username]); const isOwn = user?.username === username; return (
{username?.[0]?.toUpperCase()}

{username}

{isOwn && ( + New project )}
{loading &&

Loading…

} {error &&

{error}

} {!loading && !error && projects.length === 0 && (

No public projects yet.

)}
{projects.map((p) => (
{p.name}
{p.description &&
{p.description}
}
{p.board_type} {!p.is_public && Private} {new Date(p.updated_at).toLocaleDateString()}
))}
); };