diff --git a/src/components/dashboard/AtendimentosDia.tsx b/src/components/dashboard/AtendimentosDia.tsx new file mode 100644 index 0000000..5b6e94d --- /dev/null +++ b/src/components/dashboard/AtendimentosDia.tsx @@ -0,0 +1,49 @@ +import React, { useEffect, useState } from 'react'; + +interface Atendimento { + id: string; + hora: string; + cliente: string; + status: string; +} + +export const AtendimentosDia: React.FC = () => { + const [atendimentos, setAtendimentos] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + async function fetchAtendimentos() { + try { + setLoading(true); + setError(null); + const res = await fetch('/api/atendimentos-dia'); + if (!res.ok) throw new Error('Erro ao buscar atendimentos do dia'); + const data = await res.json(); + setAtendimentos(data); + } catch (err: any) { + setError(err.message); + } finally { + setLoading(false); + } + } + fetchAtendimentos(); + }, []); + + if (loading) return
Carregando atendimentos...
; + if (error) return
{error}
; + + return ( +
+

Atendimentos do Dia

+
    + {atendimentos.map((at) => ( +
  • + {at.hora} - {at.cliente} + {at.status} +
  • + ))} +
+
+ ); +}; diff --git a/src/components/dashboard/BenchmarkingEscritorio.tsx b/src/components/dashboard/BenchmarkingEscritorio.tsx new file mode 100644 index 0000000..37082dd --- /dev/null +++ b/src/components/dashboard/BenchmarkingEscritorio.tsx @@ -0,0 +1,47 @@ +import React, { useEffect, useState } from 'react'; + +interface Benchmarking { + ajuizados15dias: number; + emTramitacao: number; +} + +export const BenchmarkingEscritorio: React.FC = () => { + const [benchmarking, setBenchmarking] = useState(null); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + async function fetchBenchmarking() { + try { + setLoading(true); + setError(null); + const res = await fetch('/api/benchmarking'); + if (!res.ok) throw new Error('Erro ao buscar benchmarking'); + const data = await res.json(); + setBenchmarking(data); + } catch (err: any) { + setError(err.message); + } finally { + setLoading(false); + } + } + fetchBenchmarking(); + }, []); + + if (loading) return
Carregando benchmarking...
; + if (error) return
{error}
; + if (!benchmarking) return null; + + return ( +
+
+ Processos ajuizados (últimos 15 dias): + {benchmarking.ajuizados15dias} +
+
+ Processos em tramitação: + {benchmarking.emTramitacao} +
+
+ ); +}; diff --git a/src/components/dashboard/CalendarioAtendimentos.tsx b/src/components/dashboard/CalendarioAtendimentos.tsx new file mode 100644 index 0000000..b1b5eb6 --- /dev/null +++ b/src/components/dashboard/CalendarioAtendimentos.tsx @@ -0,0 +1,67 @@ +import React, { useEffect, useState } from 'react'; + +interface Evento { + id: string; + data: string; + tipo: string; + descricao: string; +} + +export const CalendarioAtendimentos: React.FC = () => { + const [eventos, setEventos] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + async function fetchEventos() { + try { + setLoading(true); + setError(null); + const res = await fetch('/api/eventos'); + if (!res.ok) throw new Error('Erro ao buscar eventos'); + const data = await res.json(); + setEventos(data); + } catch (err: any) { + setError(err.message); + } finally { + setLoading(false); + } + } + fetchEventos(); + }, []); + + // Simulação de calendário mensal + const diasMes = Array.from({ length: 30 }, (_, i) => i + 1); + const mes = '06'; + const ano = '2024'; + + if (loading) return
Carregando calendário...
; + if (error) return
{error}
; + + return ( +
+
+ {diasMes.map((dia) => { + const dataStr = `${ano}-${mes}-${dia.toString().padStart(2, '0')}`; + const eventosDia = eventos.filter(e => e.data === dataStr); + return ( +
+ {dia} + {eventosDia.map((ev) => ( + {ev.tipo} + ))} +
+ ); + })} +
+
+

Próximos eventos

+
    + {eventos.map((ev) => ( +
  • {ev.data}: {ev.tipo} - {ev.descricao}
  • + ))} +
+
+
+ ); +}; diff --git a/src/components/dashboard/DashboardLayout.tsx b/src/components/dashboard/DashboardLayout.tsx index 4920c40..30cbee9 100644 --- a/src/components/dashboard/DashboardLayout.tsx +++ b/src/components/dashboard/DashboardLayout.tsx @@ -1,52 +1,34 @@ import React from 'react'; import { useAuth } from '../../contexts/AuthContext'; -import { useDashboardStats } from '../../hooks/useDashboardStats'; -import { ProcessosStats } from './stats/ProcessosStats'; -import { TarefasStats } from './stats/TarefasStats'; -import { AtendimentosStats } from './stats/AtendimentosStats'; -import { FinanceiroStats } from './stats/FinanceiroStats'; -import { AlertasPrazos } from './AlertasPrazos'; -import { AtividadesRecentes } from './AtividadesRecentes'; -import { TaxaSucessoCard } from './TaxaSucessoCard'; -import { KPIsFinanceiros } from './stats/KPIsFinanceiros'; +import { WorkflowTarefas } from './WorkflowTarefas'; +import { CalendarioAtendimentos } from './CalendarioAtendimentos'; +import { BenchmarkingEscritorio } from './BenchmarkingEscritorio'; +import { AtendimentosDia } from './AtendimentosDia'; export const DashboardLayout: React.FC = () => { const { user } = useAuth(); - const { - processosStats, - tarefasStats, - atendimentosStats, - financeiroStats, - proximosPrazos, - atividades - } = useDashboardStats(); - - const isAdminOrAdvogado = ['ADVOGADO_ADMIN', 'ADVOGADO'].includes(user?.perfil || ''); + // ...aqui você pode usar hooks customizados para buscar os dados necessários... return ( -
- {/* Stats Cards */} -
- {processosStats.data && } - {tarefasStats.data && } - {atendimentosStats.data && } - {isAdminOrAdvogado && financeiroStats.data && ( - - )} +
+ {/* Coluna 1: Workflow de Tarefas */} +
+

Workflow de Tarefas

+
-
- {/* Coluna da esquerda */} -
- - {isAdminOrAdvogado && } -
+ {/* Coluna 2: Calendário de Atendimentos, Compromissos e Diligências */} +
+

Calendário

+ +

Atendimentos do Dia

+ +
- {/* Coluna da direita */} -
- - -
+ {/* Coluna 3: Benchmarking do Escritório */} +
+

Benchmarking do Escritório

+
); diff --git a/src/components/dashboard/WorkflowTarefas.tsx b/src/components/dashboard/WorkflowTarefas.tsx new file mode 100644 index 0000000..aaf6b15 --- /dev/null +++ b/src/components/dashboard/WorkflowTarefas.tsx @@ -0,0 +1,56 @@ +import React, { useEffect, useState } from 'react'; +import { useAuth } from '../../contexts/AuthContext'; + +interface Tarefa { + id: string; + titulo: string; + status: string; +} + +export const WorkflowTarefas: React.FC = () => { + const { token } = useAuth(); + const [tarefas, setTarefas] = useState([]); + const [loading, setLoading] = useState(true); + const [error, setError] = useState(null); + + useEffect(() => { + async function fetchTarefas() { + try { + setLoading(true); + setError(null); + const res = await fetch('/api/tarefas', { + headers: { + Authorization: `Bearer ${token}`, + 'Content-Type': 'application/json', + }, + }); + if (!res.ok) throw new Error('Erro ao buscar tarefas'); + const data = await res.json(); + setTarefas(data); + } catch (err: any) { + setError(err.message); + } finally { + setLoading(false); + } + } + fetchTarefas(); + }, [token]); + + if (loading) return
Carregando tarefas...
; + if (error) return
{error}
; + + return ( +
+ {tarefas.map((tarefa) => ( +
+ {tarefa.titulo} + + {tarefa.status} + +
+ ))} +
+ ); +};