umami/components/pages/settings/users/UserWebsites.js

25 lines
737 B
JavaScript
Raw Normal View History

2023-01-25 16:42:46 +01:00
import { Loading } from 'react-basics';
import useApi from 'hooks/useApi';
import WebsitesTable from 'components/pages/settings/websites/WebsitesTable';
2023-03-22 22:05:55 +01:00
import useMessages from 'hooks/useMessages';
2023-01-25 16:42:46 +01:00
export default function UserWebsites({ userId }) {
2023-03-22 22:05:55 +01:00
const { formatMessage, messages } = useMessages();
2023-01-25 16:42:46 +01:00
const { get, useQuery } = useApi();
2023-02-02 03:39:54 +01:00
const { data, isLoading } = useQuery(['user:websites', userId], () =>
2023-01-25 16:42:46 +01:00
get(`/users/${userId}/websites`),
);
const hasData = data && data.length !== 0;
if (isLoading) {
2023-04-13 02:43:08 +02:00
return <Loading icon="dots" style={{ minHeight: 300 }} />;
2023-01-25 16:42:46 +01:00
}
return (
<div>
{hasData && <WebsitesTable data={data} />}
{!hasData && formatMessage(messages.noDataAvailable)}
2023-01-25 16:42:46 +01:00
</div>
);
}