From 3e561b46bb554a1945862b37078f85cf25642c2a Mon Sep 17 00:00:00 2001 From: "Rodrigo B. de Sousa Martins" Date: Wed, 16 Jul 2025 16:26:25 -0300 Subject: [PATCH] calculo: fix pensaoalimenticia Signed-off-by: Rodrigo B. de Sousa Martins --- .../calculos/DetalhePensaoAlimenticia.tsx | 4 +-- src/components/calculos/DetalhesCalculo.tsx | 35 +++++++++---------- .../calculos/NovoPensaoAlimenticia.tsx | 3 ++ 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/components/calculos/DetalhePensaoAlimenticia.tsx b/src/components/calculos/DetalhePensaoAlimenticia.tsx index 3e475d6..42805fe 100644 --- a/src/components/calculos/DetalhePensaoAlimenticia.tsx +++ b/src/components/calculos/DetalhePensaoAlimenticia.tsx @@ -39,12 +39,12 @@ export function DetalhePensaoAlimenticia() { } const loadCalculo = async () => { try { - // Buscar cálculo pelo endpoint correto + // Endpoint correto para buscar cálculo de pensão alimentícia const response = await api.get(`/api/pensao-alimenticia/${id}`); setCalculo(response.data); } catch (error) { console.error('Erro ao carregar cálculo:', error); - setCalculo(null); // Não exibir erro, apenas não mostrar cálculo + setCalculo(null); } finally { setLoading(false); } diff --git a/src/components/calculos/DetalhesCalculo.tsx b/src/components/calculos/DetalhesCalculo.tsx index c376313..4f09178 100644 --- a/src/components/calculos/DetalhesCalculo.tsx +++ b/src/components/calculos/DetalhesCalculo.tsx @@ -66,25 +66,20 @@ export function DetalhesCalculo() { valorOriginal: '' }); - 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(() => { + 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); + } + }; + loadCalculo(); }, [calculoId]); @@ -2006,4 +2001,8 @@ function HistoricoTab({ )} ); +} + )} + + ); } diff --git a/src/components/calculos/NovoPensaoAlimenticia.tsx b/src/components/calculos/NovoPensaoAlimenticia.tsx index 7e970df..717388a 100644 --- a/src/components/calculos/NovoPensaoAlimenticia.tsx +++ b/src/components/calculos/NovoPensaoAlimenticia.tsx @@ -103,6 +103,8 @@ export function NovoPensaoAlimenticia() { ...formData, percentualSalarioMinimo: percentual, multaPactuada: formData.multaPactuada ? parsePercentual(formData.multaPactuada) : undefined, + processoId: formData.processoId || undefined, // Corrigir aqui + clienteId: formData.clienteId || undefined, // Corrigir aqui }; const token = getToken(); @@ -115,6 +117,7 @@ export function NovoPensaoAlimenticia() { method: 'POST', headers: { 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` // Adicionar o token aqui }, body: JSON.stringify(dadosParaEnviar), });