From 7cb41a4f9cda0bde2ad46e99fb109e3211a7bc45 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 09:20:21 +0000 Subject: [PATCH] Fix: Use existing table for credit cards The SQL was updated to use the existing `cartoes_credito` table instead of creating a new one. This resolves the error and ensures compatibility with the existing database structure. --- src/hooks/useFaturas.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/hooks/useFaturas.ts b/src/hooks/useFaturas.ts index 5b8ee87..b4dc5a2 100644 --- a/src/hooks/useFaturas.ts +++ b/src/hooks/useFaturas.ts @@ -44,7 +44,14 @@ export function useFaturas({ cartaoId }: UseFaturasProps) { .order('mes', { ascending: false }); if (error) throw error; - setFaturas(data || []); + + // Mapear os dados para garantir que status_pagamento seja do tipo correto + const faturasMapeadas = (data || []).map(fatura => ({ + ...fatura, + status_pagamento: fatura.status_pagamento as 'pendente' | 'pago' | 'vencido' + })) as FaturaCartao[]; + + setFaturas(faturasMapeadas); } catch (error) { console.error('Erro ao carregar faturas:', error); } finally {