Client - empty user data on logout

This commit is contained in:
Sam 2020-01-31 10:26:52 +01:00
parent 694248ecac
commit 4c3fc343d5

View File

@ -18,6 +18,8 @@ const handleDataAndError = (state, type, action) => {
const activities = (state = initial.activities, action) => { const activities = (state = initial.activities, action) => {
switch (action.type) { switch (action.type) {
case 'LOGOUT':
return initial.activities
case 'PUSH_ACTIVITIES': case 'PUSH_ACTIVITIES':
return { return {
...state, ...state,
@ -34,13 +36,17 @@ const activities = (state = initial.activities, action) => {
} }
const calendarActivities = (state = initial.calendarActivities, action) => { const calendarActivities = (state = initial.calendarActivities, action) => {
if (action.type === 'UPDATE_CALENDAR') { switch (action.type) {
case 'LOGOUT':
return initial.calendarActivities
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) => {
@ -102,8 +108,12 @@ const messages = (state = initial.messages, action) => {
} }
} }
const records = (state = initial.records, action) => const records = (state = initial.records, action) => {
handleDataAndError(state, 'records', action) if (action.type === 'LOGOUT') {
return initial.records
}
return handleDataAndError(state, 'records', action)
}
const sports = (state = initial.sports, action) => const sports = (state = initial.sports, action) =>
handleDataAndError(state, 'sports', action) handleDataAndError(state, 'sports', action)
@ -122,8 +132,12 @@ const user = (state = initial.user, action) => {
} }
} }
const statistics = (state = initial.statistics, action) => const statistics = (state = initial.statistics, action) => {
handleDataAndError(state, 'statistics', action) if (action.type === 'LOGOUT') {
return initial.statistics
}
return handleDataAndError(state, 'statistics', action)
}
export default history => export default history =>
combineReducers({ combineReducers({