import { Link } from "react-router-dom"; import { useQuery } from "@tanstack/react-query"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "@/components/ui/card"; import { api } from "@/lib/api"; import { Flag } from "lucide-react"; interface GoalDto { id: string; name: string; targetAmount: number; currentAmount: number; color: string; } const MAX_SHOWN = 3; /** * Surfaces the user's existing goals (Goals Tracker) here too, so checking * progress doesn't mean leaving the investments view. This is not a "funded * by investments" computation, goals aren't linked to specific holdings or * accounts anywhere in this app, just each goal's own tracked progress. */ export function GoalsPanel() { const { data: goals, isLoading } = useQuery({ queryKey: ["goals"], queryFn: () => api.get("goals"), }); const shown = (goals ?? []).slice(0, MAX_SHOWN); return (
Goals Your active savings goals
View all
{isLoading ? (

Loading…

) : shown.length === 0 ? (
Create your first goal
) : ( shown.map((g) => { const pct = g.targetAmount > 0 ? Math.min(100, (g.currentAmount / g.targetAmount) * 100) : 0; return (
{g.name} {pct.toFixed(0)}%
); }) )} ); }