mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-16 02:05:04 +01:00
Fixed error when opening user websites in the settings.
This commit is contained in:
parent
7be4d56bf7
commit
a296ecb96b
@ -1,25 +1,38 @@
|
||||
import { Loading } from 'react-basics';
|
||||
import useApi from 'hooks/useApi';
|
||||
import WebsitesTable from 'components/pages/settings/websites/WebsitesTable';
|
||||
import useMessages from 'hooks/useMessages';
|
||||
import useApiFilter from 'hooks/useApiFilter';
|
||||
import Page from 'components/layout/Page';
|
||||
import useConfig from 'hooks/useConfig';
|
||||
|
||||
export function UserWebsites({ userId }) {
|
||||
const { cloudMode } = useConfig();
|
||||
const { formatMessage, messages } = useMessages();
|
||||
const { filter, page, pageSize, handlePageSizeChange, handleFilterChange, handlePageChange } = useApiFilter();
|
||||
const { get, useQuery } = useApi();
|
||||
const { data, isLoading } = useQuery(['user:websites', userId], () =>
|
||||
get(`/users/${userId}/websites`),
|
||||
const { data, isLoading, error } = useQuery(['user:websites', userId, filter, page, pageSize], () =>
|
||||
get(`/users/${userId}/websites`, {
|
||||
filter,
|
||||
page,
|
||||
pageSize,
|
||||
}),
|
||||
);
|
||||
const hasData = data && data.length !== 0;
|
||||
|
||||
if (isLoading) {
|
||||
return <Loading icon="dots" style={{ minHeight: 300 }} />;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{hasData && <WebsitesTable data={data} />}
|
||||
<Page loading={isLoading} error={error}>
|
||||
{hasData && (
|
||||
<WebsitesTable
|
||||
data={data}
|
||||
onFilterChange={handleFilterChange}
|
||||
onPageChange={handlePageChange}
|
||||
onPageSizeChange={handlePageSizeChange}
|
||||
filterValue={filter}
|
||||
showEditButton={!cloudMode}
|
||||
/>)
|
||||
}
|
||||
{!hasData && formatMessage(messages.noDataAvailable)}
|
||||
</div>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user