dashboard: reimaginacao
Signed-off-by: Rodrigo B. de Sousa Martins <rodrigo.sousa.577@gmail.com>
This commit is contained in:
1 parent
6b89a61dd7
commit
af2f0ed649
1 file changed
+10
@@ -7,6 +7,11 @@ interface Tarefa {
|
||||
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 = () => {
|
||||
const { token } = useAuth();
|
||||
const [tarefas, setTarefas] = useState<Tarefa[]>([]);
|
||||
@@ -15,6 +20,11 @@ export const WorkflowTarefas: React.FC = () => {
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchTarefas() {
|
||||
if (!isValidJWT(token)) {
|
||||
setError('Token de autenticação inválido ou ausente. Faça login novamente.');
|
||||
setLoading(false);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
|
||||
Reference in new issue
Block a user