Repository URL to install this package:
|
Version:
1.7.2-rc.1 ▾
|
import { SettingsActionTypes as ActionTypes } from '../actions/settings';
import { ActionTypes as UserActionTypes } from '../actions';
import { initialSettingsState } from '../settingsIndex';
export const settingsReducer = (state = initialSettingsState, action) => {
switch (action.type) {
case ActionTypes.DELETE_THIRD_PARTY_SUCCESS: {
return {
...state,
deleteThirdParty: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.DELETE_THIRD_PARTY: {
return {
...state,
deleteThirdParty: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.DELETE_THIRD_PARTY_ERROR: {
return {
...state,
deleteThirdParty: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.SAVE_USER: {
return {
...state,
saveUser: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.SAVE_USER_ERROR: {
return {
...state,
saveUser: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.SAVE_USER_SUCCESS: {
return {
...state,
saveUser: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.SAVE_NEW_PASSWORD: {
return {
...state,
saveNewPassword: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.SAVE_NEW_PASSWORD_ERROR: {
return {
...state,
saveNewPassword: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.SAVE_NEW_PASSWORD_SUCCESS: {
return {
...state,
saveNewPassword: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.SAVE_NEW_EMAIL: {
return {
...state,
saveNewEmail: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.SAVE_NEW_EMAIL_ERROR: {
return {
...state,
saveNewEmail: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.SAVE_NEW_EMAIL_SUCCESS: {
return {
...state,
saveNewEmail: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.FETCH_PREMIUMS: {
return {
...state,
fetchPremiums: {
loading: true,
error: null,
},
};
}
case ActionTypes.FETCH_PREMIUMS_SUCCESS: {
return {
...state,
fetchPremiums: {
premiums: [{ id: 0, name: 'doNotUsePremium' }, ...action.premiums],
loading: false,
error: null,
},
};
}
case ActionTypes.FETCH_PREMIUMS_ERROR: {
return {
...state,
fetchPremiums: {
error: action.error,
loading: false,
},
};
}
case UserActionTypes.LOAD_BRANDING: {
return {
...state,
loadBranding: {
loading: true,
error: null,
success: false,
},
};
}
case UserActionTypes.LOAD_BRANDING_SUCCESS: {
return {
...state,
loadBranding: {
loading: false,
error: null,
success: true,
},
};
}
case UserActionTypes.LOAD_BRANDING_ERROR: {
return {
...state,
loadBranding: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.SAVE_BRANDING: {
return {
...state,
saveBranding: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.SAVE_BRANDING_SUCCESS: {
return {
...state,
saveBranding: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.SAVE_BRANDING_ERROR: {
return {
...state,
saveBranding: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.SAVE_TILE_BACKGROUND: {
return {
...state,
saveTileBackground: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.SAVE_TILE_BACKGROUND_SUCCESS: {
return {
...state,
saveTileBackground: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.SAVE_TILE_BACKGROUND_ERROR: {
return {
...state,
saveTileBackground: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.SAVE_BACKGROUND_COLOR: {
return {
...state,
saveBackgroundColor: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.SAVE_BACKGROUND_COLOR_SUCCESS: {
return {
...state,
saveBackgroundColor: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.SAVE_BACKGROUND_COLOR_ERROR: {
return {
...state,
saveBackgroundColor: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.UPLOAD_LOGO: {
return {
...state,
uploadLogo: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.UPLOAD_LOGO_SUCCESS: {
return {
...state,
uploadLogo: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.UPLOAD_LOGO_ERROR: {
return {
...state,
uploadLogo: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.REMOVE_LOGO: {
return {
...state,
removeLogo: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.REMOVE_LOGO_SUCCESS: {
return {
...state,
removeLogo: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.REMOVE_LOGO_ERROR: {
return {
...state,
removeLogo: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.UPLOAD_BACKGROUND: {
return {
...state,
uploadBackground: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.UPLOAD_BACKGROUND_SUCCESS: {
return {
...state,
uploadBackground: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.UPLOAD_BACKGROUND_ERROR: {
return {
...state,
uploadBackground: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.REMOVE_BACKGROUND: {
return {
...state,
removeBackground: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.REMOVE_BACKGROUND_SUCCESS: {
return {
...state,
removeBackground: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.REMOVE_BACKGROUND_ERROR: {
return {
...state,
removeBackground: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.DISMISS_BRANDING_NAGS: {
return {
...state,
uploadLogo: { ...initialSettingsState.uploadLogo },
removeLogo: { ...initialSettingsState.removeLogo },
uploadBackground: { ...initialSettingsState.uploadBackground },
removeBackground: { ...initialSettingsState.removeBackground },
saveBranding: { ...initialSettingsState.saveBranding },
loadBranding: { ...initialSettingsState.loadBranding },
};
}
case ActionTypes.DELETE_ACCOUNT: {
return {
...state,
deleteAccount: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.DELETE_ACCOUNT_ERROR: {
return {
...state,
deleteAccount: {
error: action.error,
loading: false,
success: false,
},
};
}
case ActionTypes.DELETE_ACCOUNT_SUCCESS: {
return {
...state,
deleteAccount: {
loading: false,
error: null,
success: true,
},
};
}
// for resetting error when opening/closing modal dialogs:
case ActionTypes.RESET_NAGS: {
return {
...initialSettingsState,
fetchPremiums: {
...initialSettingsState.premiums,
premiums: state.fetchPremiums.premiums,
},
doodleFeed: state.doodleFeed,
};
}
case ActionTypes.DELETE_CALENDAR: {
return {
...state,
deleteCalendar: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.DELETE_CALENDAR_SUCCESS: {
return {
...state,
deleteCalendar: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.DELETE_CALENDAR_ERROR: {
return {
...state,
deleteCalendar: {
loading: false,
error: action.error,
success: false,
},
};
}
case ActionTypes.GET_DOODLE_FEED: {
return {
...state,
getDoodleFeed: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.GET_DOODLE_FEED_SUCCESS: {
return {
...state,
getDoodleFeed: {
loading: false,
error: null,
success: true,
},
doodleFeed: action.feed,
};
}
case ActionTypes.GET_DOODLE_FEED_ERROR: {
return {
...state,
getDoodleFeed: {
loading: false,
error: action.error,
success: false,
},
};
}
case ActionTypes.CONNECT_DOODLE_FEED: {
return {
...state,
connectDoodleFeed: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.CONNECT_DOODLE_FEED_SUCCESS: {
return {
...state,
connectDoodleFeed: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.CONNECT_DOODLE_FEED_ERROR: {
return {
...state,
connectDoodleFeed: {
loading: false,
error: action.error,
success: false,
},
};
}
case ActionTypes.RESET_DOODLE_FEED: {
return {
...state,
resetDoodleFeed: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.RESET_DOODLE_FEED_SUCCESS: {
return {
...state,
resetDoodleFeed: {
loading: false,
error: null,
success: true,
},
doodleFeed: action.feed,
};
}
case ActionTypes.RESET_DOODLE_FEED_ERROR: {
return {
...state,
resetDoodleFeed: {
loading: false,
error: action.error,
success: false,
},
};
}
case ActionTypes.DELETE_ADDRESS_BOOK: {
return {
...state,
deleteAddressBook: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.DELETE_ADDRESS_BOOK_SUCCESS: {
return {
...state,
deleteAddressBook: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.DELETE_ADDRESS_BOOK_ERROR: {
return {
...state,
deleteAddressBook: {
loading: false,
error: action.error,
success: false,
},
};
}
case ActionTypes.LOGOUT_APPS: {
return {
...state,
logoutApps: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.LOGOUT_APPS_SUCCESS: {
return {
...state,
logoutApps: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.LOGOUT_APPS_ERROR: {
return {
...state,
logoutApps: {
loading: false,
error: action.error,
success: false,
},
};
}
case ActionTypes.GET_APPS: {
return {
...state,
getApps: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.GET_APPS_SUCCESS: {
return {
...state,
getApps: {
loading: false,
error: null,
success: true,
},
apps: action.apps,
};
}
case ActionTypes.GET_APPS_ERROR: {
return {
...state,
getApps: {
loading: false,
error: action.error,
success: false,
},
};
}
case ActionTypes.SAVE_AVATAR: {
return {
...state,
saveAvatar: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.SAVE_AVATAR_SUCCESS: {
return {
...state,
saveAvatar: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.SAVE_AVATAR_ERROR: {
return {
...state,
saveAvatar: {
loading: false,
error: action.error,
success: false,
},
};
}
case ActionTypes.DELETE_AVATAR: {
return {
...state,
deleteAvatar: {
loading: true,
error: null,
success: false,
},
};
}
case ActionTypes.DELETE_AVATAR_SUCCESS: {
return {
...state,
deleteAvatar: {
loading: false,
error: null,
success: true,
},
};
}
case ActionTypes.DELETE_AVATAR_ERROR: {
return {
...state,
deleteAvatar: {
loading: false,
error: action.error,
success: false,
},
};
}
case ActionTypes.DISMISS_NOTIFICATIONS_NAGS:
case ActionTypes.DISMISS_PREMIUM_NAGS:
case ActionTypes.DISMISS_CALENDARS_NAGS: {
return {
...state,
saveUser: { ...initialSettingsState.saveUser },
};
}
default:
return state;
}
};
export const createSettingsReducer = (options = {}) => ({
[options.domain || 'userSettings']: settingsReducer,
});