Client - minor refactor

This commit is contained in:
Sam 2019-08-28 15:51:04 +02:00
parent 2a52b9081d
commit 8000018cf4
3 changed files with 23 additions and 33 deletions

View File

@ -28,7 +28,7 @@ export default function ActivityCard(props) {
<img <img
alt="Map" alt="Map"
src={ src={
`${apiUrl}activities/map/${activity.map}` + `?${Date.now()}` `${apiUrl}activities/map/${activity.map}?${Date.now()}`
} }
className="img-fluid" className="img-fluid"
/> />

View File

@ -115,7 +115,7 @@ class NavBar extends React.PureComponent {
{picture === true && ( {picture === true && (
<img <img
alt="Avatar" alt="Avatar"
src={`${apiUrl}users/${id}/picture` + `?${Date.now()}`} src={`${apiUrl}users/${id}/picture?${Date.now()}`}
className="img-fluid App-nav-profile-img" className="img-fluid App-nav-profile-img"
/> />
)} )}

View File

@ -7,15 +7,13 @@ const handleDataAndError = (state, type, action) => {
if (action.target !== type) { if (action.target !== type) {
return state return state
} }
switch (action.type) { if (action.type === 'SET_DATA') {
case 'SET_DATA': return {
return { ...state,
...state, data: action.data[action.target],
data: action.data[action.target], }
}
default:
return state
} }
return state
} }
const activities = (state = initial.activities, action) => { const activities = (state = initial.activities, action) => {
@ -36,42 +34,34 @@ const activities = (state = initial.activities, action) => {
} }
const calendarActivities = (state = initial.calendarActivities, action) => { const calendarActivities = (state = initial.calendarActivities, action) => {
switch (action.type) { if (action.type === 'UPDATE_CALENDAR') {
case 'UPDATE_CALENDAR': return {
return { ...state,
...state, data: action.activities,
data: action.activities, }
}
default:
return handleDataAndError(state, 'calendarActivities', action)
} }
return handleDataAndError(state, 'calendarActivities', action)
} }
const chartData = (state = initial.chartData, action) => { const chartData = (state = initial.chartData, action) => {
switch (action.type) { if (action.type === 'SET_CHART_DATA') {
case 'SET_CHART_DATA': return action.chartData
return action.chartData
default:
return state
} }
return state
} }
const gpx = (state = initial.gpx, action) => { const gpx = (state = initial.gpx, action) => {
switch (action.type) { if (action.type === 'SET_GPX') {
case 'SET_GPX': return action.gpxContent
return action.gpxContent
default:
return state
} }
return state
} }
const loading = (state = initial.loading, action) => { const loading = (state = initial.loading, action) => {
switch (action.type) { if (action.type === 'SET_LOADING') {
case 'SET_LOADING': return action.loading
return action.loading
default:
return state
} }
return state
} }
const message = (state = initial.message, action) => { const message = (state = initial.message, action) => {