import { useCallback } from "react"; import { goalsApi } from "../api/goals"; import { useApi } from "../hooks/useApi"; import { StatusBadge } from "../components/StatusBadge"; import { useCompany } from "../context/CompanyContext"; import { Card, CardContent } from "@/components/ui/card"; export function Goals() { const { selectedCompanyId } = useCompany(); const fetcher = useCallback(() => { if (!selectedCompanyId) return Promise.resolve([]); return goalsApi.list(selectedCompanyId); }, [selectedCompanyId]); const { data: goals, loading, error } = useApi(fetcher); if (!selectedCompanyId) { return

Select a company first.

; } return (

Goals

{loading &&

Loading...

} {error &&

{error.message}

} {goals && goals.length === 0 &&

No goals yet.

} {goals && goals.length > 0 && (
{goals.map((goal) => (

{goal.title}

{goal.description &&

{goal.description}

}

Level: {goal.level}

))}
)}
); }