diff --git a/src/components/dashboard/DashboardSummaryCards.tsx b/src/components/dashboard/DashboardSummaryCards.tsx index 252b3fc..9da8c83 100644 --- a/src/components/dashboard/DashboardSummaryCards.tsx +++ b/src/components/dashboard/DashboardSummaryCards.tsx @@ -62,7 +62,7 @@ const DashboardSummaryCards: React.FC = ({ resumo, f

{resumo ? formatCurrency(resumo.totalDespesas) : 'R$ 0,00'}

- {resumo && resumo.totalCartoes > 0 && ( + {resumo && resumo.totalCartoes && resumo.totalCartoes > 0 && (

Cartões: diff --git a/src/pages/Categorias.tsx b/src/pages/Categorias.tsx index 7f80fcb..fbf400b 100644 --- a/src/pages/Categorias.tsx +++ b/src/pages/Categorias.tsx @@ -6,6 +6,7 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@ import { useToast } from "@/hooks/use-toast"; import { getCategorySummary } from '@/services/transacao'; import { CategorySummary } from '@/types/financialTypes'; +import { MonthFilter } from "@/components/filters/MonthFilter"; interface CategoryCard { nome: string; @@ -17,13 +18,19 @@ interface CategoryCard { const Categorias = () => { const [categories, setCategories] = useState([]); const [filtro, setFiltro] = useState<'despesa' | 'receita'>('despesa'); + const [selectedMonth, setSelectedMonth] = useState(() => { + const now = new Date(); + return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}`; + }); const [isLoading, setIsLoading] = useState(true); const { toast } = useToast(); const loadCategories = async () => { try { setIsLoading(true); - const data = await getCategorySummary(filtro); + console.log("Carregando categorias com filtro:", filtro, "mês:", selectedMonth); + const data = await getCategorySummary(filtro, selectedMonth); + console.log("Categorias carregadas:", data); setCategories(data); } catch (error) { console.error("Erro ao carregar categorias:", error); @@ -39,7 +46,7 @@ const Categorias = () => { useEffect(() => { loadCategories(); - }, [filtro]); + }, [filtro, selectedMonth]); const formatCurrency = (value: number) => { return new Intl.NumberFormat('pt-BR', { @@ -59,11 +66,17 @@ const Categorias = () => {

Categorias

- +
+ + +
{[1, 2, 3, 4, 5, 6].map((i) => ( @@ -87,6 +100,10 @@ const Categorias = () => {

Categorias

+ Filtrar por: