Compare commits
No commits in common. "5bfaa7f733c243b71bb8665a9689bf40e5a6f143" and "bc134c827cccb22ad5e3546549b0e26e42fcb992" have entirely different histories.
5bfaa7f733
...
bc134c827c
|
@ -93,7 +93,7 @@ export const store = async (req: Request, res: Response): Promise<Response> => {
|
||||||
number: Yup.string()
|
number: Yup.string()
|
||||||
.required()
|
.required()
|
||||||
.matches(/^\d+$/, "Invalid number format. Only numbers is allowed.")
|
.matches(/^\d+$/, "Invalid number format. Only numbers is allowed.")
|
||||||
// .matches(/^55\d+$/, "The number must start with 55.")
|
.matches(/^55\d+$/, "The number must start with 55.")
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -102,8 +102,6 @@ export const store = async (req: Request, res: Response): Promise<Response> => {
|
||||||
throw new AppError(err.message);
|
throw new AppError(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
newContact.number = addStartPhoneNumber(newContact.number);
|
|
||||||
|
|
||||||
const validNumber = await CheckIsValidContact(newContact.number);
|
const validNumber = await CheckIsValidContact(newContact.number);
|
||||||
|
|
||||||
// const validNumber: any = await CheckContactNumber(newContact.number)
|
// const validNumber: any = await CheckContactNumber(newContact.number)
|
||||||
|
@ -159,11 +157,9 @@ export const update = async (
|
||||||
|
|
||||||
const schema = Yup.object().shape({
|
const schema = Yup.object().shape({
|
||||||
name: Yup.string(),
|
name: Yup.string(),
|
||||||
number: Yup.string().matches(
|
number: Yup.string()
|
||||||
/^\d+$/,
|
.matches(/^\d+$/, "Invalid number format. Only numbers is allowed.")
|
||||||
"Invalid number format. Only numbers is allowed."
|
.matches(/^55\d+$/, "The number must start with 55.")
|
||||||
)
|
|
||||||
// .matches(/^55\d+$/, "The number must start with 55.")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -172,8 +168,6 @@ export const update = async (
|
||||||
throw new AppError(err.message);
|
throw new AppError(err.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
contactData.number = addStartPhoneNumber(contactData.number);
|
|
||||||
|
|
||||||
await CheckIsValidContact(contactData.number);
|
await CheckIsValidContact(contactData.number);
|
||||||
|
|
||||||
const { contactId } = req.params;
|
const { contactId } = req.params;
|
||||||
|
@ -239,13 +233,3 @@ export const contacsBulkInsertOnQueue = async (
|
||||||
|
|
||||||
return res.status(200).json({ message: "ok" });
|
return res.status(200).json({ message: "ok" });
|
||||||
};
|
};
|
||||||
|
|
||||||
function addStartPhoneNumber(phoneNumber: string) {
|
|
||||||
const regex = /^55/;
|
|
||||||
|
|
||||||
if (!regex.test(phoneNumber)) {
|
|
||||||
phoneNumber = "55" + phoneNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
return phoneNumber;
|
|
||||||
}
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ export const reportUserService = async (req: Request, res: Response): Promise<Re
|
||||||
|
|
||||||
// let usersProfile = await ListUserParamiterService({ profile: 'user' })
|
// let usersProfile = await ListUserParamiterService({ profile: 'user' })
|
||||||
let usersProfile = await ListUserParamiterService({
|
let usersProfile = await ListUserParamiterService({
|
||||||
profiles: ["user", "supervisor"],
|
profile: "user",
|
||||||
raw: true
|
raw: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2,17 +2,15 @@ import { Op, Sequelize } from "sequelize";
|
||||||
import Queue from "../../models/Queue";
|
import Queue from "../../models/Queue";
|
||||||
import User from "../../models/User";
|
import User from "../../models/User";
|
||||||
import UserQueue from "../../models/UserQueue";
|
import UserQueue from "../../models/UserQueue";
|
||||||
import { List } from "whatsapp-web.js"
|
|
||||||
|
|
||||||
interface Request {
|
interface Request {
|
||||||
userId?: string | number;
|
userId?: string | number;
|
||||||
profile?: string;
|
profile?: string;
|
||||||
profiles?: Array<string>;
|
|
||||||
raw?: boolean;
|
raw?: boolean;
|
||||||
userIds?: string | number;
|
userIds?: string | number
|
||||||
}
|
}
|
||||||
|
|
||||||
const ListUser = async ({ profile, userId, raw, userIds, profiles }: Request): Promise<User[]> => {
|
const ListUser = async ({ profile, userId, raw, userIds }: Request): Promise<User[]> => {
|
||||||
let where_clause = {};
|
let where_clause = {};
|
||||||
|
|
||||||
if (userId && profile) {
|
if (userId && profile) {
|
||||||
|
@ -31,10 +29,6 @@ const ListUser = async ({ profile, userId, raw, userIds, profiles }: Request): P
|
||||||
where_clause = {
|
where_clause = {
|
||||||
id: { [Op.in]: userIds }
|
id: { [Op.in]: userIds }
|
||||||
};
|
};
|
||||||
} else if (profiles) {
|
|
||||||
where_clause = {
|
|
||||||
profile: { [Op.in]: profiles }
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const users = await User.findAll({
|
const users = await User.findAll({
|
||||||
|
@ -46,8 +40,7 @@ const ListUser = async ({ profile, userId, raw, userIds, profiles }: Request): P
|
||||||
{ model: Queue, as: "queues", attributes: ["id", "name", "color"] }
|
{ model: Queue, as: "queues", attributes: ["id", "name", "color"] }
|
||||||
],
|
],
|
||||||
|
|
||||||
order: [["id", "ASC"]],
|
order: [["id", "ASC"]]
|
||||||
group: ["User.id"]
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return users;
|
return users;
|
||||||
|
|
Loading…
Reference in New Issue