Client - add spinner on loading activities
This commit is contained in:
parent
4c3fc343d5
commit
34614d5a6c
@ -48,7 +48,10 @@ export const addActivity = form => dispatch =>
|
|||||||
}
|
}
|
||||||
dispatch(setLoading(false))
|
dispatch(setLoading(false))
|
||||||
})
|
})
|
||||||
.catch(error => dispatch(setError(`activities|${error}`)))
|
.catch(error => {
|
||||||
|
dispatch(setLoading(false))
|
||||||
|
dispatch(setError(`activities|${error}`))
|
||||||
|
})
|
||||||
|
|
||||||
export const addActivityWithoutGpx = form => dispatch =>
|
export const addActivityWithoutGpx = form => dispatch =>
|
||||||
FitTrackeeGenericApi.addData('activities/no_gpx', form)
|
FitTrackeeGenericApi.addData('activities/no_gpx', form)
|
||||||
@ -150,7 +153,10 @@ export const editActivity = form => dispatch =>
|
|||||||
}
|
}
|
||||||
dispatch(setLoading(false))
|
dispatch(setLoading(false))
|
||||||
})
|
})
|
||||||
.catch(error => dispatch(setError(`activities|${error}`)))
|
.catch(error => {
|
||||||
|
dispatch(setLoading(false))
|
||||||
|
dispatch(setError(`activities|${error}`))
|
||||||
|
})
|
||||||
|
|
||||||
export const getMoreActivities = params => dispatch =>
|
export const getMoreActivities = params => dispatch =>
|
||||||
FitTrackeeGenericApi.getData('activities', params)
|
FitTrackeeGenericApi.getData('activities', params)
|
||||||
|
@ -25,7 +25,9 @@ export const setLoading = loading => ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
export const getOrUpdateData = (action, target, data) => dispatch => {
|
export const getOrUpdateData = (action, target, data) => dispatch => {
|
||||||
|
dispatch(setLoading(true))
|
||||||
if (data && data.id && isNaN(data.id)) {
|
if (data && data.id && isNaN(data.id)) {
|
||||||
|
dispatch(setLoading(false))
|
||||||
return dispatch(setError(`${target}|Incorrect id`))
|
return dispatch(setError(`${target}|Incorrect id`))
|
||||||
}
|
}
|
||||||
return FitTrackeeApi[action](target, data)
|
return FitTrackeeApi[action](target, data)
|
||||||
@ -35,8 +37,12 @@ export const getOrUpdateData = (action, target, data) => dispatch => {
|
|||||||
} else {
|
} else {
|
||||||
dispatch(setError(`${target}|${ret.message || ret.status}`))
|
dispatch(setError(`${target}|${ret.message || ret.status}`))
|
||||||
}
|
}
|
||||||
|
dispatch(setLoading(false))
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
dispatch(setLoading(false))
|
||||||
|
dispatch(setError(`${target}|${error}`))
|
||||||
})
|
})
|
||||||
.catch(error => dispatch(setError(`${target}|${error}`)))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addData = (target, data) => dispatch =>
|
export const addData = (target, data) => dispatch =>
|
||||||
|
@ -7,7 +7,7 @@ import { getDateWithTZ } from '../../utils'
|
|||||||
|
|
||||||
export default class ActivitiesList extends React.PureComponent {
|
export default class ActivitiesList extends React.PureComponent {
|
||||||
render() {
|
render() {
|
||||||
const { activities, sports, t, user } = this.props
|
const { activities, loading, sports, t, user } = this.props
|
||||||
return (
|
return (
|
||||||
<div className="card activity-card">
|
<div className="card activity-card">
|
||||||
<div className="card-body">
|
<div className="card-body">
|
||||||
@ -24,7 +24,8 @@ export default class ActivitiesList extends React.PureComponent {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{sports &&
|
{!loading &&
|
||||||
|
sports &&
|
||||||
activities.map((activity, idx) => (
|
activities.map((activity, idx) => (
|
||||||
// eslint-disable-next-line react/no-array-index-key
|
// eslint-disable-next-line react/no-array-index-key
|
||||||
<tr key={idx}>
|
<tr key={idx}>
|
||||||
@ -61,6 +62,7 @@ export default class ActivitiesList extends React.PureComponent {
|
|||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{loading && <div className="loader" />}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -38,6 +38,7 @@ class Activities extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
const {
|
const {
|
||||||
activities,
|
activities,
|
||||||
|
loading,
|
||||||
loadActivities,
|
loadActivities,
|
||||||
loadMoreActivities,
|
loadMoreActivities,
|
||||||
message,
|
message,
|
||||||
@ -71,6 +72,7 @@ class Activities extends React.Component {
|
|||||||
<div className="col-md-9 activities-result">
|
<div className="col-md-9 activities-result">
|
||||||
<ActivitiesList
|
<ActivitiesList
|
||||||
activities={activities}
|
activities={activities}
|
||||||
|
loading={loading}
|
||||||
sports={sports}
|
sports={sports}
|
||||||
t={t}
|
t={t}
|
||||||
user={user}
|
user={user}
|
||||||
@ -101,6 +103,7 @@ export default withTranslation()(
|
|||||||
connect(
|
connect(
|
||||||
state => ({
|
state => ({
|
||||||
activities: state.activities.data,
|
activities: state.activities.data,
|
||||||
|
loading: state.loading,
|
||||||
message: state.message,
|
message: state.message,
|
||||||
sports: state.sports.data,
|
sports: state.sports.data,
|
||||||
user: state.user,
|
user: state.user,
|
||||||
|
@ -349,12 +349,12 @@ label {
|
|||||||
|
|
||||||
.loader {
|
.loader {
|
||||||
animation: spin 2s linear infinite;
|
animation: spin 2s linear infinite;
|
||||||
border: 16px solid #f3f3f3;
|
border: 8px solid #f3f3f3;
|
||||||
border-top: 16px solid #3498db;
|
border-top: 8px solid #3498db;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
height: 120px;
|
height: 60px;
|
||||||
margin-left: 41%;
|
margin-left: 41%;
|
||||||
width: 120px;
|
width: 60px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@keyframes spin {
|
@keyframes spin {
|
||||||
|
Loading…
Reference in New Issue
Block a user