forked from farhoodlabs/paperclip
f4339668f3
New pages: AgentDetail, GoalDetail, IssueDetail, ProjectDetail, Inbox, MyIssues. New feature components: AgentProperties, GoalProperties, IssueProperties, ProjectProperties, GoalTree, NewIssueDialog. Add heartbeats API client. Restyle all list pages (Agents, Issues, Goals, Projects, Dashboard, Costs, Activity, Org) with EntityRow, FilterBar, and improved layouts. Add routing for detail views. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { useCallback, useEffect } from "react";
|
|
import { useNavigate } from "react-router-dom";
|
|
import { goalsApi } from "../api/goals";
|
|
import { useApi } from "../hooks/useApi";
|
|
import { useCompany } from "../context/CompanyContext";
|
|
import { useBreadcrumbs } from "../context/BreadcrumbContext";
|
|
import { GoalTree } from "../components/GoalTree";
|
|
import { EmptyState } from "../components/EmptyState";
|
|
import { Target } from "lucide-react";
|
|
|
|
export function Goals() {
|
|
const { selectedCompanyId } = useCompany();
|
|
const { setBreadcrumbs } = useBreadcrumbs();
|
|
const navigate = useNavigate();
|
|
|
|
useEffect(() => {
|
|
setBreadcrumbs([{ label: "Goals" }]);
|
|
}, [setBreadcrumbs]);
|
|
|
|
const fetcher = useCallback(() => {
|
|
if (!selectedCompanyId) return Promise.resolve([]);
|
|
return goalsApi.list(selectedCompanyId);
|
|
}, [selectedCompanyId]);
|
|
|
|
const { data: goals, loading, error } = useApi(fetcher);
|
|
|
|
if (!selectedCompanyId) {
|
|
return <EmptyState icon={Target} message="Select a company to view goals." />;
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
<h2 className="text-lg font-semibold">Goals</h2>
|
|
|
|
{loading && <p className="text-sm text-muted-foreground">Loading...</p>}
|
|
{error && <p className="text-sm text-destructive">{error.message}</p>}
|
|
|
|
{goals && goals.length === 0 && (
|
|
<EmptyState icon={Target} message="No goals yet." />
|
|
)}
|
|
|
|
{goals && goals.length > 0 && (
|
|
<GoalTree goals={goals} onSelect={(goal) => navigate(`/goals/${goal.id}`)} />
|
|
)}
|
|
</div>
|
|
);
|
|
}
|