This repository was archived by the owner on Jul 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
app/client/src/components Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ class Post extends React.Component {
125
125
onCancelVote = { this . handleCancelVote }
126
126
userUpvoted = { userUpvoted }
127
127
userDownvoted = { userDownvoted }
128
+ currentUser = { currentUser }
128
129
/>
129
130
< div className = "post-body-container" >
130
131
< div
Original file line number Diff line number Diff line change 1
1
import React from "react" ;
2
2
import classnames from "classnames" ;
3
+ import { withRouter } from "react-router-dom" ;
3
4
4
5
const PostVote = ( {
5
6
post,
6
7
onVote,
7
8
onCancelVote,
8
9
userUpvoted,
9
- userDownvoted
10
+ userDownvoted,
11
+ currentUser,
12
+ history
10
13
} ) => {
11
14
let postScore = post . UpvoteCount - post . DownvoteCount ;
12
15
if ( userUpvoted ) {
@@ -23,6 +26,10 @@ const PostVote = ({
23
26
className = { classnames ( "vote-btn" , { voted : userUpvoted } ) }
24
27
onClick = { e => {
25
28
e . preventDefault ( ) ;
29
+ if ( ! currentUser ) {
30
+ history . push ( "/login" ) ;
31
+ return ;
32
+ }
26
33
27
34
if ( userUpvoted ) {
28
35
onCancelVote ( { type : "Upvote" } ) ;
@@ -41,6 +48,10 @@ const PostVote = ({
41
48
className = { classnames ( "vote-btn" , { voted : userDownvoted } ) }
42
49
onClick = { e => {
43
50
e . preventDefault ( ) ;
51
+ if ( ! currentUser ) {
52
+ history . push ( "/login" ) ;
53
+ return ;
54
+ }
44
55
45
56
if ( userDownvoted ) {
46
57
onCancelVote ( { type : "Downvote" } ) ;
@@ -55,4 +66,4 @@ const PostVote = ({
55
66
</ div >
56
67
) ;
57
68
} ;
58
- export default PostVote ;
69
+ export default withRouter ( PostVote ) ;
You can’t perform that action at this time.
0 commit comments