File tree Expand file tree Collapse file tree 5 files changed +48
-33
lines changed
layout components/Trending/TrendingItem Expand file tree Collapse file tree 5 files changed +48
-33
lines changed Original file line number Diff line number Diff line change 1
1
import { Flex } from "@chakra-ui/react" ;
2
2
import React , { useEffect } from "react" ;
3
3
// Redux
4
- import { Provider } from "react-redux" ;
4
+ import { connect } from "react-redux" ;
5
5
// Router
6
6
import { BrowserRouter as Router , Switch } from "react-router-dom" ;
7
+ import { getAdminPrivilages } from "./actions/adminPrivilagesAction" ;
7
8
import { loadUser } from "./actions/authAction" ;
8
9
import Navbar from "./components/navbar/Navbar" ;
9
10
// Import Routes
@@ -16,22 +17,32 @@ if (localStorage.getItem("token")) {
16
17
setAuthToken ( localStorage . getItem ( "token" ) ) ;
17
18
}
18
19
19
- function App ( ) {
20
+ function App ( { auth , getAdminPrivilages } ) {
20
21
useEffect ( ( ) => {
21
22
store . dispatch ( loadUser ( ) ) ;
23
+ getAdminPrivilages ( true ) ;
22
24
} , [ ] ) ;
25
+
26
+ useEffect ( ( ) => {
27
+ getAdminPrivilages ( true ) ;
28
+ } , [ auth . isAuthenticated ] ) ;
29
+
23
30
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 >
34
39
) ;
35
40
}
36
41
37
- export default App ;
42
+ const mapStateToProps = ( state ) => {
43
+ return {
44
+ auth : state . auth ,
45
+ } ;
46
+ } ;
47
+
48
+ export default connect ( mapStateToProps , { getAdminPrivilages } ) ( App ) ;
Original file line number Diff line number Diff line change
1
+ import * as S from "@chakra-ui/react" ;
1
2
import React , { useEffect , useState } from "react" ;
2
3
import { connect } from "react-redux" ;
3
4
import { getComments , postComment } from "../../actions/commentAction" ;
4
5
import CommentInput from "./CommentInput" ;
5
6
import CommentItem from "./CommentItem" ;
6
- import * as S from "@chakra-ui/react" ;
7
7
8
8
const Comment = ( {
9
9
getComments,
Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ const TrendingItem = ({
170
170
{ adminPrivilages . postAccessibility && (
171
171
< Fragment >
172
172
< Flex mt = "10px" className = "admin-post-drop" >
173
- < Menu isLazy >
173
+ < Menu >
174
174
< MenuButton
175
175
as = { Flex }
176
176
w = "20px"
Original file line number Diff line number Diff line change @@ -27,17 +27,17 @@ const ActivityList = ({
27
27
// eslint-disable-next-line
28
28
} , [ post . savedPosts . length ] ) ;
29
29
30
- const removeThisSavedPost = ( id ) => {
31
- savePost ( id ) ;
32
- } ;
30
+ // const removeThisSavedPost = (id) => {
31
+ // savePost(id);
32
+ // };
33
33
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
+ // };
41
41
42
42
return (
43
43
< Flex className = "activity-list" px = "1rem" w = "100%" mt = "2rem" >
@@ -48,7 +48,7 @@ const ActivityList = ({
48
48
width = "100%"
49
49
>
50
50
{ postsSaved . map ( ( post ) => (
51
- < Box w = "350px" onClick = { openThisPost } mb = "2rem" >
51
+ < Box w = "350px" mb = "2rem" >
52
52
< TrendingItem post = { post } forComp = "saved" />
53
53
</ Box >
54
54
) ) }
Original file line number Diff line number Diff line change 1
1
import { ChakraProvider , extendTheme } from "@chakra-ui/react" ;
2
2
import React from "react" ;
3
3
import ReactDOM from "react-dom" ;
4
+ import { Provider } from "react-redux" ;
4
5
import App from "./App" ;
5
6
import "./index.css" ;
7
+ import store from "./store" ;
6
8
7
9
ReactDOM . render (
8
10
< 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 >
16
20
</ React . StrictMode > ,
17
21
document . getElementById ( "root" )
18
22
) ;
You can’t perform that action at this time.
0 commit comments