New admin section.
This commit is contained in:
@@ -288,6 +288,10 @@ export async function canCreateTeamWebsite({ user }: Auth, teamId: string) {
|
||||
return teamUser && hasPermission(teamUser.role, PERMISSIONS.websiteCreate);
|
||||
}
|
||||
|
||||
export async function canViewAllTeams({ user }: Auth) {
|
||||
return user.isAdmin;
|
||||
}
|
||||
|
||||
export async function canCreateUser({ user }: Auth) {
|
||||
return user.isAdmin;
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ async function pagedRawQuery(
|
||||
queryParams: Record<string, any>,
|
||||
filters: QueryFilters,
|
||||
) {
|
||||
const { page = 1, pageSize, orderBy, sortDescending = false } = filters;
|
||||
const { page = 1, pageSize, orderBy, sortDescending = false, search } = filters;
|
||||
const size = +pageSize || DEFAULT_PAGE_SIZE;
|
||||
const offset = +size * (+page - 1);
|
||||
const direction = sortDescending ? 'desc' : 'asc';
|
||||
@@ -167,7 +167,7 @@ async function pagedRawQuery(
|
||||
|
||||
const data = await rawQuery(`${query}${statements}`, queryParams);
|
||||
|
||||
return { data, count, page: +page, pageSize: size, orderBy };
|
||||
return { data, count, page: +page, pageSize: size, orderBy, search };
|
||||
}
|
||||
|
||||
async function rawQuery<T = unknown>(
|
||||
|
||||
@@ -197,7 +197,7 @@ async function rawQuery(sql: string, data: object): Promise<any> {
|
||||
}
|
||||
|
||||
async function pagedQuery<T>(model: string, criteria: T, filters?: QueryFilters) {
|
||||
const { page = 1, pageSize, orderBy, sortDescending = false } = filters || {};
|
||||
const { page = 1, pageSize, orderBy, sortDescending = false, search } = filters || {};
|
||||
const size = +pageSize || DEFAULT_PAGE_SIZE;
|
||||
|
||||
const data = await client[model].findMany({
|
||||
@@ -216,7 +216,7 @@ async function pagedQuery<T>(model: string, criteria: T, filters?: QueryFilters)
|
||||
|
||||
const count = await client[model].count({ where: (criteria as any).where });
|
||||
|
||||
return { data, count, page: +page, pageSize: size, orderBy };
|
||||
return { data, count, page: +page, pageSize: size, orderBy, search };
|
||||
}
|
||||
|
||||
async function pagedRawQuery(
|
||||
|
||||
Reference in New Issue
Block a user