Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
12 changed files
with
239 additions
and
2 deletions.
There are no files selected for viewing
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
48 changes: 48 additions & 0 deletions
48
client/src/services/redux/pages/profile/profilePageData/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,48 @@ | ||
import { | ||
ProfilePageAction, | ||
ProfilePageDataActionTypes, | ||
ProfilePageDataState, | ||
} from "./types"; | ||
import { Dispatch } from "react"; | ||
|
||
export const profilePageDataAction = (data: ProfilePageDataState) => { | ||
return (dispatch: Dispatch<ProfilePageAction>) => { | ||
dispatch({ | ||
type: ProfilePageDataActionTypes.PROFILE_PAGE_DATA_ACTION, | ||
payload: data, | ||
}); | ||
}; | ||
}; | ||
|
||
export const setProfilePageFriends = ( | ||
data: ProfilePageDataState["friends"] | ||
) => { | ||
return (dispatch: Dispatch<ProfilePageAction>) => { | ||
dispatch({ | ||
type: ProfilePageDataActionTypes.SET_PROFILE_PAGE_FRIENDS, | ||
payload: data, | ||
}); | ||
}; | ||
}; | ||
|
||
export const setProfilePageFollowers = ( | ||
data: ProfilePageDataState["followers"] | ||
) => { | ||
return (dispatch: Dispatch<ProfilePageAction>) => { | ||
dispatch({ | ||
type: ProfilePageDataActionTypes.SET_PROFILE_PAGE_FOLLOWERS, | ||
payload: data, | ||
}); | ||
}; | ||
}; | ||
|
||
export const setProfilePageFollowings = ( | ||
data: ProfilePageDataState["followings"] | ||
) => { | ||
return (dispatch: Dispatch<ProfilePageAction>) => { | ||
dispatch({ | ||
type: ProfilePageDataActionTypes.SET_PROFILE_PAGE_FOLLOWINGS, | ||
payload: data, | ||
}); | ||
}; | ||
}; |
42 changes: 42 additions & 0 deletions
42
client/src/services/redux/pages/profile/profilePageData/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,42 @@ | ||
import { | ||
ProfilePageAction, | ||
ProfilePageDataActionTypes, | ||
ProfilePageDataState, | ||
} from "./types"; | ||
|
||
const initialState: ProfilePageDataState = { | ||
userID: "", | ||
post: [], | ||
friends: [], | ||
followings: [], | ||
followers: [], | ||
}; | ||
|
||
const profilePageDataReducer = ( | ||
state: ProfilePageDataState = initialState, | ||
action: ProfilePageAction | ||
) => { | ||
switch (action.type) { | ||
case ProfilePageDataActionTypes.PROFILE_PAGE_DATA_ACTION: | ||
return action.payload; | ||
case ProfilePageDataActionTypes.SET_PROFILE_PAGE_FRIENDS: | ||
return { | ||
...state, | ||
friends: action.payload, | ||
}; | ||
case ProfilePageDataActionTypes.SET_PROFILE_PAGE_FOLLOWERS: | ||
return { | ||
...state, | ||
followers: action.payload, | ||
}; | ||
case ProfilePageDataActionTypes.SET_PROFILE_PAGE_FOLLOWINGS: | ||
return { | ||
...state, | ||
followings: action.payload, | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default profilePageDataReducer; |
39 changes: 39 additions & 0 deletions
39
client/src/services/redux/pages/profile/profilePageData/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,39 @@ | ||
export interface ProfilePageDataState { | ||
userID: string; | ||
post: []; | ||
friends: []; | ||
followings: []; | ||
followers: []; | ||
} | ||
|
||
export enum ProfilePageDataActionTypes { | ||
PROFILE_PAGE_DATA_ACTION = "profilePageDataAction", | ||
SET_PROFILE_PAGE_FRIENDS = "setProfilePageFriends", | ||
SET_PROFILE_PAGE_FOLLOWERS = "setProfilePageFollowers", | ||
SET_PROFILE_PAGE_FOLLOWINGS = "setProfilePageFollowings", | ||
} | ||
export interface ProfilePageDataAction { | ||
type: ProfilePageDataActionTypes.PROFILE_PAGE_DATA_ACTION; | ||
payload: any; | ||
} | ||
|
||
export interface SetProfilePageFriendsAction { | ||
type: ProfilePageDataActionTypes.SET_PROFILE_PAGE_FRIENDS; | ||
payload: any; | ||
} | ||
|
||
export interface SetProfilePageFollowersAction { | ||
type: ProfilePageDataActionTypes.SET_PROFILE_PAGE_FOLLOWERS; | ||
payload: any; | ||
} | ||
|
||
export interface SetProfilePageFollowingAction { | ||
type: ProfilePageDataActionTypes.SET_PROFILE_PAGE_FOLLOWINGS; | ||
payload: any; | ||
} | ||
|
||
export type ProfilePageAction = | ||
| ProfilePageDataAction | ||
| SetProfilePageFollowersAction | ||
| SetProfilePageFriendsAction | ||
| SetProfilePageFollowingAction; |
15 changes: 15 additions & 0 deletions
15
client/src/services/redux/pages/profile/rootUserProfileData/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,15 @@ | ||
import { | ||
RootUserProfileDataAction, | ||
RootUserProfileDataActionTypes, | ||
RootUserProfileDataState, | ||
} from "./types"; | ||
import { Dispatch } from "react"; | ||
|
||
export const setRootUserProfileDataState = (data: RootUserProfileDataState) => { | ||
return (dispatch: Dispatch<RootUserProfileDataAction>) => { | ||
dispatch({ | ||
type: RootUserProfileDataActionTypes.SET_ROOT_USER_PROFILE_DATA_STATE, | ||
payload: data, | ||
}); | ||
}; | ||
}; |
24 changes: 24 additions & 0 deletions
24
client/src/services/redux/pages/profile/rootUserProfileData/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,24 @@ | ||
import { | ||
RootUserProfileDataAction, | ||
RootUserProfileDataActionTypes, | ||
RootUserProfileDataState, | ||
} from "./types"; | ||
|
||
const initialState: RootUserProfileDataState = { | ||
fetchedRootUserProfileData: false, | ||
getRootUserProfileData: false, | ||
}; | ||
|
||
const rootUserProfileDataState = ( | ||
state: RootUserProfileDataState = initialState, | ||
action: RootUserProfileDataAction | ||
) => { | ||
switch (action.type) { | ||
case RootUserProfileDataActionTypes.SET_ROOT_USER_PROFILE_DATA_STATE: | ||
return action.payload; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default rootUserProfileDataState; |
14 changes: 14 additions & 0 deletions
14
client/src/services/redux/pages/profile/rootUserProfileData/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,14 @@ | ||
export interface RootUserProfileDataState { | ||
fetchedRootUserProfileData: boolean; | ||
getRootUserProfileData: boolean; | ||
} | ||
|
||
export enum RootUserProfileDataActionTypes { | ||
SET_ROOT_USER_PROFILE_DATA_STATE = "setRootUserProfileDataState", | ||
} | ||
export interface SetRootUserProfileDataState { | ||
type: RootUserProfileDataActionTypes.SET_ROOT_USER_PROFILE_DATA_STATE; | ||
payload: RootUserProfileDataState; | ||
} | ||
|
||
export type RootUserProfileDataAction = SetRootUserProfileDataState; |
15 changes: 15 additions & 0 deletions
15
client/src/services/redux/pages/profile/userProfilePost/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,15 @@ | ||
import { | ||
UserProfilePostActionTypes, | ||
UserProfilePostState, | ||
UserProfilePostAction, | ||
} from "./types"; | ||
import { Dispatch } from "react"; | ||
|
||
export const userProfilePost = (data: UserProfilePostState) => { | ||
return (dispatch: Dispatch<UserProfilePostAction>) => { | ||
dispatch({ | ||
type: UserProfilePostActionTypes.SET_USER_PROFILE_POST, | ||
payload: data, | ||
}); | ||
}; | ||
}; |
21 changes: 21 additions & 0 deletions
21
client/src/services/redux/pages/profile/userProfilePost/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,21 @@ | ||
import { | ||
UserProfilePostAction, | ||
UserProfilePostActionTypes, | ||
UserProfilePostState, | ||
} from "./types"; | ||
|
||
const initialState: UserProfilePostState = []; | ||
// this store the user Post data | ||
const setUserProfilePostReducer = ( | ||
state: UserProfilePostState = initialState, | ||
action: UserProfilePostAction | ||
) => { | ||
switch (action.type) { | ||
case UserProfilePostActionTypes.SET_USER_PROFILE_POST: | ||
return action.payload; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default setUserProfilePostReducer; |
12 changes: 12 additions & 0 deletions
12
client/src/services/redux/pages/profile/userProfilePost/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,12 @@ | ||
export interface UserProfilePostState {} | ||
|
||
export enum UserProfilePostActionTypes { | ||
SET_USER_PROFILE_POST = "userProfilePost", | ||
} | ||
|
||
export interface SetUserProfilePostAction { | ||
type: UserProfilePostActionTypes.SET_USER_PROFILE_POST; | ||
payload: UserProfilePostState; | ||
} | ||
|
||
export type UserProfilePostAction = SetUserProfilePostAction; |
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