Skip to content

Commit 2683d5a

Browse files
idk
1 parent 9f56dca commit 2683d5a

File tree

5 files changed

+48
-33
lines changed

5 files changed

+48
-33
lines changed

client/src/App.js

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { Flex } from "@chakra-ui/react";
22
import React, { useEffect } from "react";
33
// Redux
4-
import { Provider } from "react-redux";
4+
import { connect } from "react-redux";
55
// Router
66
import { BrowserRouter as Router, Switch } from "react-router-dom";
7+
import { getAdminPrivilages } from "./actions/adminPrivilagesAction";
78
import { loadUser } from "./actions/authAction";
89
import Navbar from "./components/navbar/Navbar";
910
// Import Routes
@@ -16,22 +17,32 @@ if (localStorage.getItem("token")) {
1617
setAuthToken(localStorage.getItem("token"));
1718
}
1819

19-
function App() {
20+
function App({ auth, getAdminPrivilages }) {
2021
useEffect(() => {
2122
store.dispatch(loadUser());
23+
getAdminPrivilages(true);
2224
}, []);
25+
26+
useEffect(() => {
27+
getAdminPrivilages(true);
28+
}, [auth.isAuthenticated]);
29+
2330
return (
24-
<Provider store={store}>
25-
<Router>
26-
<Navbar />
27-
<Flex justifyContent="space-between" alignItems="flex-start" h="100%">
28-
<Switch>
29-
<Routes />
30-
</Switch>
31-
</Flex>
32-
</Router>
33-
</Provider>
31+
<Router>
32+
<Navbar />
33+
<Flex justifyContent="space-between" alignItems="flex-start" h="100%">
34+
<Switch>
35+
<Routes />
36+
</Switch>
37+
</Flex>
38+
</Router>
3439
);
3540
}
3641

37-
export default App;
42+
const mapStateToProps = (state) => {
43+
return {
44+
auth: state.auth,
45+
};
46+
};
47+
48+
export default connect(mapStateToProps, { getAdminPrivilages })(App);

client/src/components/comment/Comment.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import * as S from "@chakra-ui/react";
12
import React, { useEffect, useState } from "react";
23
import { connect } from "react-redux";
34
import { getComments, postComment } from "../../actions/commentAction";
45
import CommentInput from "./CommentInput";
56
import CommentItem from "./CommentItem";
6-
import * as S from "@chakra-ui/react";
77

88
const Comment = ({
99
getComments,

client/src/components/layout components/Trending/TrendingItem/TrendingItem.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ const TrendingItem = ({
170170
{adminPrivilages.postAccessibility && (
171171
<Fragment>
172172
<Flex mt="10px" className="admin-post-drop">
173-
<Menu isLazy>
173+
<Menu>
174174
<MenuButton
175175
as={Flex}
176176
w="20px"

client/src/components/pages/ActivityList.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ const ActivityList = ({
2727
// eslint-disable-next-line
2828
}, [post.savedPosts.length]);
2929

30-
const removeThisSavedPost = (id) => {
31-
savePost(id);
32-
};
30+
// const removeThisSavedPost = (id) => {
31+
// savePost(id);
32+
// };
3333

34-
const openThisPost = (id) => {
35-
if (post !== undefined && routing !== undefined) {
36-
setCurrentPost(id.toString());
37-
sessionStorage.setItem("postID", id.toString());
38-
routing.push("/post");
39-
}
40-
};
34+
// const openThisPost = (id) => {
35+
// if (post !== undefined && routing !== undefined) {
36+
// setCurrentPost(id.toString());
37+
// sessionStorage.setItem("postID", id.toString());
38+
// routing.push("/post");
39+
// }
40+
// };
4141

4242
return (
4343
<Flex className="activity-list" px="1rem" w="100%" mt="2rem">
@@ -48,7 +48,7 @@ const ActivityList = ({
4848
width="100%"
4949
>
5050
{postsSaved.map((post) => (
51-
<Box w="350px" onClick={openThisPost} mb="2rem">
51+
<Box w="350px" mb="2rem">
5252
<TrendingItem post={post} forComp="saved" />
5353
</Box>
5454
))}

client/src/index.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import { ChakraProvider, extendTheme } from "@chakra-ui/react";
22
import React from "react";
33
import ReactDOM from "react-dom";
4+
import { Provider } from "react-redux";
45
import App from "./App";
56
import "./index.css";
7+
import store from "./store";
68

79
ReactDOM.render(
810
<React.StrictMode>
9-
<ChakraProvider
10-
theme={extendTheme({
11-
config: { useSystemColorMode: false, initialColorMode: "dark" },
12-
})}
13-
>
14-
<App />
15-
</ChakraProvider>
11+
<Provider store={store}>
12+
<ChakraProvider
13+
theme={extendTheme({
14+
config: { useSystemColorMode: false, initialColorMode: "dark" },
15+
})}
16+
>
17+
<App />
18+
</ChakraProvider>
19+
</Provider>
1620
</React.StrictMode>,
1721
document.getElementById("root")
1822
);

0 commit comments

Comments
 (0)