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

31 lines
882 B
JavaScript
Raw Normal View History

2023-06-13 20:59:12 +02:00
import { Loading, useToasts } 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-04-21 17:00:42 +02:00
export function TeamMembers({ teamId, readOnly }) {
2023-06-13 20:59:12 +02:00
const { showToast } = useToasts();
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) {
2023-04-13 02:43:08 +02:00
return <Loading icon="dots" style={{ minHeight: 300 }} />;
2023-01-10 08:59:26 +01:00
}
const handleSave = async () => {
await refetch();
showToast({ message: formatMessage(messages.saved), variant: 'success' });
};
return (
<>
<TeamMembersTable onSave={handleSave} data={data} readOnly={readOnly} />
</>
);
2023-01-10 08:59:26 +01:00
}
2023-04-21 17:00:42 +02:00
export default TeamMembers;