umami/components/pages/settings/teams/TeamMembers.js

30 lines
870 B
JavaScript
Raw Normal View History

2023-03-22 22:05:55 +01:00
import { Loading, useToast } from 'react-basics';
2023-01-10 08:59:26 +01:00
import TeamMembersTable from 'components/pages/settings/teams/TeamMembersTable';
import useApi from 'hooks/useApi';
2023-03-22 22:05:55 +01:00
import useMessages from 'hooks/useMessages';
2023-01-10 08:59:26 +01:00
2023-02-02 20:59:38 +01:00
export default function TeamMembers({ teamId, readOnly }) {
const { toast, showToast } = useToast();
2023-01-10 08:59:26 +01:00
const { get, useQuery } = useApi();
const { formatMessage, messages } = useMessages();
const { data, isLoading, refetch } = useQuery(['teams:users', teamId], () =>
2023-01-10 08:59:26 +01:00
get(`/teams/${teamId}/users`),
);
if (isLoading) {
return <Loading icon="dots" position="block" />;
}
const handleSave = async () => {
await refetch();
showToast({ message: formatMessage(messages.saved), variant: 'success' });
};
return (
<>
{toast}
<TeamMembersTable onSave={handleSave} data={data} readOnly={readOnly} />
</>
);
2023-01-10 08:59:26 +01:00
}