feat: admin ui for managing instance

This commit is contained in:
pit
2023-09-21 12:43:36 +01:00
committed by Mythie
parent 1db0d2eae6
commit 32b41386e5
5 changed files with 220 additions and 3 deletions

View File

@ -0,0 +1,37 @@
import { prisma } from '@documenso/prisma';
type getAllUsersProps = {
page: number;
perPage: number;
};
export const findUsers = async ({ page = 1, perPage = 10 }: getAllUsersProps) => {
const [users, count] = await Promise.all([
await prisma.user.findMany({
select: {
id: true,
name: true,
email: true,
roles: true,
Subscription: {
select: {
id: true,
status: true,
planId: true,
priceId: true,
createdAt: true,
periodEnd: true,
},
},
},
skip: Math.max(page - 1, 0) * perPage,
take: perPage,
}),
await prisma.user.count(),
]);
return {
users,
totalPages: Math.ceil(count / perPage),
};
};