Skip to content

Commit

Permalink
fix(client): added rootUserProfileDetail reducer & action type
Browse files Browse the repository at this point in the history
fixing #109
  • Loading branch information
roman-ojha committed Jun 24, 2022
1 parent 9261074 commit 2791482
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 18 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,19 @@ const RoutingProfilePage = (props) => {
if (location.pathname.includes("/u/profile")) {
const selectedLinkElement = document.getElementsByClassName(
"MainPage_SideBar_Link"
)[4];
selectedLinkElement.firstElementChild.style.backgroundColor =
"var(--primary-color-point-7)";
document.getElementsByClassName(
"MainPage_SideBar_Menu_Logo"
)[4].style.color = "var(--primary-color-point-7)";
selectedLinkElement.firstElementChild.nextElementSibling.nextElementSibling.style.color =
"var(--primary-color-point-7)";
)[4] as HTMLElement;
(
selectedLinkElement.firstElementChild! as HTMLElement
).style.backgroundColor = "var(--primary-color-point-7)";
(
document.getElementsByClassName(
"MainPage_SideBar_Menu_Logo"
)[4] as HTMLElement
).style.color = "var(--primary-color-point-7)";
(
selectedLinkElement.firstElementChild!.nextElementSibling!
.nextElementSibling! as HTMLElement
).style.color = "var(--primary-color-point-7)";
}
} catch (err) {}
};
Expand All @@ -33,13 +38,18 @@ const RoutingProfilePage = (props) => {
const selectedLinkElement = document.getElementsByClassName(
"MainPage_SideBar_Link"
)[4];
selectedLinkElement.firstElementChild.style.backgroundColor =
"transparent";
document.getElementsByClassName(
"MainPage_SideBar_Menu_Logo"
)[4].style.color = "var(--lower-opacity-font-color)";
selectedLinkElement.firstElementChild.nextElementSibling.nextElementSibling.style.color =
"var(--lower-opacity-font-color)";
(
selectedLinkElement.firstElementChild! as HTMLElement
).style.backgroundColor = "transparent";
(
document.getElementsByClassName(
"MainPage_SideBar_Menu_Logo"
)[4] as HTMLElement
).style.color = "var(--lower-opacity-font-color)";
(
selectedLinkElement.firstElementChild!.nextElementSibling!
.nextElementSibling! as HTMLElement
).style.color = "var(--lower-opacity-font-color)";
}
} catch (err) {}
};
Expand Down
2 changes: 1 addition & 1 deletion client/src/routes/RoutingUserPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const RoutingUserPage = () => {
<Route exact path="/u/message" component={Message} />
<Route exact path="/u/setting" component={Setting} />
<Route path="/u/profile/:userID" component={Profile} />
<Route exact page="/u/stories" component={Stories} />
<Route exact path="/u/stories" component={Stories} />
<Route
path="*"
component={() => {
Expand Down
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;
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;
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",
}
10 changes: 8 additions & 2 deletions client/src/services/redux-reducer/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { combineReducers } from "redux";
// Javascript
import setUserProfileDetailReducer from "./global/UserProfileDetailReducer";
import changeMainPageMessageView from "./components/messageBox/mainPageMessageOnOff";
import setUserPostResponseData from "./page/home/UserPostResponseData";
import homePageUserPostFieldDataReducer from "./page/home/homePageUserPostFieldData";
import setUserProfileDetailReducer from "./global/UserProfileDetailReducer";
import setUserProfilePostReducer from "./page/profile/UserProfilePostReducer";
import profilePageDataReducer from "./page/profile/profilePageDataReducer";
import setFollowedUserPostDataReducer from "./page/home/FollowedUserPostDataReducer";
Expand All @@ -25,12 +26,15 @@ import videoPageDataReducer from "./page/video";
import rootUserFriends from "./global/rootUserFriends";
import rootUserProfileDataState from "./page/profile/rootUserProfileDataState";
import displayEmojiPicker from "./page/home/displayEmojiPicker";
// Typescript
import userProfileDetailReducer from "./global/rootUserProfileDetail/reducer";

const rootReducers = combineReducers({
// Javascript
setUserProfileDetailReducer,
changeMainPageMessageView,
setUserPostResponseData,
homePageUserPostFieldDataReducer,
setUserProfileDetailReducer,
setUserProfilePostReducer,
profilePageDataReducer,
setFollowedUserPostDataReducer,
Expand All @@ -53,6 +57,8 @@ const rootReducers = combineReducers({
rootUserFriends,
rootUserProfileDataState,
displayEmojiPicker,
// Typescript
userProfileDetailReducer,
});

export default rootReducers;

0 comments on commit 2791482

Please sign in to comment.