Skip to content

Commit 4535882

Browse files
committed
refactor: AddTeamMember to use Typescript
1 parent 056eac5 commit 4535882

File tree

2 files changed

+18
-6
lines changed
  • packages/app/src/app/pages/Dashboard/Content/routes/TeamView/AddTeamMember

2 files changed

+18
-6
lines changed

packages/app/src/app/pages/Dashboard/Content/routes/TeamView/AddTeamMember/index.js renamed to packages/app/src/app/pages/Dashboard/Content/routes/TeamView/AddTeamMember/index.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import track from '@codesandbox/common/lib/utils/analytics';
99

1010
import { useOvermind } from 'app/overmind';
1111
import { INVITE_TO_TEAM } from '../../../../queries';
12+
import { IAddTeamMemberProps, IMutationVariables } from './types';
1213

1314
const ErrorMessage = styled.div`
1415
color: ${props => props.theme.red};
@@ -17,12 +18,12 @@ const ErrorMessage = styled.div`
1718
margin-bottom: 0.5rem;
1819
`;
1920

20-
export const AddTeamMember = ({ teamId }) => {
21+
export const AddTeamMember: React.FC<IAddTeamMemberProps> = ({ teamId }) => {
2122
const { actions } = useOvermind();
2223
const [mutate, { loading, error }] = useMutation(INVITE_TO_TEAM);
23-
let input = null;
24+
let input: HTMLInputElement = null;
2425

25-
const submit = e => {
26+
const submit: React.FormEventHandler = e => {
2627
e.preventDefault();
2728
e.stopPropagation();
2829

@@ -34,7 +35,7 @@ export const AddTeamMember = ({ teamId }) => {
3435

3536
// We don't enable email for now for privacy reasons
3637

37-
const variables = { teamId };
38+
const variables: IMutationVariables = { teamId };
3839

3940
const { value } = input;
4041
if (isEmail) {
@@ -47,8 +48,8 @@ export const AddTeamMember = ({ teamId }) => {
4748
variables,
4849
}).then(() => {
4950
actions.notificationAdded({
50-
message: `${value} has been invited!`,
51-
type: 'success',
51+
title: `${value} has been invited!`,
52+
notificationType: 'success',
5253
});
5354
});
5455

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type TeamId = string;
2+
3+
export interface IAddTeamMemberProps {
4+
teamId: TeamId;
5+
}
6+
7+
export interface IMutationVariables {
8+
teamId: TeamId;
9+
email?: string;
10+
username?: string;
11+
}

0 commit comments

Comments
 (0)