diff --git a/components/pages/settings/users/UserWebsites.js b/components/pages/settings/users/UserWebsites.js index 8189ad8d..709f6e4d 100644 --- a/components/pages/settings/users/UserWebsites.js +++ b/components/pages/settings/users/UserWebsites.js @@ -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,19 +18,18 @@ export function UserWebsites({ userId }) { const hasData = data && data.length !== 0; return ( - +
{hasData && ( - ) - } + /> + )} {!hasData && formatMessage(messages.noDataAvailable)} - +
); } diff --git a/lib/prisma.ts b/lib/prisma.ts index 12bafa51..8fa7e8ae 100644 --- a/lib/prisma.ts +++ b/lib/prisma.ts @@ -185,7 +185,9 @@ function getPageFilters(filters: SearchFilter): [ orderBy: string; }, ] { - const { pageSize = 10, page = 1, orderBy } = filters; + const pageSize = filters?.pageSize || 10; + const page = filters?.page || 1; + const orderBy = filters?.orderBy; return [ { diff --git a/queries/admin/user.ts b/queries/admin/user.ts index dfb923f3..ca459b9f 100644 --- a/queries/admin/user.ts +++ b/queries/admin/user.ts @@ -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> { const { teamId, filter, filterType = USER_FILTER_TYPES.all } = UserSearchFilter; @@ -72,14 +72,22 @@ export async function getUsers( ...UserSearchFilter, }); - const users = await prisma.client.user.findMany({ - where: { - ...where, - deletedAt: null, - }, - ...pageFilters, - ...(options?.include && { include: options.include }), - }); + 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: { ...where,