mirror of
https://github.com/hanzoai/calendar.git
synced 2026-09-24 22:42:24 +00:00
* fix: load more users on table scroll Signed-off-by: Chayan Das <[email protected]> * 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 <[email protected]> --------- Signed-off-by: Chayan Das <[email protected]>
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;
|