diff --git a/components/pages/settings/teams/TeamMemberRemoveButton.js b/components/pages/settings/teams/TeamMemberRemoveButton.js
new file mode 100644
index 00000000..84b728a6
--- /dev/null
+++ b/components/pages/settings/teams/TeamMemberRemoveButton.js
@@ -0,0 +1,29 @@
+import useApi from 'hooks/useApi';
+import useMessages from 'hooks/useMessages';
+import { Icon, Icons, LoadingButton, Text } from 'react-basics';
+
+export default function TeamMemberRemoveButton({ teamUserId, disabled, onSave }) {
+ const { formatMessage, labels } = useMessages();
+ const { del, useMutation } = useApi();
+ const { mutate, isLoading } = useMutation(() => del(`/teamUsers/${teamUserId}`));
+
+ const handleRemoveTeamMember = () => {
+ mutate(
+ { teamUserId },
+ {
+ onSuccess: () => {
+ onSave();
+ },
+ },
+ );
+ };
+
+ return (
+ handleRemoveTeamMember()} disabled={disabled} loading={isLoading}>
+
+
+
+ {formatMessage(labels.remove)}
+
+ );
+}
diff --git a/components/pages/settings/teams/TeamMembersTable.js b/components/pages/settings/teams/TeamMembersTable.js
index 0d405fec..b4909369 100644
--- a/components/pages/settings/teams/TeamMembersTable.js
+++ b/components/pages/settings/teams/TeamMembersTable.js
@@ -1,28 +1,20 @@
+import useMessages from 'hooks/useMessages';
+import useUser from 'hooks/useUser';
+import { ROLES } from 'lib/constants';
import {
+ Flexbox,
Table,
- TableHeader,
TableBody,
- TableRow,
TableCell,
TableColumn,
- LoadingButton,
- Icon,
- Icons,
- Flexbox,
- Text,
+ TableHeader,
+ TableRow,
} from 'react-basics';
-import { ROLES } from 'lib/constants';
-import useUser from 'hooks/useUser';
-import useApi from 'hooks/useApi';
-import useMessages from 'hooks/useMessages';
-import { useState } from 'react';
+import TeamMemberRemoveButton from './TeamMemberRemoveButton';
export default function TeamMembersTable({ data = [], onSave, readOnly }) {
const { formatMessage, labels } = useMessages();
const { user } = useUser();
- const { del, useMutation } = useApi();
- const { mutate, isLoading } = useMutation(data => del(`/teamUsers/${data.teamUserId}`));
- const [loadingIds, setLoadingIds] = useState([]);
const columns = [
{ name: 'username', label: formatMessage(labels.username), style: { flex: 2 } },
@@ -30,23 +22,6 @@ export default function TeamMembersTable({ data = [], onSave, readOnly }) {
{ name: 'action', label: '', style: { flex: 1 } },
];
- const handleRemoveTeamMember = teamUserId => {
- setLoadingIds(prev => [...prev, teamUserId]);
-
- mutate(
- { teamUserId },
- {
- onSuccess: () => {
- setLoadingIds(loadingIds.filter(a => a !== teamUserId));
- onSave();
- },
- onError: () => {
- setLoadingIds(loadingIds.filter(a => a !== teamUserId));
- },
- },
- );
- };
-
return (
@@ -67,16 +42,11 @@ export default function TeamMembersTable({ data = [], onSave, readOnly }) {
),
action: !readOnly && (
- handleRemoveTeamMember(row.id)}
+ a === row.id)}
- >
-
-
-
- {formatMessage(labels.remove)}
-
+ onSave={onSave}
+ >
),
};
diff --git a/components/pages/settings/teams/TeamWebsiteRemoveButton.js b/components/pages/settings/teams/TeamWebsiteRemoveButton.js
new file mode 100644
index 00000000..cc38f892
--- /dev/null
+++ b/components/pages/settings/teams/TeamWebsiteRemoveButton.js
@@ -0,0 +1,29 @@
+import useApi from 'hooks/useApi';
+import useMessages from 'hooks/useMessages';
+import { Icon, Icons, LoadingButton, Text } from 'react-basics';
+
+export default function TeamWebsiteRemoveButton({ teamWebsiteId, onSave }) {
+ const { formatMessage, labels } = useMessages();
+ const { del, useMutation } = useApi();
+ const { mutate, isLoading } = useMutation(() => del(`/teamWebsites/${teamWebsiteId}`));
+
+ const handleRemoveTeamMember = () => {
+ mutate(
+ { teamWebsiteId },
+ {
+ onSuccess: () => {
+ onSave();
+ },
+ },
+ );
+ };
+
+ return (
+ handleRemoveTeamMember()} loading={isLoading}>
+
+
+
+ {formatMessage(labels.remove)}
+
+ );
+}
diff --git a/components/pages/settings/teams/TeamWebsitesTable.js b/components/pages/settings/teams/TeamWebsitesTable.js
index bb85033f..a2190abc 100644
--- a/components/pages/settings/teams/TeamWebsitesTable.js
+++ b/components/pages/settings/teams/TeamWebsitesTable.js
@@ -1,44 +1,30 @@
+import useMessages from 'hooks/useMessages';
+import useUser from 'hooks/useUser';
import Link from 'next/link';
import {
- Table,
- TableHeader,
- TableBody,
- TableRow,
- TableCell,
- TableColumn,
Button,
- Text,
+ Flexbox,
Icon,
Icons,
- Flexbox,
+ Table,
+ TableBody,
+ TableCell,
+ TableColumn,
+ TableHeader,
+ TableRow,
+ Text,
} from 'react-basics';
-import useUser from 'hooks/useUser';
-import useApi from 'hooks/useApi';
-import useMessages from 'hooks/useMessages';
+import TeamWebsiteRemoveButton from './TeamWebsiteRemoveButton';
export default function TeamWebsitesTable({ data = [], onSave }) {
const { formatMessage, labels } = useMessages();
const { user } = useUser();
- const { del, useMutation } = useApi();
- const { mutate } = useMutation(({ teamWebsiteId }) => del(`/teamWebsites/${teamWebsiteId}`));
-
const columns = [
{ name: 'name', label: formatMessage(labels.name) },
{ name: 'domain', label: formatMessage(labels.domain) },
{ name: 'action', label: ' ' },
];
- const handleRemoveWebsite = teamWebsiteId => {
- mutate(
- { teamWebsiteId },
- {
- onSuccess: async () => {
- onSave();
- },
- },
- );
- };
-
return (
@@ -72,12 +58,10 @@ export default function TeamWebsitesTable({ data = [], onSave }) {
{canRemove && (
-
+
)}
);