Skip to content

Commit d3e1024

Browse files
vacodoceojfcampos1
authored andcommitted
fix: remove unnecesary loadings and fix loading display (#42)
* fix: remove unnecesary loadings and fix loading display * fix: remove last slash in baseURL
1 parent ac83d3c commit d3e1024

10 files changed

Lines changed: 73 additions & 20 deletions

File tree

src/components/Loading/Loading.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import React from 'react'
2+
import CircularProgress from '@material-ui/core/CircularProgress'
3+
import Container from '@material-ui/core/Container'
4+
import Grid from '@material-ui/core/Grid'
5+
import { makeStyles } from '@material-ui/core/styles'
6+
import { fade } from '@material-ui/core/styles/colorManipulator'
7+
8+
const useStyles = makeStyles({
9+
container: {
10+
height: 'calc(100vh - 3px)',
11+
padding: 0,
12+
},
13+
dim: {
14+
left: 0,
15+
width: '100%',
16+
height: '102%',
17+
position: 'fixed',
18+
backgroundColor: fade('#ffffff', 0.5),
19+
zIndex: 10001,
20+
top: 56,
21+
},
22+
circularProgress: {
23+
position: 'relative',
24+
top: -28,
25+
},
26+
})
27+
28+
const Loading = () => {
29+
const classes = useStyles()
30+
return (
31+
<Container className={classes.dim}>
32+
<Grid
33+
container
34+
direction="column"
35+
justify="center"
36+
alignItems="center"
37+
align="center"
38+
className={classes.container}
39+
>
40+
<Grid item>
41+
<CircularProgress className={classes.circularProgress} />
42+
</Grid>
43+
</Grid>
44+
</Container>
45+
)
46+
}
47+
48+
export default Loading

src/redux/store.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import currentTripReducer from './reducers/currentTrip'
3030
import { currentTripModel } from './models/currentTrip'
3131

3232
export const client = axios.create({
33-
baseURL: 'https://playground-api.salgode.com',
33+
baseURL: 'https://api.salgode.com',
3434
responseType: 'json',
3535
requestType: 'json',
3636
})

src/screens/FindTrip/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { connect } from 'react-redux'
33
import PropTypes from 'prop-types'
44

55
import { Container } from '@material-ui/core'
6-
import { CircularProgress } from '@material-ui/core'
6+
import Loading from '../../components/Loading/Loading'
77
import Select, { components } from 'react-select'
88
import { withStyles } from '@material-ui/core/styles'
99
import { FindTripsCard } from './../../components/MyTripsCard/index'
@@ -128,7 +128,7 @@ class FindTripScreen extends Component {
128128
}}
129129
/>
130130
{loading ? (
131-
<CircularProgress />
131+
<Loading />
132132
) : (
133133
<div>
134134
{trips.map((trip, i) => (

src/screens/MyTripDetails/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { TripDetailsCard } from '../../components/MyTripsCard/index'
1111
import { TripManifestCard } from '../../components/MyTripsCard/index'
1212

1313
// Components
14-
import { CircularProgress } from '@material-ui/core'
14+
import Loading from '../../components/Loading/Loading'
1515
import Divider from '@material-ui/core/Divider'
1616
import Grid from '@material-ui/core/Grid'
1717
import Typography from '@material-ui/core/Typography'
@@ -92,7 +92,7 @@ class MyTripDetails extends Component {
9292
'Hubo un problema obteniendo el detalle del viaje. Por favor intentalo de nuevo.'
9393
)
9494
}
95-
this.setState({ manifest: reserve.payload.data })
95+
this.setState({ manifest: reserve.payload.data, loading: false })
9696
}
9797

9898
renderDetails() {
@@ -131,7 +131,7 @@ class MyTripDetails extends Component {
131131

132132
render() {
133133
const { loading, reservations } = this.state
134-
if (loading) return <CircularProgress />
134+
if (loading) return <Loading />
135135
return (
136136
<div>
137137
{this.renderDetails()}

src/screens/MyTrips/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import './style.sass'
88
import { MyTripsCard } from '../../components/MyTripsCard/index'
99

1010
// Components
11-
import { CircularProgress } from '@material-ui/core'
11+
import Loading from '../../components/Loading/Loading'
1212
import Grid from '@material-ui/core/Grid'
1313

1414
class MyTrips extends Component {
@@ -45,7 +45,7 @@ class MyTrips extends Component {
4545
const { loading, trips } = this.state
4646
return (
4747
<div>
48-
{loading && <CircularProgress />}
48+
{loading && <Loading />}
4949
<Grid container spacing={2} justify="center" alignItems="center">
5050
{trips.map((trip, i) => {
5151
return (

src/screens/PassengerTrips/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types'
55
import { getPassengerTripsAction } from '../../redux/actions/passengerTrips'
66
import PassengerTripCard from '../../components/PassengerTrips/index'
77

8-
import { CircularProgress } from '@material-ui/core'
8+
import Loading from '../../components/Loading/Loading'
99
import Grid from '@material-ui/core/Grid'
1010

1111
class PassengerTrips extends Component {
@@ -39,7 +39,7 @@ class PassengerTrips extends Component {
3939
render() {
4040
const { loading, trips } = this.state
4141
if (loading) {
42-
return <div>{loading && <CircularProgress />}</div>
42+
return <div>{loading && <Loading />}</div>
4343
}
4444
return (
4545
<div>

src/screens/RequestedTrip/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { fetchRequestedTrips } from '../../redux/actions/requestedTrip'
77
import { RequestedTripCard } from '../../components/MyTripsCard/index'
88

99
// Components
10-
import { CircularProgress } from '@material-ui/core'
10+
import Loading from '../../components/Loading/Loading'
1111
import Grid from '@material-ui/core/Grid'
1212

1313
class RequestedTrip extends Component {
@@ -44,7 +44,7 @@ class RequestedTrip extends Component {
4444
const { loading, trips } = this.state
4545
return (
4646
<div>
47-
{loading && <CircularProgress />}
47+
{loading && <Loading />}
4848
<Grid container spacing={2} justify="center" alignItems="center">
4949
{trips.map((trip, i) => {
5050
return (

src/screens/SignIn/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { setObject, USER_DATA, TOKEN } from '../../utils/storeData'
1010

1111
// Components
1212
import { SignInForm } from '../../components/index'
13-
import { CircularProgress } from '@material-ui/core'
13+
import Loading from '../../components/Loading/Loading'
1414

1515
const MESSAGE =
1616
'Hubo un problema iniciando sesión. Por favor intentalo de nuevo.'
@@ -33,7 +33,10 @@ class SignInScreen extends React.Component {
3333

3434
const user = await signIn(payload)
3535

36-
if (user.error || !user.payload.data.email) return alert(MESSAGE)
36+
if (user.error || !user.payload.data.email) {
37+
this.setState({ loading: false })
38+
return alert(MESSAGE)
39+
}
3740

3841
this.setState({ loading: false })
3942
setObject(USER_DATA, user.payload.data)
@@ -47,7 +50,7 @@ class SignInScreen extends React.Component {
4750
<div className="sign-in">
4851
<SignInForm onSubmit={this.onSubmit} />
4952

50-
{loading && <CircularProgress />}
53+
{loading && <Loading />}
5154
</div>
5255
)
5356
}

src/screens/SignUp/index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { signupUser } from '../../redux/actions/user'
1010

1111
// Components
1212
import { SignUpForm } from '../../components/index'
13-
import { CircularProgress } from '@material-ui/core'
13+
import Loading from '../../components/Loading/Loading'
1414

1515
const MESSAGE = 'Hubo un problema registrandote. Por favor intentalo de nuevo.'
1616

@@ -34,8 +34,10 @@ class SignUpScreen extends React.Component {
3434

3535
this.setState({ loading: false })
3636

37-
if (user.error || !user.payload.data.email || !user.payload.data.user_id)
37+
if (user.error || !user.payload.data.email || !user.payload.data.user_id) {
38+
this.setState({ loading: false })
3839
return alert(MESSAGE)
40+
}
3941

4042
setObject(USER_DATA, user.payload.data)
4143
setObject(TOKEN, user.payload.data.token)
@@ -49,7 +51,7 @@ class SignUpScreen extends React.Component {
4951
<div className="sign-up">
5052
<SignUpForm onSubmit={this.onSubmit} />
5153

52-
{loading && <CircularProgress />}
54+
{loading && <Loading />}
5355
</div>
5456
)
5557
}

src/screens/UpdateUser/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState, useEffect } from 'react'
22
import UpdateUserForm from '../../components/User/UpdateForm'
3-
import { CircularProgress } from '@material-ui/core'
3+
import Loading from '../../components/Loading/Loading'
44
import { getObject, USER_DATA } from '../../utils/storeData'
55

66
const UpdateUser = () => {
@@ -21,7 +21,7 @@ const UpdateUser = () => {
2121
setIsLoading(false)
2222
}, [])
2323

24-
if (isLoading) return <CircularProgress />
24+
if (isLoading) return <Loading />
2525

2626
return (
2727
<div className="columns has-margin-top-40">

0 commit comments

Comments
 (0)