From 5cf8e4f4b34e16fd48ca4d1b40e5e26ada5aef39 Mon Sep 17 00:00:00 2001 From: "Rodrigo B. de Sousa Martins" Date: Wed, 16 Jul 2025 16:46:38 -0300 Subject: [PATCH] calculo: fix pensaoalimenticia Signed-off-by: Rodrigo B. de Sousa Martins --- src/components/calculos/DetalhesCalculo.tsx | 35 +++++++++++---------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/components/calculos/DetalhesCalculo.tsx b/src/components/calculos/DetalhesCalculo.tsx index 4f09178..c376313 100644 --- a/src/components/calculos/DetalhesCalculo.tsx +++ b/src/components/calculos/DetalhesCalculo.tsx @@ -66,20 +66,25 @@ export function DetalhesCalculo() { valorOriginal: '' }); - useEffect(() => { - const loadCalculo = async () => { - try { - // Buscar cálculo judicial pelo id correto - const response = await api.get(`/api/calculos/${calculoId}`); - setCalculo(response.data); - } catch (error) { - console.error('Erro ao carregar cálculo:', error); - setCalculo(null); - } finally { - setLoading(false); - } - }; + const loadCalculo = async () => { + if (!calculoId) return; + try { + setLoading(true); + setError(null); + + const response = await api.get(`/calculos/${calculoId}`); + setCalculo(response.data); + } catch (error) { + console.error('Erro ao carregar cálculo:', error); + setError('Não foi possível carregar os dados do cálculo'); + toast.error('Erro ao carregar dados do cálculo'); + } finally { + setLoading(false); + } + }; + + useEffect(() => { loadCalculo(); }, [calculoId]); @@ -2001,8 +2006,4 @@ function HistoricoTab({ )} ); -} - )} - - ); }