umami/components/pages/settings/users/UserWebsites.js
2023-04-08 13:14:22 -07:00

25 lines
727 B
JavaScript

import { Loading } from 'react-basics';
import useApi from 'hooks/useApi';
import WebsitesTable from 'components/pages/settings/websites/WebsitesTable';
import useMessages from 'hooks/useMessages';
export default function UserWebsites({ userId }) {
const { formatMessage, messages } = useMessages();
const { get, useQuery } = useApi();
const { data, isLoading } = useQuery(['user:websites', userId], () =>
get(`/users/${userId}/websites`),
);
const hasData = data && data.length !== 0;
if (isLoading) {
return <Loading icon="dots" position="block" />;
}
return (
<div>
{hasData && <WebsitesTable data={data} />}
{!hasData && formatMessage(messages.noDataAvailable)}
</div>
);
}