* fix: load more users on table scroll Signed-off-by: Chayan Das <daschayan8837@gmail.com> * refactor: move user listing logic to UserRepository Add a dedicated listUsers method with search and cursor pagination support. Add repository tests covering filtering and pagination. Ensure user listing metadata remains consistent with the returned results. Signed-off-by: Chayan Das <daschayan8837@gmail.com> --------- Signed-off-by: Chayan Das <daschayan8837@gmail.com>
33 lines
722 B
TypeScript
33 lines
722 B
TypeScript
import { getUserRepository } from "@calcom/features/di/containers/UserRepository";
|
|
|
|
import type { TrpcSessionUser } from "../../../types";
|
|
import type { TListMembersSchema } from "./listPaginated.schema";
|
|
|
|
type GetOptions = {
|
|
ctx: {
|
|
user: NonNullable<TrpcSessionUser>;
|
|
};
|
|
input: TListMembersSchema;
|
|
};
|
|
const listPaginatedHandler = async ({ input }: GetOptions) => {
|
|
const userRepository = getUserRepository();
|
|
|
|
const { cursor, limit, searchTerm } = input;
|
|
|
|
const { users, total, nextCursor } = await userRepository.listUsers({
|
|
searchTerm,
|
|
limit,
|
|
cursor
|
|
})
|
|
|
|
return {
|
|
rows: users,
|
|
nextCursor,
|
|
meta: {
|
|
totalRowCount: total
|
|
}
|
|
};
|
|
};
|
|
|
|
export default listPaginatedHandler;
|