-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(client): added rootUserProfileDetail reducer & action type
fixing #109
- Loading branch information
1 parent
9261074
commit 2791482
Showing
7 changed files
with
126 additions
and
18 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
client/src/services/redux-reducer/global/rootUserProfileDetail/action.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { RootUserProfileDetailActionTypes } from "./types"; | ||
|
||
export interface SetRootUserProfileDetailAction { | ||
type: RootUserProfileDetailActionTypes.SET_ROOT_USER_PROFILE_DETAIL; | ||
payload: any; | ||
} | ||
|
||
export interface ChangeRootUserProfilePicture { | ||
type: RootUserProfileDetailActionTypes.CHANGE_ROOT_USER_PROFILE_PICTURE; | ||
payload: any; | ||
} | ||
|
||
export interface ChangeRootUserUserID { | ||
type: RootUserProfileDetailActionTypes.CHANGE_ROOT_USER_USER_ID; | ||
payload: any; | ||
} | ||
|
||
export interface ChangeRootUserName { | ||
type: RootUserProfileDetailActionTypes.CHANGE_ROOT_USERNAME; | ||
payload: any; | ||
} | ||
|
||
export interface setRootUserPostData { | ||
type: RootUserProfileDetailActionTypes.CHANGE_ROOT_USER_POST_DATA; | ||
payload: any; | ||
} | ||
|
||
export type RootUserProfileDetailAction = | ||
| SetRootUserProfileDetailAction | ||
| ChangeRootUserProfilePicture | ||
| ChangeRootUserUserID | ||
| ChangeRootUserName | ||
| setRootUserPostData; |
48 changes: 48 additions & 0 deletions
48
client/src/services/redux-reducer/global/rootUserProfileDetail/reducer.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { | ||
RootUserProfileDetailState, | ||
RootUserProfileDetailActionTypes, | ||
} from "./types"; | ||
import { RootUserProfileDetailAction } from "./action"; | ||
|
||
const initialState = { | ||
fetchedPostData: false, | ||
}; | ||
// this store the detail of Root User | ||
|
||
const rootUserProfileDetailReducer = ( | ||
state: RootUserProfileDetailState = initialState, | ||
action: RootUserProfileDetailAction | ||
) => { | ||
switch (action.type) { | ||
case RootUserProfileDetailActionTypes.SET_ROOT_USER_PROFILE_DETAIL: | ||
return { | ||
...state, | ||
...action.payload, | ||
}; | ||
case RootUserProfileDetailActionTypes.CHANGE_ROOT_USER_PROFILE_PICTURE: | ||
return { | ||
...state, | ||
picture: action.payload, | ||
}; | ||
case RootUserProfileDetailActionTypes.CHANGE_ROOT_USER_USER_ID: | ||
return { | ||
...state, | ||
userID: action.payload, | ||
}; | ||
case RootUserProfileDetailActionTypes.CHANGE_ROOT_USERNAME: | ||
return { | ||
...state, | ||
name: action.payload, | ||
}; | ||
case RootUserProfileDetailActionTypes.CHANGE_ROOT_USER_POST_DATA: | ||
return { | ||
...state, | ||
fetchedPostData: action.payload.fetchedPostData, | ||
posts: action.payload.posts, | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default rootUserProfileDetailReducer; |
11 changes: 11 additions & 0 deletions
11
client/src/services/redux-reducer/global/rootUserProfileDetail/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export interface RootUserProfileDetailState { | ||
fetchedPostData: boolean; | ||
} | ||
|
||
export enum RootUserProfileDetailActionTypes { | ||
SET_ROOT_USER_PROFILE_DETAIL = "setRootUserProfileDetail", | ||
CHANGE_ROOT_USER_PROFILE_PICTURE = "changeRootUserProfilePicture", | ||
CHANGE_ROOT_USER_USER_ID = "changeRootUserUserID", | ||
CHANGE_ROOT_USERNAME = "changeRootUserName", | ||
CHANGE_ROOT_USER_POST_DATA = "setRootUserPostData", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters