Skip to content
Snippets Groups Projects
Commit f6375d04 authored by vgm18's avatar vgm18
Browse files

added a loading screen after login to prevent the user changing pages if not...

added a loading screen after login to prevent the user changing pages if not loaded, avoiding status 401 errors
parent dce96c8b
No related branches found
No related tags found
4 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...,!51Fixed resource editing not updating in some cases, inability to publish a...,!49Fixed resource editing not updating in some cases, inability to publish a...
......@@ -26,6 +26,7 @@ import {Store} from '../Store.js'
import Snackbar from '@material-ui/core/Snackbar';
import MuiAlert from '@material-ui/lab/Alert';
import {authentication} from './HelperFunctions/getAxiosConfig'
import LoadingSpinner from './LoadingSpinner.js'
const StyledLogin = styled(Modal)`
margin : 0 !important;
......@@ -46,6 +47,7 @@ export default function LoginModal (props){
const {state, dispatch} = useContext(Store)
const [snackbarOpened, handleSnackbar] = useState(false)
const [loading, setLoading] = useState(false)
const handleCloseSnackbar = (event, reason) => {
if (reason === 'clickaway') {
......@@ -55,6 +57,14 @@ export default function LoginModal (props){
handleSnackbar(false);
}
async function sleep(ms){
setLoading(true)
await new Promise(resolve => setTimeout(resolve, ms))
props.handleClose();
props.openSnackbar();
setLoading(false)
}
function handleSuccess (data) {
dispatch ({
type: "USER_LOGGED_IN",
......@@ -62,8 +72,7 @@ export default function LoginModal (props){
login: data.data
}
)
props.handleClose();
props.openSnackbar();
sleep(4000)
}
function handleError (error) {
handleSnackbar(true)
......@@ -99,10 +108,20 @@ export default function LoginModal (props){
}}
>
<Zoom in={props.open} style={{ transitionDelay :"0.2ms"}}>
<LoginContainer handleClose={props.handleClose}
openSignUp={props.openSignUp}
handleLoginInfo={handleLoginInfo}
/>
{
loading ? (
<div style={{backgroundColor: 'white', padding: '10px'}}>
<LoadingSpinner text={'Carregando...'} />
</div>
)
:
(
<LoginContainer handleClose={props.handleClose}
openSignUp={props.openSignUp}
handleLoginInfo={handleLoginInfo}
/>
)
}
</Zoom>
</StyledLogin>
......
......@@ -34,7 +34,7 @@ export default function TabPanelSolicitarContaProfessor (props) {
<div className='card-config'>
<div className='content-div'>
{
state.currentUser.submitter_request === 'default' || state.currentUser.submitter_request === 'rejected' ?
!state.currentUser.roles.some(role => role.name === "teacher") && ( state.currentUser.submitter_request === 'default' || state.currentUser.submitter_request === 'rejected' ) ?
(
<div>
<ImageDiv/>
......@@ -60,11 +60,11 @@ export default function TabPanelSolicitarContaProfessor (props) {
{
state.currentUser.submitter_request === 'requested' ?
(
<span>Requested</span>
<h1>A sua conta de Professor foi solicitada</h1>
)
:
(
<span>Professor</span>
<h1>Você possui uma conta de Professor</h1>
)
}
</>
......
......@@ -126,9 +126,9 @@ const Container = styled.div`
border-radius : 4px;
box-shadow : 0 7px 8px -4px rgba(0,0,0,.2),0 13px 19px 2px rgba(0,0,0,.14),0 5px 24px 4px rgba(0,0,0,.12);
@media screen and (max-width : 899px) {
@media screen and (max-width : 599px) {
width : 100%;
height : 100%;
height : 40%;
}
`
const StyledButton = styled(Button)`
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment