Compare commits
No commits in common. "a215831b076d33ab2a6141bd545aedf970934c9d" and "d6ec5972a5a5aa856b2d40567dc1dc0feb19581c" have entirely different histories.
a215831b07
...
d6ec5972a5
|
@ -71,9 +71,9 @@ export const listQueues = async (
|
||||||
};
|
};
|
||||||
|
|
||||||
export const store = async (req: Request, res: Response): Promise<Response> => {
|
export const store = async (req: Request, res: Response): Promise<Response> => {
|
||||||
const { name, color, greetingMessage, cc } = req.body;
|
const { name, color, greetingMessage } = req.body;
|
||||||
|
|
||||||
const queue = await CreateQueueService({ name, color, greetingMessage, cc });
|
const queue = await CreateQueueService({ name, color, greetingMessage });
|
||||||
|
|
||||||
const io = getIO();
|
const io = getIO();
|
||||||
io.emit("queue", {
|
io.emit("queue", {
|
||||||
|
|
|
@ -77,7 +77,6 @@ import { botSendMessage } from "../services/WbotServices/wbotMessageListener";
|
||||||
import WhatsappQueue from "../models/WhatsappQueue";
|
import WhatsappQueue from "../models/WhatsappQueue";
|
||||||
import { get } from "../helpers/RedisClient";
|
import { get } from "../helpers/RedisClient";
|
||||||
import CountStatusChatEndService from "../services/StatusChatEndService/CountStatusChatEndService";
|
import CountStatusChatEndService from "../services/StatusChatEndService/CountStatusChatEndService";
|
||||||
import Queue from "../models/Queue";
|
|
||||||
|
|
||||||
export const index = async (req: Request, res: Response): Promise<Response> => {
|
export const index = async (req: Request, res: Response): Promise<Response> => {
|
||||||
const {
|
const {
|
||||||
|
@ -120,15 +119,14 @@ export const remoteTicketCreation = async (
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response
|
res: Response
|
||||||
): Promise<Response> => {
|
): Promise<Response> => {
|
||||||
let { queueId, contact_from, cc, contact_to, msg, contact_name }: any =
|
let { queueId, contact_from, contact_to, msg, contact_name }: any = req.body;
|
||||||
req.body;
|
|
||||||
|
|
||||||
let whatsappId: any;
|
let whatsappId: any;
|
||||||
|
|
||||||
if (!queueId && !contact_from && !cc) {
|
if (!queueId && !contact_from) {
|
||||||
return res.status(400).json({
|
return res
|
||||||
error: `Property 'queueId' or 'contact_from' or 'cc' is required.`
|
.status(400)
|
||||||
});
|
.json({ error: `Property 'queueId' or 'contact_from' is required.` });
|
||||||
}
|
}
|
||||||
|
|
||||||
const validate = ["contact_to", "msg"];
|
const validate = ["contact_to", "msg"];
|
||||||
|
@ -184,25 +182,6 @@ export const remoteTicketCreation = async (
|
||||||
|
|
||||||
queueId = queues[0].id;
|
queueId = queues[0].id;
|
||||||
whatsappId = 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);
|
// const validNumber = await CheckIsValidContact(contact_to, true);
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
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,9 +36,6 @@ class Queue extends Model<Queue> {
|
||||||
@Column
|
@Column
|
||||||
greetingMessage: string;
|
greetingMessage: string;
|
||||||
|
|
||||||
@Column
|
|
||||||
cc: string;
|
|
||||||
|
|
||||||
@CreatedAt
|
@CreatedAt
|
||||||
createdAt: Date;
|
createdAt: Date;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ interface QueueData {
|
||||||
name: string;
|
name: string;
|
||||||
color: string;
|
color: string;
|
||||||
greetingMessage?: string;
|
greetingMessage?: string;
|
||||||
cc?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const CreateQueueService = async (queueData: QueueData): Promise<Queue> => {
|
const CreateQueueService = async (queueData: QueueData): Promise<Queue> => {
|
||||||
|
|
|
@ -3,13 +3,12 @@ import * as Yup from "yup";
|
||||||
import AppError from "../../errors/AppError";
|
import AppError from "../../errors/AppError";
|
||||||
import Queue from "../../models/Queue";
|
import Queue from "../../models/Queue";
|
||||||
import ShowQueueService from "./ShowQueueService";
|
import ShowQueueService from "./ShowQueueService";
|
||||||
import { set } from "../../helpers/RedisClient";
|
import { set } from "../../helpers/RedisClient"
|
||||||
|
|
||||||
interface QueueData {
|
interface QueueData {
|
||||||
name?: string;
|
name?: string;
|
||||||
color?: string;
|
color?: string;
|
||||||
greetingMessage?: string;
|
greetingMessage?: string;
|
||||||
cc?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const UpdateQueueService = async (
|
const UpdateQueueService = async (
|
||||||
|
|
|
@ -10,7 +10,7 @@ const ListWhatsAppsForQueueService = async (
|
||||||
queueId: number | string,
|
queueId: number | string,
|
||||||
status?: string
|
status?: string
|
||||||
): Promise<any> => {
|
): Promise<any> => {
|
||||||
let distinctWhatsapps: any[] = [];
|
let distinctWhatsapps: any;
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
distinctWhatsapps = await sequelize.query(
|
distinctWhatsapps = await sequelize.query(
|
||||||
|
|
|
@ -70,7 +70,6 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
||||||
name: "",
|
name: "",
|
||||||
color: "",
|
color: "",
|
||||||
greetingMessage: "",
|
greetingMessage: "",
|
||||||
cc:""
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const [colorPickerModalOpen, setColorPickerModalOpen] = useState(false);
|
const [colorPickerModalOpen, setColorPickerModalOpen] = useState(false);
|
||||||
|
@ -95,7 +94,6 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
||||||
name: "",
|
name: "",
|
||||||
color: "",
|
color: "",
|
||||||
greetingMessage: "",
|
greetingMessage: "",
|
||||||
cc: ""
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}, [queueId, open]);
|
}, [queueId, open]);
|
||||||
|
@ -215,19 +213,6 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
||||||
margin="dense"
|
margin="dense"
|
||||||
/>
|
/>
|
||||||
</div>
|
</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>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button
|
<Button
|
||||||
|
|
Loading…
Reference in New Issue