Skip to content

Commit b3f2b28

Browse files
committed
add clearProfile action annd reducer for clear all profile info
add clearProfile action annd reducer for clear all profile info for fix topcoder-platform/community-app#1192
1 parent c01cc83 commit b3f2b28

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

__tests__/__snapshots__/index.js.snap

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Object {
8686
"addSkillInit": [Function],
8787
"addWebLinkDone": [Function],
8888
"addWebLinkInit": [Function],
89+
"clearProfile": [Function],
8990
"deletePhotoDone": [Function],
9091
"deletePhotoInit": [Function],
9192
"deleteWebLinkDone": [Function],

__tests__/actions/__snapshots__/profile.js.snap

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Object {
77
"addSkillInit": [Function],
88
"addWebLinkDone": [Function],
99
"addWebLinkInit": [Function],
10+
"clearProfile": [Function],
1011
"deletePhotoDone": [Function],
1112
"deletePhotoInit": [Function],
1213
"deleteWebLinkDone": [Function],

docs/actions.profile.md

+12
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Actions for interactions with profile details API.
1111

1212
* [actions.profile](#module_actions.profile)
1313
* [.loadProfile(handle)](#module_actions.profile.loadProfile) ⇒ <code>Action</code>
14+
* [.clearProfile()](#module_actions.profile.clearProfile) ⇒ <code>Action</code>
1415
* [.getAchievementsInit()](#module_actions.profile.getAchievementsInit) ⇒ <code>Action</code>
1516
* [.getAchievementsDone(handle)](#module_actions.profile.getAchievementsDone) ⇒ <code>Action</code>
1617
* [.getExternalAccountsInit()](#module_actions.profile.getExternalAccountsInit) ⇒ <code>Action</code>
@@ -67,6 +68,17 @@ Creates and action that loads user profile.
6768
| --- | --- | --- |
6869
| handle | <code>String</code> | User handle. |
6970

71+
<a name="module_actions.profile.clearProfile"></a>
72+
73+
### actions.profile.clearProfile() ⇒ <code>Action</code>
74+
Creates and action that clear user profile.
75+
76+
**Kind**: static method of [<code>actions.profile</code>](#module_actions.profile)
77+
**Todo**
78+
79+
- [ ] This action does not follow the pattern with init/done pairs of
80+
actions. Should be improved.
81+
7082
<a name="module_actions.profile.getAchievementsInit"></a>
7183

7284
### actions.profile.getAchievementsInit() ⇒ <code>Action</code>

src/actions/profile.js

+9
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ function loadProfile(handle) {
2121
return handle;
2222
}
2323

24+
/**
25+
* @static
26+
* @desc Creates and action that clear user profile.
27+
* @todo This action does not follow the pattern with init/done pairs of
28+
* actions. Should be improved.
29+
*/
30+
function clearProfile() {}
31+
2432
/**
2533
* @static
2634
* @desc Creates an action that signals beginning of user achievements loading.
@@ -415,6 +423,7 @@ function updatePasswordDone(profile, tokenV3, newPassword, oldPassword) {
415423
export default createActions({
416424
PROFILE: {
417425
LOAD_PROFILE: loadProfile,
426+
CLEAR_PROFILE: clearProfile,
418427
GET_ACHIEVEMENTS_INIT: getAchievementsInit,
419428
GET_ACHIEVEMENTS_DONE: getAchievementsDone,
420429
GET_EXTERNAL_ACCOUNTS_INIT: getExternalAccountsInit,

src/reducers/profile.js

+3
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,9 @@ function onUpdatePasswordDone(state, { payload, error }) {
432432
function create(initialState) {
433433
const a = actions.profile;
434434
return handleActions({
435+
[a.clearProfile]: state => ({
436+
...state, achievements: null, country: '', info: null, skills: null, stats: null,
437+
}),
435438
[a.loadProfile]: (state, action) => ({ ...state, profileForHandle: action.payload }),
436439
[a.getAchievementsInit]: state => state,
437440
[a.getAchievementsDone]: onGetAchievementsDone,

0 commit comments

Comments
 (0)