dashboard: reimaginacao
Signed-off-by: Rodrigo B. de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
1ab7bd8f36
commit
1e08f559ff
5 files changed
+7
-56
No files matched your search
@@ -8,23 +8,14 @@ interface Atendimento {
|
|||||||
status: string;
|
status: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidJWT(token?: string) {
|
|
||||||
return !!token && token.split('.').length === 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const AtendimentosDia: React.FC = () => {
|
export const AtendimentosDia: React.FC = () => {
|
||||||
const { user, token } = useAuth();
|
const { token } = useAuth();
|
||||||
const [atendimentos, setAtendimentos] = useState<Atendimento[]>([]);
|
const [atendimentos, setAtendimentos] = useState<Atendimento[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchAtendimentos() {
|
async function fetchAtendimentos() {
|
||||||
if (!user || !isValidJWT(token)) {
|
|
||||||
setError('Usuário não autenticado ou token inválido. Faça login novamente.');
|
|
||||||
setLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
@@ -44,7 +35,7 @@ export const AtendimentosDia: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchAtendimentos();
|
fetchAtendimentos();
|
||||||
}, [user, token]);
|
}, [token]);
|
||||||
|
|
||||||
if (loading) return <div>Carregando atendimentos...</div>;
|
if (loading) return <div>Carregando atendimentos...</div>;
|
||||||
if (error) return <div className="text-red-600">{error}</div>;
|
if (error) return <div className="text-red-600">{error}</div>;
|
||||||
|
|||||||
@@ -6,23 +6,14 @@ interface Benchmarking {
|
|||||||
emTramitacao: number;
|
emTramitacao: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidJWT(token?: string) {
|
|
||||||
return !!token && token.split('.').length === 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const BenchmarkingEscritorio: React.FC = () => {
|
export const BenchmarkingEscritorio: React.FC = () => {
|
||||||
const { user, token } = useAuth();
|
const { token } = useAuth();
|
||||||
const [benchmarking, setBenchmarking] = useState<Benchmarking | null>(null);
|
const [benchmarking, setBenchmarking] = useState<Benchmarking | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchBenchmarking() {
|
async function fetchBenchmarking() {
|
||||||
if (!user || !isValidJWT(token)) {
|
|
||||||
setError('Usuário não autenticado ou token inválido. Faça login novamente.');
|
|
||||||
setLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
@@ -42,7 +33,7 @@ export const BenchmarkingEscritorio: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchBenchmarking();
|
fetchBenchmarking();
|
||||||
}, [user, token]);
|
}, [token]);
|
||||||
|
|
||||||
if (loading) return <div>Carregando benchmarking...</div>;
|
if (loading) return <div>Carregando benchmarking...</div>;
|
||||||
if (error) return <div className="text-red-600">{error}</div>;
|
if (error) return <div className="text-red-600">{error}</div>;
|
||||||
|
|||||||
@@ -8,23 +8,14 @@ interface Evento {
|
|||||||
descricao: string;
|
descricao: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidJWT(token?: string) {
|
|
||||||
return !!token && token.split('.').length === 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const CalendarioAtendimentos: React.FC = () => {
|
export const CalendarioAtendimentos: React.FC = () => {
|
||||||
const { user, token } = useAuth();
|
const { token } = useAuth();
|
||||||
const [eventos, setEventos] = useState<Evento[]>([]);
|
const [eventos, setEventos] = useState<Evento[]>([]);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchEventos() {
|
async function fetchEventos() {
|
||||||
if (!user || !isValidJWT(token)) {
|
|
||||||
setError('Usuário não autenticado ou token inválido. Faça login novamente.');
|
|
||||||
setLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
@@ -44,7 +35,7 @@ export const CalendarioAtendimentos: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchEventos();
|
fetchEventos();
|
||||||
}, [user, token]);
|
}, [token]);
|
||||||
|
|
||||||
// Simulação de calendário mensal
|
// Simulação de calendário mensal
|
||||||
const diasMes = Array.from({ length: 30 }, (_, i) => i + 1);
|
const diasMes = Array.from({ length: 30 }, (_, i) => i + 1);
|
||||||
|
|||||||
@@ -5,20 +5,8 @@ import { CalendarioAtendimentos } from './CalendarioAtendimentos';
|
|||||||
import { BenchmarkingEscritorio } from './BenchmarkingEscritorio';
|
import { BenchmarkingEscritorio } from './BenchmarkingEscritorio';
|
||||||
import { AtendimentosDia } from './AtendimentosDia';
|
import { AtendimentosDia } from './AtendimentosDia';
|
||||||
|
|
||||||
function isValidJWT(token?: string) {
|
|
||||||
return !!token && token.split('.').length === 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DashboardLayout: React.FC = () => {
|
export const DashboardLayout: React.FC = () => {
|
||||||
const { user, token } = useAuth();
|
const { user } = useAuth();
|
||||||
|
|
||||||
if (!user || !isValidJWT(token)) {
|
|
||||||
return (
|
|
||||||
<div className="p-6 text-center text-red-600 font-bold">
|
|
||||||
Usuário não autenticado ou token inválido. Faça login novamente.
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6 p-6">
|
<div className="grid grid-cols-1 lg:grid-cols-3 gap-6 p-6">
|
||||||
|
|||||||
@@ -7,11 +7,6 @@ interface Tarefa {
|
|||||||
status: string;
|
status: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isValidJWT(token?: string) {
|
|
||||||
// JWT tem 3 partes separadas por ponto e cada parte deve ser base64
|
|
||||||
return !!token && token.split('.').length === 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const WorkflowTarefas: React.FC = () => {
|
export const WorkflowTarefas: React.FC = () => {
|
||||||
const { token } = useAuth();
|
const { token } = useAuth();
|
||||||
const [tarefas, setTarefas] = useState<Tarefa[]>([]);
|
const [tarefas, setTarefas] = useState<Tarefa[]>([]);
|
||||||
@@ -20,11 +15,6 @@ export const WorkflowTarefas: React.FC = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function fetchTarefas() {
|
async function fetchTarefas() {
|
||||||
if (!isValidJWT(token)) {
|
|
||||||
setError('Token de autenticação inválido ou ausente. Faça login novamente.');
|
|
||||||
setLoading(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setError(null);
|
setError(null);
|
||||||
|
|||||||
Reference in new issue
Block a user