mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-16 02:05:04 +01:00
Merge branch 'dev' into bugfix/user-website-error
This commit is contained in:
commit
907253926e
@ -2,15 +2,13 @@ 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 { filter, page, pageSize, handleFilterChange, handlePageChange, handlePageSizeChange } =
|
||||
useApiFilter();
|
||||
const { get, useQuery } = useApi();
|
||||
const { data, isLoading, error } = useQuery(['user:websites', userId, filter, page, pageSize], () =>
|
||||
const { data, isLoading } = useQuery(['user:websites', userId, filter, page, pageSize], () =>
|
||||
get(`/users/${userId}/websites`, {
|
||||
filter,
|
||||
page,
|
||||
@ -20,7 +18,7 @@ export function UserWebsites({ userId }) {
|
||||
const hasData = data && data.length !== 0;
|
||||
|
||||
return (
|
||||
<Page loading={isLoading} error={error}>
|
||||
<div>
|
||||
{hasData && (
|
||||
<WebsitesTable
|
||||
data={data}
|
||||
@ -28,11 +26,10 @@ export function UserWebsites({ userId }) {
|
||||
onPageChange={handlePageChange}
|
||||
onPageSizeChange={handlePageSizeChange}
|
||||
filterValue={filter}
|
||||
showEditButton={!cloudMode}
|
||||
/>)
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{!hasData && formatMessage(messages.noDataAvailable)}
|
||||
</Page>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,9 @@ function getPageFilters(filters: SearchFilter<any>): [
|
||||
orderBy: string;
|
||||
},
|
||||
] {
|
||||
const { pageSize = 10, page = 1, orderBy } = filters;
|
||||
const pageSize = filters?.pageSize || 10;
|
||||
const page = filters?.page || 1;
|
||||
const orderBy = filters?.orderBy;
|
||||
|
||||
return [
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ export async function getUserByUsername(username: string, options: GetUserOption
|
||||
}
|
||||
|
||||
export async function getUsers(
|
||||
UserSearchFilter: UserSearchFilter = {},
|
||||
UserSearchFilter: UserSearchFilter,
|
||||
options?: { include?: Prisma.UserInclude },
|
||||
): Promise<FilterResult<User[]>> {
|
||||
const { teamId, filter, filterType = USER_FILTER_TYPES.all } = UserSearchFilter;
|
||||
@ -72,13 +72,21 @@ export async function getUsers(
|
||||
...UserSearchFilter,
|
||||
});
|
||||
|
||||
const users = await prisma.client.user.findMany({
|
||||
const users = await prisma.client.user
|
||||
.findMany({
|
||||
where: {
|
||||
...where,
|
||||
deletedAt: null,
|
||||
},
|
||||
...pageFilters,
|
||||
...(options?.include && { include: options.include }),
|
||||
})
|
||||
.then(a => {
|
||||
return a.map(a => {
|
||||
const { password, ...rest } = a;
|
||||
|
||||
return rest;
|
||||
});
|
||||
});
|
||||
const count = await prisma.client.user.count({
|
||||
where: {
|
||||
|
Loading…
Reference in New Issue
Block a user