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';
|
2023-03-10 08:21:19 +01:00
|
|
|
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();
|
2023-03-30 01:02:14 +02:00
|
|
|
const { formatMessage, messages } = useMessages();
|
2023-03-10 08:21:19 +01:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2023-03-10 08:21:19 +01:00
|
|
|
const handleSave = async () => {
|
|
|
|
await refetch();
|
2023-03-30 01:02:14 +02:00
|
|
|
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
2023-03-10 08:21:19 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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;
|