feat: added pagination to platform managed users table (#18523)
* feat: added pagination to platform managed users table * removed console * implemented feedback, removed unused components * added label * Update managed-users-view.tsx * Update managed-users-view.tsx
This commit is contained in:
1 parent
f558f8aca5
commit
f26d2998cb
14 files changed
+519
-209
No files matched your search
@@ -18,10 +18,22 @@ type GetOptions = {
|
||||
const isAllString = (array: (string | number)[]): array is string[] => {
|
||||
return array.every((value) => typeof value === "string");
|
||||
};
|
||||
function getUserConditions(oAuthClientId?: string) {
|
||||
if (!!oAuthClientId) {
|
||||
return {
|
||||
platformOAuthClients: {
|
||||
some: { id: oAuthClientId },
|
||||
},
|
||||
isPlatformManaged: true,
|
||||
};
|
||||
}
|
||||
return { isPlatformManaged: false };
|
||||
}
|
||||
|
||||
export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
const organizationId = ctx.user.organizationId ?? ctx.user.profiles[0].organizationId;
|
||||
const searchTerm = input.searchTerm;
|
||||
const oAuthClientId = input.oAuthClientId;
|
||||
const expand = input.expand;
|
||||
const filters = input.filters || [];
|
||||
|
||||
@@ -66,13 +78,16 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
|
||||
const getTotalMembers = await prisma.membership.count({
|
||||
where: {
|
||||
user: {
|
||||
...getUserConditions(oAuthClientId),
|
||||
},
|
||||
teamId: organizationId,
|
||||
},
|
||||
});
|
||||
|
||||
let whereClause: Prisma.MembershipWhereInput = {
|
||||
user: {
|
||||
isPlatformManaged: false,
|
||||
...getUserConditions(oAuthClientId),
|
||||
},
|
||||
teamId: organizationId,
|
||||
...(searchTerm && {
|
||||
|
||||
@@ -15,6 +15,7 @@ export const ZListMembersSchema = z.object({
|
||||
searchTerm: z.string().optional(),
|
||||
expand: z.array(expandableColumns).optional(),
|
||||
filters: z.array(ZListMembersFilter).optional(),
|
||||
oAuthClientId: z.string().optional(),
|
||||
});
|
||||
|
||||
export type TListMembersSchema = z.infer<typeof ZListMembersSchema>;
|
||||
Reference in new issue
Block a user