Compare commits
2 Commits
d6ec5972a5
...
a215831b07
Author | SHA1 | Date |
---|---|---|
adriano | a215831b07 | |
adriano | 5eac253549 |
|
@ -71,9 +71,9 @@ export const listQueues = async (
|
|||
};
|
||||
|
||||
export const store = async (req: Request, res: Response): Promise<Response> => {
|
||||
const { name, color, greetingMessage } = req.body;
|
||||
const { name, color, greetingMessage, cc } = req.body;
|
||||
|
||||
const queue = await CreateQueueService({ name, color, greetingMessage });
|
||||
const queue = await CreateQueueService({ name, color, greetingMessage, cc });
|
||||
|
||||
const io = getIO();
|
||||
io.emit("queue", {
|
||||
|
|
|
@ -77,6 +77,7 @@ import { botSendMessage } from "../services/WbotServices/wbotMessageListener";
|
|||
import WhatsappQueue from "../models/WhatsappQueue";
|
||||
import { get } from "../helpers/RedisClient";
|
||||
import CountStatusChatEndService from "../services/StatusChatEndService/CountStatusChatEndService";
|
||||
import Queue from "../models/Queue";
|
||||
|
||||
export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||
const {
|
||||
|
@ -119,14 +120,15 @@ export const remoteTicketCreation = async (
|
|||
req: Request,
|
||||
res: Response
|
||||
): Promise<Response> => {
|
||||
let { queueId, contact_from, contact_to, msg, contact_name }: any = req.body;
|
||||
let { queueId, contact_from, cc, contact_to, msg, contact_name }: any =
|
||||
req.body;
|
||||
|
||||
let whatsappId: any;
|
||||
|
||||
if (!queueId && !contact_from) {
|
||||
return res
|
||||
.status(400)
|
||||
.json({ error: `Property 'queueId' or 'contact_from' is required.` });
|
||||
if (!queueId && !contact_from && !cc) {
|
||||
return res.status(400).json({
|
||||
error: `Property 'queueId' or 'contact_from' or 'cc' is required.`
|
||||
});
|
||||
}
|
||||
|
||||
const validate = ["contact_to", "msg"];
|
||||
|
@ -182,6 +184,25 @@ export const remoteTicketCreation = async (
|
|||
|
||||
queueId = queues[0].id;
|
||||
whatsappId = id;
|
||||
} else if (cc) {
|
||||
const queue = await Queue.findOne({ where: { cc } });
|
||||
if (!queue) {
|
||||
return res.status(404).json({
|
||||
msg: `Queue with cc ${cc} not found! `
|
||||
});
|
||||
}
|
||||
|
||||
queueId = queue.id;
|
||||
|
||||
const whatsapps = await ListWhatsAppsForQueueService(queueId, "CONNECTED");
|
||||
|
||||
if ( whatsapps.length === 0) {
|
||||
return res.status(500).json({
|
||||
msg: `No WhatsApp found for this cc ${cc} or the WhatsApp number is disconnected! `
|
||||
});
|
||||
}
|
||||
|
||||
whatsappId = whatsapps[0].id;
|
||||
}
|
||||
|
||||
// const validNumber = await CheckIsValidContact(contact_to, true);
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
import { QueryInterface, DataTypes } from "sequelize";
|
||||
|
||||
module.exports = {
|
||||
up: (queryInterface: QueryInterface) => {
|
||||
return queryInterface.addColumn("Queues", "cc", {
|
||||
type: DataTypes.STRING,
|
||||
allowNull: true
|
||||
});
|
||||
},
|
||||
|
||||
down: (queryInterface: QueryInterface) => {
|
||||
return queryInterface.removeColumn("Queues", "cc");
|
||||
}
|
||||
};
|
|
@ -36,6 +36,9 @@ class Queue extends Model<Queue> {
|
|||
@Column
|
||||
greetingMessage: string;
|
||||
|
||||
@Column
|
||||
cc: string;
|
||||
|
||||
@CreatedAt
|
||||
createdAt: Date;
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ interface QueueData {
|
|||
name: string;
|
||||
color: string;
|
||||
greetingMessage?: string;
|
||||
cc?: string;
|
||||
}
|
||||
|
||||
const CreateQueueService = async (queueData: QueueData): Promise<Queue> => {
|
||||
|
|
|
@ -3,12 +3,13 @@ import * as Yup from "yup";
|
|||
import AppError from "../../errors/AppError";
|
||||
import Queue from "../../models/Queue";
|
||||
import ShowQueueService from "./ShowQueueService";
|
||||
import { set } from "../../helpers/RedisClient"
|
||||
import { set } from "../../helpers/RedisClient";
|
||||
|
||||
interface QueueData {
|
||||
name?: string;
|
||||
color?: string;
|
||||
greetingMessage?: string;
|
||||
cc?: string;
|
||||
}
|
||||
|
||||
const UpdateQueueService = async (
|
||||
|
|
|
@ -10,7 +10,7 @@ const ListWhatsAppsForQueueService = async (
|
|||
queueId: number | string,
|
||||
status?: string
|
||||
): Promise<any> => {
|
||||
let distinctWhatsapps: any;
|
||||
let distinctWhatsapps: any[] = [];
|
||||
|
||||
if (status) {
|
||||
distinctWhatsapps = await sequelize.query(
|
||||
|
|
|
@ -70,6 +70,7 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
|||
name: "",
|
||||
color: "",
|
||||
greetingMessage: "",
|
||||
cc:""
|
||||
};
|
||||
|
||||
const [colorPickerModalOpen, setColorPickerModalOpen] = useState(false);
|
||||
|
@ -94,6 +95,7 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
|||
name: "",
|
||||
color: "",
|
||||
greetingMessage: "",
|
||||
cc: ""
|
||||
});
|
||||
};
|
||||
}, [queueId, open]);
|
||||
|
@ -213,6 +215,19 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
|||
margin="dense"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<Field
|
||||
as={TextField}
|
||||
label="CC"
|
||||
autoFocus
|
||||
name="cc"
|
||||
error={touched.cc && Boolean(errors.cc)}
|
||||
helperText={touched.cc && errors.cc}
|
||||
variant="outlined"
|
||||
margin="dense"
|
||||
className={classes.textField}
|
||||
/>
|
||||
</div>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
|
|
Loading…
Reference in New Issue