forked from RiseUP/riseup-squad23
Erro de login
This commit is contained in:
parent
844ebf03a8
commit
95054bb9c1
@ -24,7 +24,7 @@ return(
|
||||
|
||||
<div>
|
||||
|
||||
{showModal ?
|
||||
{showModal === "modal"?
|
||||
|
||||
<div className="modal-overlay">
|
||||
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
import React, { useState, useEffect, use } from "react";
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { Link, useNavigate } from "react-router-dom";
|
||||
import { useAuth } from "../components/utils/AuthProvider";
|
||||
import API_KEY from "../components/utils/apiKeys";
|
||||
import { UserInfos } from "../components/utils/Functions-Endpoints/General";
|
||||
import CabecalhoError from "../components/utils/fetchErros/CabecalhoError";
|
||||
|
||||
function Login({ onEnterSystem }) {
|
||||
const { setAuthTokens } = useAuth();
|
||||
const [showCabecalho, setShowCabecalho ] = useState(false)
|
||||
const navigate = useNavigate();
|
||||
const [form, setForm] = useState({
|
||||
username: "",
|
||||
@ -126,6 +128,9 @@ function Login({ onEnterSystem }) {
|
||||
} else if (UserData?.roles?.includes("financeiro")) {
|
||||
navigate(`/financeiro/`);
|
||||
}
|
||||
}else{
|
||||
console.log("ERROROROROROOR")
|
||||
setShowCabecalho(true)
|
||||
}
|
||||
} else {
|
||||
setAlert("Preencha todos os campos!");
|
||||
@ -148,11 +153,7 @@ function Login({ onEnterSystem }) {
|
||||
<p className="auth-subtitle mb-5">
|
||||
Entre com os dados que você inseriu durante o registro.
|
||||
</p>
|
||||
{alert && (
|
||||
<div className="alert alert-info" role="alert">
|
||||
{alert}
|
||||
</div>
|
||||
)}
|
||||
<CabecalhoError showCabecalho={showCabecalho} message={"E-mail ou senha incorretos."}/>
|
||||
<form onSubmit={handleLogin}>
|
||||
<div className="form-group position-relative has-icon-left mb-4">
|
||||
<input
|
||||
|
||||
@ -4,6 +4,8 @@ import API_KEY from "../components/utils/apiKeys";
|
||||
import { useAuth } from "../components/utils/AuthProvider";
|
||||
import "./style/TablePaciente.css";
|
||||
import ModalErro from "../components/utils/fetchErros/ModalErro";
|
||||
import manager from "../components/utils/fetchErros/ManagerFunction";
|
||||
|
||||
function TablePaciente({ setCurrentPage, setPatientID }) {
|
||||
|
||||
const { getAuthorizationHeader, isAuthenticated, RefreshingToken } = useAuth();
|
||||
@ -24,7 +26,7 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
||||
const [showDeleteModal, setShowDeleteModal] = useState(false);
|
||||
const [selectedPatientId, setSelectedPatientId] = useState(null);
|
||||
|
||||
const [showModalError, setShowModalError] = useState(false);
|
||||
const [showModalError, setShowModalError] = useState("");
|
||||
|
||||
const [ ErrorInfo, setErrorInfo] = useState({})
|
||||
|
||||
@ -117,7 +119,7 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
||||
redirect: 'follow'
|
||||
};
|
||||
|
||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/patients", requestOptions)
|
||||
fetch("https://yuanqfswhberkoevtmfr.supabase.co/rest/v1/patient", requestOptions)
|
||||
.then(response => {
|
||||
|
||||
// 1. VERIFICAÇÃO DO STATUS HTTP (Se não for 2xx)
|
||||
@ -142,21 +144,15 @@ function TablePaciente({ setCurrentPage, setPatientID }) {
|
||||
return response.json();
|
||||
})
|
||||
.then(result => {
|
||||
// 4. Bloco de SUCESSO
|
||||
|
||||
setPacientes(result);
|
||||
console.log("Sucesso:", result);
|
||||
|
||||
// IMPORTANTE: Se o modal estava aberto, feche-o no sucesso
|
||||
setShowModalError(false);
|
||||
})
|
||||
.catch(error => {
|
||||
// 5. Bloco de ERRO (Captura erros de rede ou o erro lançado pelo 'throw')
|
||||
//console.error('Falha na requisição:', error.message);
|
||||
if(error.httpStatus === 401){
|
||||
RefreshingToken()
|
||||
}
|
||||
setErrorInfo(error)
|
||||
setShowModalError(true);
|
||||
manager(setShowModalError, RefreshingToken, setErrorInfo, error)
|
||||
|
||||
});
|
||||
}, [isAuthenticated, getAuthorizationHeader]);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user