dashboard: reimaginacao
Signed-off-by: Rodrigo B. de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
af2f0ed649
commit
f782fb36ad
3 files changed
+33
-6
No files matched your search
@@ -8,14 +8,23 @@ 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 { token } = useAuth();
|
const { user, 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);
|
||||||
@@ -35,7 +44,7 @@ export const AtendimentosDia: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchAtendimentos();
|
fetchAtendimentos();
|
||||||
}, [token]);
|
}, [user, 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,14 +6,23 @@ 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 { token } = useAuth();
|
const { user, 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);
|
||||||
@@ -33,7 +42,7 @@ export const BenchmarkingEscritorio: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchBenchmarking();
|
fetchBenchmarking();
|
||||||
}, [token]);
|
}, [user, 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,14 +8,23 @@ 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 { token } = useAuth();
|
const { user, 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);
|
||||||
@@ -35,7 +44,7 @@ export const CalendarioAtendimentos: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchEventos();
|
fetchEventos();
|
||||||
}, [token]);
|
}, [user, 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);
|
||||||
|
|||||||
Reference in new issue
Block a user