Skip to content

Commit 1e76062

Browse files
michellewzhangandrewshie-sentry
authored andcommitted
ref(tsc): convert teamAccessRequestModal to FC (#82470)
1 parent 95810cc commit 1e76062

File tree

1 file changed

+25
-44
lines changed

1 file changed

+25
-44
lines changed

Diff for: static/app/components/modals/teamAccessRequestModal.tsx

+25-44
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Component, Fragment} from 'react';
1+
import {Fragment, useState} from 'react';
22
import styled from '@emotion/styled';
33

44
import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
@@ -21,22 +21,12 @@ export interface CreateTeamAccessRequestModalProps
2121
teamId: string;
2222
}
2323

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;
2727

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);
4030

4131
try {
4232
await api.requestPromise(
@@ -49,37 +39,28 @@ class CreateTeamAccessRequestModal extends Component<
4939
} catch (err) {
5040
addErrorMessage(t('Unable to send team request'));
5141
}
52-
this.setState({createBusy: false});
42+
setCreateBusy(false);
5343
closeModal();
5444
};
5545

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+
);
8364
}
8465

8566
const ButtonGroup = styled('div')`

0 commit comments

Comments
 (0)