1
- import { Component , Fragment } from 'react' ;
1
+ import { Fragment , useState } from 'react' ;
2
2
import styled from '@emotion/styled' ;
3
3
4
4
import { addErrorMessage , addSuccessMessage } from 'sentry/actionCreators/indicator' ;
@@ -21,22 +21,12 @@ export interface CreateTeamAccessRequestModalProps
21
21
teamId : string ;
22
22
}
23
23
24
- type State = {
25
- createBusy : boolean ;
26
- } ;
24
+ function CreateTeamAccessRequestModal ( props : CreateTeamAccessRequestModalProps ) {
25
+ const [ createBusy , setCreateBusy ] = useState < boolean > ( false ) ;
26
+ const { api , memberId , orgId , teamId , closeModal , Body , Footer } = props ;
27
27
28
- class CreateTeamAccessRequestModal extends Component <
29
- CreateTeamAccessRequestModalProps ,
30
- State
31
- > {
32
- state : State = {
33
- createBusy : false ,
34
- } ;
35
-
36
- handleClick = async ( ) => {
37
- const { api, memberId, orgId, teamId, closeModal} = this . props ;
38
-
39
- this . setState ( { createBusy : true } ) ;
28
+ const handleClick = async ( ) => {
29
+ setCreateBusy ( true ) ;
40
30
41
31
try {
42
32
await api . requestPromise (
@@ -49,37 +39,28 @@ class CreateTeamAccessRequestModal extends Component<
49
39
} catch ( err ) {
50
40
addErrorMessage ( t ( 'Unable to send team request' ) ) ;
51
41
}
52
- this . setState ( { createBusy : false } ) ;
42
+ setCreateBusy ( false ) ;
53
43
closeModal ( ) ;
54
44
} ;
55
45
56
- render ( ) {
57
- const { Body, Footer, closeModal, teamId} = this . props ;
58
-
59
- return (
60
- < Fragment >
61
- < Body >
62
- { tct (
63
- 'You do not have permission to add members to the #[team] team, but we will send a request to your organization admins for approval.' ,
64
- { team : teamId }
65
- ) }
66
- </ Body >
67
- < Footer >
68
- < ButtonGroup >
69
- < Button onClick = { closeModal } > { t ( 'Cancel' ) } </ Button >
70
- < Button
71
- priority = "primary"
72
- onClick = { this . handleClick }
73
- busy = { this . state . createBusy }
74
- autoFocus
75
- >
76
- { t ( 'Continue' ) }
77
- </ Button >
78
- </ ButtonGroup >
79
- </ Footer >
80
- </ Fragment >
81
- ) ;
82
- }
46
+ return (
47
+ < Fragment >
48
+ < Body >
49
+ { tct (
50
+ 'You do not have permission to add members to the #[team] team, but we will send a request to your organization admins for approval.' ,
51
+ { team : teamId }
52
+ ) }
53
+ </ Body >
54
+ < Footer >
55
+ < ButtonGroup >
56
+ < Button onClick = { closeModal } > { t ( 'Cancel' ) } </ Button >
57
+ < Button priority = "primary" onClick = { handleClick } busy = { createBusy } autoFocus >
58
+ { t ( 'Continue' ) }
59
+ </ Button >
60
+ </ ButtonGroup >
61
+ </ Footer >
62
+ </ Fragment >
63
+ ) ;
83
64
}
84
65
85
66
const ButtonGroup = styled ( 'div' ) `
0 commit comments