1
1
import { FC , useMemo } from 'react'
2
2
import { format } from 'date-fns'
3
3
4
- import { CheckIcon } from '@heroicons/react/solid'
4
+ import { CheckIcon , XIcon } from '@heroicons/react/solid'
5
5
import { useWindowSize , WindowSize } from '~/libs/shared'
6
6
import {
7
7
Button ,
@@ -27,6 +27,7 @@ export interface ReviewerListProps {
27
27
approvingReviewerId : number
28
28
onPageChange : ( page : number ) => void
29
29
onApproveApplication : ( reviewer : Reviewer ) => void
30
+ onUnapproveApplication : ( reviewer : Reviewer ) => void
30
31
onToggleSort : ( sort : Sort ) => void
31
32
}
32
33
@@ -35,15 +36,22 @@ const ApproveButton: FC<{
35
36
openReviews : number
36
37
approvingReviewerId : number
37
38
onApproveApplication : ReviewerListProps [ 'onApproveApplication' ]
39
+ onUnapproveApplication : ReviewerListProps [ 'onUnapproveApplication' ]
38
40
} > = props => {
39
41
const handleApprove = useEventCallback ( ( ) : void => {
40
42
props . onApproveApplication ( props . reviewer )
41
43
} )
42
44
45
+ const handleRemove = useEventCallback ( ( ) : void => {
46
+ props . onUnapproveApplication ( props . reviewer )
47
+ } )
48
+
43
49
const isApproving = props . approvingReviewerId === props . reviewer . userId
44
50
const isOtherApproving = props . approvingReviewerId > 0
45
51
const hideApproveButton
46
52
= props . openReviews < 1 || props . reviewer . applicationStatus !== 'Pending'
53
+ const showRemoveButton
54
+ = props . reviewer . applicationStatus === 'Approved'
47
55
48
56
return (
49
57
< >
@@ -53,7 +61,19 @@ const ApproveButton: FC<{
53
61
className = { styles . approvingLoadingSpinner }
54
62
/>
55
63
) : (
56
- ! hideApproveButton && (
64
+ hideApproveButton ? (
65
+ showRemoveButton && (
66
+ < Button
67
+ primary
68
+ variant = 'danger'
69
+ onClick = { handleRemove }
70
+ >
71
+ < XIcon className = 'icon icon-fill' />
72
+ { ' ' }
73
+ Remove Reviewer
74
+ </ Button >
75
+ )
76
+ ) : (
57
77
< Button
58
78
primary
59
79
onClick = { handleApprove }
@@ -105,13 +125,15 @@ const Actions: FC<{
105
125
openReviews : number
106
126
approvingReviewerId : number
107
127
onApproveApplication : ReviewerListProps [ 'onApproveApplication' ]
128
+ onUnapproveApplication : ReviewerListProps [ 'onUnapproveApplication' ]
108
129
} > = props => (
109
130
< div className = { styles . rowActions } >
110
131
< ApproveButton
111
132
reviewer = { props . reviewer }
112
133
openReviews = { props . openReviews }
113
134
approvingReviewerId = { props . approvingReviewerId }
114
135
onApproveApplication = { props . onApproveApplication }
136
+ onUnapproveApplication = { props . onUnapproveApplication }
115
137
/>
116
138
</ div >
117
139
)
@@ -155,7 +177,7 @@ const ReviewerList: FC<ReviewerListProps> = props => {
155
177
type : 'element' ,
156
178
} ,
157
179
{
158
- label : 'Open Review Opp ' ,
180
+ label : 'Open Reviews ' ,
159
181
propertyName : '' ,
160
182
renderer : ( reviewer : Reviewer ) => (
161
183
// eslint-disable-next-line jsx-a11y/anchor-is-valid
@@ -170,7 +192,7 @@ const ReviewerList: FC<ReviewerListProps> = props => {
170
192
propertyName : 'reviewsInPast60Days' ,
171
193
type : 'number' ,
172
194
} ,
173
- { label : 'Matching Skills' , propertyName : '' , type : 'text' } ,
195
+ // { label: 'Matching Skills', propertyName: '', type: 'text' },
174
196
{
175
197
label : '' ,
176
198
renderer : ( reviewer : Reviewer ) => (
@@ -179,6 +201,7 @@ const ReviewerList: FC<ReviewerListProps> = props => {
179
201
openReviews = { props . openReviews }
180
202
approvingReviewerId = { props . approvingReviewerId }
181
203
onApproveApplication = { props . onApproveApplication }
204
+ onUnapproveApplication = { props . onUnapproveApplication }
182
205
/>
183
206
) ,
184
207
type : 'action' ,
0 commit comments