1
1
/* eslint-disable react/no-unescaped-entities */
2
2
import React , { Component , Fragment } from 'react' ;
3
3
import PropTypes from 'prop-types' ;
4
- import BigNumber from 'bignumber.js' ;
5
4
6
5
import Milestone from 'models/Milestone' ;
7
6
import User from 'models/User' ;
8
7
import MilestoneService from 'services/MilestoneService' ;
9
8
import ErrorPopup from 'components/ErrorPopup' ;
10
9
import ConversationModal from 'components/ConversationModal' ;
11
- import GA from 'lib/GoogleAnalytics' ;
12
- import { checkBalance } from 'lib/middleware' ;
13
10
14
11
class ApproveRejectMilestoneCompletionButtons extends Component {
15
12
constructor ( ) {
@@ -18,145 +15,72 @@ class ApproveRejectMilestoneCompletionButtons extends Component {
18
15
}
19
16
20
17
approveMilestoneCompleted ( ) {
21
- const { milestone, currentUser , balance } = this . props ;
18
+ const { milestone } = this . props ;
22
19
23
- checkBalance ( balance )
24
- . then ( ( ) => {
25
- this . conversationModal . current
26
- . openModal ( {
27
- title : 'Approve milestone completion' ,
28
- description :
29
- 'Optionally explain why you approve the completion of this milestone. Compliments are appreciated! This information will be publicly visible and emailed to the milestone owner.' ,
30
- textPlaceholder :
31
- 'Optionally explain why you approve the completion of this milestone...' ,
32
- required : false ,
33
- cta : 'Approve completion' ,
34
- enableAttachProof : false ,
35
- } )
36
- . then ( proof => {
37
- MilestoneService . approveMilestoneCompletion ( {
38
- milestone,
39
- from : currentUser . address ,
40
- proof,
41
- onTxHash : txUrl => {
42
- GA . trackEvent ( {
43
- category : 'Milestone' ,
44
- action : 'approved completion' ,
45
- label : milestone . _id ,
46
- } ) ;
47
-
48
- React . toast . info (
49
- < p >
50
- Approving this milestone is pending...
51
- < br />
52
- < a href = { txUrl } target = "_blank" rel = "noopener noreferrer" >
53
- View transaction
54
- </ a >
55
- </ p > ,
56
- ) ;
57
- } ,
58
- onConfirmation : txUrl => {
59
- React . toast . success (
60
- < p >
61
- The milestone has been approved!
62
- < br />
63
- < a href = { txUrl } target = "_blank" rel = "noopener noreferrer" >
64
- View transaction
65
- </ a >
66
- </ p > ,
67
- ) ;
68
- } ,
69
- onError : ( err , txUrl ) => {
70
- if ( err === 'patch-error' ) {
71
- ErrorPopup (
72
- "Something went wrong with approving this milestone's completion" ,
73
- err ,
74
- ) ;
75
- } else {
76
- ErrorPopup (
77
- 'Something went wrong with the transaction.' ,
78
- `${ txUrl } => ${ JSON . stringify ( err , null , 2 ) } ` ,
79
- ) ;
80
- }
81
- } ,
82
- } ) ;
83
- } ) ;
20
+ this . conversationModal . current
21
+ . openModal ( {
22
+ title : 'Approve milestone completion' ,
23
+ description :
24
+ 'Optionally explain why you approve the completion of this milestone. Compliments are appreciated! This information will be publicly visible and emailed to the milestone owner.' ,
25
+ textPlaceholder : 'Optionally explain why you approve the completion of this milestone...' ,
26
+ required : false ,
27
+ cta : 'Approve completion' ,
28
+ enableAttachProof : false ,
84
29
} )
85
- . catch ( err => {
86
- if ( err === 'noBalance' ) {
87
- // handle no balance error
88
- }
30
+ . then ( proof => {
31
+ MilestoneService . approveMilestoneCompletion ( {
32
+ milestone,
33
+ proof,
34
+ onConfirmation : txUrl => {
35
+ React . toast . success (
36
+ < p >
37
+ The milestone has been approved!
38
+ < br />
39
+ < a href = { txUrl } target = "_blank" rel = "noopener noreferrer" >
40
+ View transaction
41
+ </ a >
42
+ </ p > ,
43
+ ) ;
44
+ } ,
45
+ onError : err => {
46
+ ErrorPopup ( 'Failed to approve milestone completion' , err ) ;
47
+ } ,
48
+ } ) ;
89
49
} ) ;
90
50
}
91
51
92
52
rejectMilestoneCompleted ( ) {
93
- const { milestone, currentUser } = this . props ;
94
-
95
- checkBalance ( this . props . balance )
96
- . then ( ( ) => {
97
- this . conversationModal . current
98
- . openModal ( {
99
- title : 'Reject milestone completion' ,
100
- description :
101
- 'Explain why you rejected the completion of this milestone. This information will be publicly visible and emailed to the milestone owner.' ,
102
- textPlaceholder : 'Explain why you rejected the completion of this milestone...' ,
103
- required : true ,
104
- cta : 'Reject completion' ,
105
- enableAttachProof : false ,
106
- } )
107
- . then ( proof => {
108
- MilestoneService . rejectMilestoneCompletion ( {
109
- milestone,
110
- from : currentUser . address ,
111
- proof,
112
- onTxHash : txUrl => {
113
- GA . trackEvent ( {
114
- category : 'Milestone' ,
115
- action : 'rejected completion' ,
116
- label : milestone . _id ,
117
- } ) ;
53
+ const { milestone } = this . props ;
118
54
119
- React . toast . info (
120
- < p >
121
- Rejecting this milestone's completion is pending...
122
- < br />
123
- < a href = { txUrl } target = "_blank" rel = "noopener noreferrer" >
124
- View transaction
125
- </ a >
126
- </ p > ,
127
- ) ;
128
- } ,
129
- onConfirmation : txUrl => {
130
- React . toast . success (
131
- < p >
132
- The milestone's completion has been rejected.
133
- < br />
134
- < a href = { txUrl } target = "_blank" rel = "noopener noreferrer" >
135
- View transaction
136
- </ a >
137
- </ p > ,
138
- ) ;
139
- } ,
140
- onError : ( err , txUrl ) => {
141
- if ( err === 'patch-error' ) {
142
- ErrorPopup (
143
- "Something went wrong with rejecting this milestone's completion" ,
144
- err ,
145
- ) ;
146
- } else {
147
- ErrorPopup (
148
- 'Something went wrong with the transaction.' ,
149
- `${ txUrl } => ${ JSON . stringify ( err , null , 2 ) } ` ,
150
- ) ;
151
- }
152
- } ,
153
- } ) ;
154
- } ) ;
55
+ this . conversationModal . current
56
+ . openModal ( {
57
+ title : 'Reject milestone completion' ,
58
+ description :
59
+ 'Explain why you rejected the completion of this milestone. This information will be publicly visible and emailed to the milestone owner.' ,
60
+ textPlaceholder : 'Explain why you rejected the completion of this milestone...' ,
61
+ required : true ,
62
+ cta : 'Reject completion' ,
63
+ enableAttachProof : false ,
155
64
} )
156
- . catch ( err => {
157
- if ( err === 'noBalance' ) {
158
- // handle no balance error
159
- }
65
+ . then ( proof => {
66
+ MilestoneService . rejectMilestoneCompletion ( {
67
+ milestone,
68
+ proof,
69
+ onConfirmation : txUrl => {
70
+ React . toast . success (
71
+ < p >
72
+ The milestone's completion has been rejected.
73
+ < br />
74
+ < a href = { txUrl } target = "_blank" rel = "noopener noreferrer" >
75
+ View transaction
76
+ </ a >
77
+ </ p > ,
78
+ ) ;
79
+ } ,
80
+ onError : err => {
81
+ ErrorPopup ( 'Failed to reject milestone completion' , err ) ;
82
+ } ,
83
+ } ) ;
160
84
} ) ;
161
85
}
162
86
@@ -167,8 +91,7 @@ class ApproveRejectMilestoneCompletionButtons extends Component {
167
91
< Fragment >
168
92
{ currentUser &&
169
93
milestone . reviewerAddress === currentUser . address &&
170
- milestone . status === 'NeedsReview' &&
171
- milestone . mined && (
94
+ milestone . status === 'NeedsReview' && (
172
95
< span >
173
96
< button
174
97
type = "button"
@@ -198,7 +121,6 @@ class ApproveRejectMilestoneCompletionButtons extends Component {
198
121
199
122
ApproveRejectMilestoneCompletionButtons . propTypes = {
200
123
currentUser : PropTypes . instanceOf ( User ) . isRequired ,
201
- balance : PropTypes . instanceOf ( BigNumber ) . isRequired ,
202
124
milestone : PropTypes . instanceOf ( Milestone ) . isRequired ,
203
125
} ;
204
126
0 commit comments