mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 19:59:20 +00:00
changed contacts routes to typescript
This commit is contained in:
@@ -3,7 +3,7 @@ import User from "../../models/User";
|
||||
|
||||
interface Request {
|
||||
searchParam?: string;
|
||||
pageNumber?: number;
|
||||
pageNumber?: string;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
@@ -14,7 +14,7 @@ interface Response {
|
||||
|
||||
const ListUsersService = async ({
|
||||
searchParam = "",
|
||||
pageNumber = 1
|
||||
pageNumber = "1"
|
||||
}: Request): Promise<Response> => {
|
||||
const whereCondition = {
|
||||
[Op.or]: [
|
||||
@@ -28,8 +28,8 @@ const ListUsersService = async ({
|
||||
{ email: { [Op.like]: `%${searchParam.toLowerCase()}%` } }
|
||||
]
|
||||
};
|
||||
const limit = 20;
|
||||
const offset = limit * (pageNumber - 1);
|
||||
const limit = 10;
|
||||
const offset = limit * (+pageNumber - 1);
|
||||
|
||||
const { count, rows: users } = await User.findAndCountAll({
|
||||
where: whereCondition,
|
||||
@@ -39,7 +39,7 @@ const ListUsersService = async ({
|
||||
order: [["createdAt", "DESC"]]
|
||||
});
|
||||
|
||||
const hasMore = count > limit + users.length;
|
||||
const hasMore = count > offset + users.length;
|
||||
|
||||
return {
|
||||
users,
|
||||
|
||||
Reference in New Issue
Block a user