Compare commits
No commits in common. "0a031bd9a8a0ee493747b4dc939c7bea0273c353" and "dc44dccd827dfc00071123e52172b7ff9ea609ee" have entirely different histories.
0a031bd9a8
...
dc44dccd82
|
@ -17,7 +17,6 @@
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@sentry/node": "^5.29.2",
|
"@sentry/node": "^5.29.2",
|
||||||
"@socket.io/redis-adapter": "^7.2.0",
|
|
||||||
"@types/fluent-ffmpeg": "^2.1.21",
|
"@types/fluent-ffmpeg": "^2.1.21",
|
||||||
"@types/pino": "^6.3.4",
|
"@types/pino": "^6.3.4",
|
||||||
"axios": "^1.2.3",
|
"axios": "^1.2.3",
|
||||||
|
@ -42,20 +41,18 @@
|
||||||
"pino": "^6.9.0",
|
"pino": "^6.9.0",
|
||||||
"pino-pretty": "^9.1.1",
|
"pino-pretty": "^9.1.1",
|
||||||
"qrcode-terminal": "^0.12.0",
|
"qrcode-terminal": "^0.12.0",
|
||||||
"redis": "^4.6.13",
|
|
||||||
"reflect-metadata": "^0.1.13",
|
"reflect-metadata": "^0.1.13",
|
||||||
"sequelize": "^5.22.3",
|
"sequelize": "^5.22.3",
|
||||||
"sequelize-cli": "^5.5.1",
|
"sequelize-cli": "^5.5.1",
|
||||||
"sequelize-typescript": "^1.1.0",
|
"sequelize-typescript": "^1.1.0",
|
||||||
"sharp": "^0.32.5",
|
"sharp": "^0.32.5",
|
||||||
"socket.io": "^4.7.5",
|
"socket.io": "^3.0.5",
|
||||||
"socket.io-client": "^4.5.4",
|
"socket.io-client": "^4.5.4",
|
||||||
"uuid": "^8.3.2",
|
"uuid": "^8.3.2",
|
||||||
"whatsapp-web.js": "github:pedroslopez/whatsapp-web.js",
|
"whatsapp-web.js": "github:pedroslopez/whatsapp-web.js",
|
||||||
"yup": "^0.32.8"
|
"yup": "^0.32.8"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/lodash": "4.14",
|
|
||||||
"@types/bcryptjs": "^2.4.2",
|
"@types/bcryptjs": "^2.4.2",
|
||||||
"@types/bluebird": "^3.5.32",
|
"@types/bluebird": "^3.5.32",
|
||||||
"@types/cookie-parser": "^1.4.2",
|
"@types/cookie-parser": "^1.4.2",
|
||||||
|
|
|
@ -3,9 +3,6 @@ import { Server } from "http";
|
||||||
import AppError from "../errors/AppError";
|
import AppError from "../errors/AppError";
|
||||||
import { logger } from "../utils/logger";
|
import { logger } from "../utils/logger";
|
||||||
|
|
||||||
import { createAdapter } from "@socket.io/redis-adapter";
|
|
||||||
import { createClient } from 'redis';
|
|
||||||
|
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import ListUserParamiterService from "../services/UserServices/ListUserParamiterService";
|
import ListUserParamiterService from "../services/UserServices/ListUserParamiterService";
|
||||||
import {
|
import {
|
||||||
|
@ -30,7 +27,6 @@ import {
|
||||||
} from "../services/WbotServices/wbotMessageListener";
|
} from "../services/WbotServices/wbotMessageListener";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import Whatsapp from "../models/Whatsapp";
|
import Whatsapp from "../models/Whatsapp";
|
||||||
import { get } from "../helpers/RedisClient"
|
|
||||||
|
|
||||||
let count: number = 0;
|
let count: number = 0;
|
||||||
let listOnline: any[] = [];
|
let listOnline: any[] = [];
|
||||||
|
@ -46,30 +42,14 @@ let dateTime = splitDateTime(
|
||||||
new Date(format(new Date(), "yyyy-MM-dd HH:mm:ss", { locale: ptBR }))
|
new Date(format(new Date(), "yyyy-MM-dd HH:mm:ss", { locale: ptBR }))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
const pubClient = createClient({ url: 'redis://172.31.187.29:6379' });
|
|
||||||
const subClient = pubClient.duplicate();
|
|
||||||
|
|
||||||
|
|
||||||
pubClient.connect().catch(console.error);
|
|
||||||
subClient.connect().catch(console.error);
|
|
||||||
|
|
||||||
|
|
||||||
export const initIO = (httpServer: Server): SocketIO => {
|
export const initIO = (httpServer: Server): SocketIO => {
|
||||||
|
|
||||||
io = new SocketIO(httpServer, {
|
io = new SocketIO(httpServer, {
|
||||||
cors: {
|
cors: {
|
||||||
origin: process.env.FRONTEND_URL,
|
origin: process.env.FRONTEND_URL
|
||||||
//allowedHeaders: ["my-custom-header"],
|
|
||||||
//credentials: true
|
|
||||||
},
|
},
|
||||||
maxHttpBufferSize: 1e8,
|
maxHttpBufferSize: 1e8
|
||||||
// pingInterval: 25000,
|
|
||||||
// pingTimeout: 60000,
|
|
||||||
// adapter: createAdapter(pubClient, subClient)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
io.on("connection", socket => {
|
io.on("connection", socket => {
|
||||||
logger.info("Client Connected");
|
logger.info("Client Connected");
|
||||||
|
|
||||||
|
@ -127,7 +107,6 @@ export const initIO = (httpServer: Server): SocketIO => {
|
||||||
socket.on("online", (userId: any) => {
|
socket.on("online", (userId: any) => {
|
||||||
// console.log('userId: ', userId)
|
// console.log('userId: ', userId)
|
||||||
|
|
||||||
return
|
|
||||||
obj.uuid = uuidv4();
|
obj.uuid = uuidv4();
|
||||||
|
|
||||||
if (userId.logoutUserId) {
|
if (userId.logoutUserId) {
|
||||||
|
@ -254,18 +233,13 @@ export const initIO = (httpServer: Server): SocketIO => {
|
||||||
if (rooms && rooms.size == 2 && ![...rooms][1].startsWith("session_"))
|
if (rooms && rooms.size == 2 && ![...rooms][1].startsWith("session_"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let whatsappIds = await get({
|
let whatsappIds: any = await Whatsapp.findAll({
|
||||||
key: "whatsapp:*",
|
attributes: ["id"],
|
||||||
parse: true
|
raw: true
|
||||||
});
|
});
|
||||||
|
|
||||||
// let whatsappIds: any = await Whatsapp.findAll({
|
|
||||||
// attributes: ["id"],
|
|
||||||
// raw: true
|
|
||||||
// });
|
|
||||||
|
|
||||||
if (whatsappIds && whatsappIds.length > 0) {
|
if (whatsappIds && whatsappIds.length > 0) {
|
||||||
// whatsappIds = whatsappIds.map((e: any) => `${e.id}`);
|
whatsappIds = whatsappIds.map((e: any) => `${e.id}`);
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
"whatsappIds whatsappIds whatsappIds whatsappIds whatsappIds: ",
|
"whatsappIds whatsappIds whatsappIds whatsappIds whatsappIds: ",
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
"yup": "^0.32.8"
|
"yup": "^0.32.8"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "PORT=3331 react-scripts start",
|
"start": "react-scripts start",
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"test": "react-scripts test",
|
"test": "react-scripts test",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
import React, { useContext, useState, useEffect, useReducer, useRef } from "react"
|
import React, { useContext, useState, useEffect, useReducer, useRef } from "react"
|
||||||
|
|
||||||
import { isSameDay, parseISO, format } from "date-fns"
|
import { isSameDay, parseISO, format } from "date-fns"
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
import clsx from "clsx"
|
import clsx from "clsx"
|
||||||
import { AuthContext } from "../../context/Auth/AuthContext"
|
import { AuthContext } from "../../context/Auth/AuthContext"
|
||||||
|
|
||||||
|
@ -36,7 +34,7 @@ import whatsBackground from "../../assets/wa-background.png"
|
||||||
|
|
||||||
import api from "../../services/api"
|
import api from "../../services/api"
|
||||||
import toastError from "../../errors/toastError"
|
import toastError from "../../errors/toastError"
|
||||||
import { countTicketMsgContext } from "../../context/CountTicketMsgProvider/CountTicketMsgProvider"
|
import { countTicketMsgContext } from "../../context/CountTicketMsgProvider/CountTicketMsgProvider"
|
||||||
|
|
||||||
const useStyles = makeStyles((theme) => ({
|
const useStyles = makeStyles((theme) => ({
|
||||||
messagesListWrapper: {
|
messagesListWrapper: {
|
||||||
|
@ -440,18 +438,11 @@ const MessagesList = ({ ticketId, isGroup }) => {
|
||||||
}, [pageNumber, ticketId])
|
}, [pageNumber, ticketId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onConnectMessagesList = () => {
|
socket.on("connect", () => socket.emit("joinChatBox", ticketId))
|
||||||
socket.emit("joinChatBox", ticketId)
|
|
||||||
}
|
|
||||||
|
|
||||||
onConnectMessagesList()
|
socket.on("appMessage", (data) => {
|
||||||
|
|
||||||
socket.on("connect", onConnectMessagesList)
|
|
||||||
|
|
||||||
const onAppMessageMessagesList = (data) => {
|
|
||||||
if (+data.message.ticketId !== +ticketId) return
|
|
||||||
|
|
||||||
if (data.action === "create") {
|
if (data.action === "create") {
|
||||||
|
|
||||||
|
@ -463,14 +454,10 @@ const MessagesList = ({ ticketId, isGroup }) => {
|
||||||
if (data.action === "update") {
|
if (data.action === "update") {
|
||||||
dispatch({ type: "UPDATE_MESSAGE", payload: data.message })
|
dispatch({ type: "UPDATE_MESSAGE", payload: data.message })
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("appMessage", onAppMessageMessagesList)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.emit("leaveChatBox", ticketId)
|
socket.disconnect()
|
||||||
socket.off("connect", onConnectMessagesList)
|
|
||||||
socket.off("appMessage", onAppMessageMessagesList)
|
|
||||||
}
|
}
|
||||||
}, [ticketId])
|
}, [ticketId])
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@ import React, { useState, useRef, useEffect, useContext } from "react"
|
||||||
|
|
||||||
import { useHistory } from "react-router-dom"
|
import { useHistory } from "react-router-dom"
|
||||||
import { format } from "date-fns"
|
import { format } from "date-fns"
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
import useSound from "use-sound"
|
import useSound from "use-sound"
|
||||||
|
|
||||||
import Popover from "@material-ui/core/Popover"
|
import Popover from "@material-ui/core/Popover"
|
||||||
|
@ -116,24 +115,24 @@ const NotificationsPopOver = () => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchSession = async () => {
|
const fetchSession = async () => {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.get('/settings')
|
const { data } = await api.get('/settings')
|
||||||
setSettings(data.settings)
|
setSettings(data.settings)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toastError(err)
|
toastError(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fetchSession()
|
fetchSession()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const getSettingValue = (key) => {
|
const getSettingValue = (key) => {
|
||||||
const { value } = settings.find((s) => s.key === key)
|
const { value } = settings.find((s) => s.key === key)
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
socket.on("reload_page", (data) => {
|
socket.on("reload_page", (data) => {
|
||||||
|
|
||||||
|
@ -194,8 +193,7 @@ const NotificationsPopOver = () => {
|
||||||
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.removeAllListeners('reload_page');
|
socket.disconnect()
|
||||||
socket.removeAllListeners('onlineStatus');
|
|
||||||
}
|
}
|
||||||
}, [user.id, handleLogout, user.profile])
|
}, [user.id, handleLogout, user.profile])
|
||||||
|
|
||||||
|
@ -203,17 +201,12 @@ const NotificationsPopOver = () => {
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onConnectNotifications = () => {
|
socket.on("connect", () => socket.emit("joinNotification"))
|
||||||
socket.emit("joinNotification")
|
|
||||||
}
|
|
||||||
|
|
||||||
onConnectNotifications()
|
|
||||||
|
|
||||||
socket.on("connect", onConnectNotifications)
|
socket.on("ticket", data => {
|
||||||
|
|
||||||
const onTicketNotifications = data => {
|
|
||||||
if (data.action === "updateUnread" || data.action === "delete") {
|
if (data.action === "updateUnread" || data.action === "delete") {
|
||||||
|
|
||||||
|
|
||||||
|
@ -239,18 +232,25 @@ const NotificationsPopOver = () => {
|
||||||
return prevState
|
return prevState
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
|
socket.on("appMessage", data => {
|
||||||
|
|
||||||
|
|
||||||
socket.on("ticket", onTicketNotifications)
|
|
||||||
|
|
||||||
const onAppMessageNotifications = data => {
|
|
||||||
if (
|
if (
|
||||||
data.action === "create" &&
|
data.action === "create" &&
|
||||||
!data.message.read &&
|
!data.message.read &&
|
||||||
(data.ticket.userId === user?.id || !data.ticket.userId)
|
(data.ticket.userId === user?.id || !data.ticket.userId)
|
||||||
) {
|
) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setNotifications(prevState => {
|
setNotifications(prevState => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// prevState.forEach((e)=>{
|
// prevState.forEach((e)=>{
|
||||||
//
|
//
|
||||||
// })
|
// })
|
||||||
|
@ -265,6 +265,8 @@ const NotificationsPopOver = () => {
|
||||||
return [data.ticket, ...prevState]
|
return [data.ticket, ...prevState]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const shouldNotNotificate = (data.message.ticketId === ticketIdRef.current && document.visibilityState === "visible") ||
|
const shouldNotNotificate = (data.message.ticketId === ticketIdRef.current && document.visibilityState === "visible") ||
|
||||||
(data.ticket.userId && data.ticket.userId !== user?.id) ||
|
(data.ticket.userId && data.ticket.userId !== user?.id) ||
|
||||||
data.ticket.isGroup || !data.ticket.userId
|
data.ticket.isGroup || !data.ticket.userId
|
||||||
|
@ -273,25 +275,20 @@ const NotificationsPopOver = () => {
|
||||||
|
|
||||||
handleNotifications(data)
|
handleNotifications(data)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("appMessage", onAppMessageNotifications)
|
socket.on('notifyPeding', data =>{
|
||||||
|
if(settings?.length > 0 && getSettingValue('notificationTransferQueue') === 'enabled') handleNotifications("", data);
|
||||||
socket.on('notifyPeding', data => {
|
|
||||||
if (settings?.length > 0 && getSettingValue('notificationTransferQueue') === 'enabled') handleNotifications("", data);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off('connect', onConnectNotifications);
|
socket.disconnect()
|
||||||
socket.off('ticket', onTicketNotifications);
|
|
||||||
socket.off('appMessage', onAppMessageNotifications);
|
|
||||||
socket.removeAllListeners('notifyPeding');
|
|
||||||
}
|
}
|
||||||
}, [user, settings])
|
}, [user, settings])
|
||||||
|
|
||||||
const handleNotifications = (data, notify) => {
|
const handleNotifications = (data, notify) => {
|
||||||
let isQueue = false;
|
let isQueue = false;
|
||||||
if (!notify) {
|
if(!notify){
|
||||||
const { message, contact, ticket } = data
|
const { message, contact, ticket } = data
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
|
@ -304,10 +301,10 @@ const NotificationsPopOver = () => {
|
||||||
const notification = new Notification(
|
const notification = new Notification(
|
||||||
`${i18n.t("tickets.notification.message")} ${contact.name}`,
|
`${i18n.t("tickets.notification.message")} ${contact.name}`,
|
||||||
options
|
options
|
||||||
)
|
)
|
||||||
|
|
||||||
notification.onclick = e => {
|
notification.onclick = e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
window.focus()
|
window.focus()
|
||||||
historyRef.current.push(`/tickets/${ticket.id}`)
|
historyRef.current.push(`/tickets/${ticket.id}`)
|
||||||
}
|
}
|
||||||
|
@ -322,15 +319,15 @@ const NotificationsPopOver = () => {
|
||||||
}
|
}
|
||||||
return [notification, ...prevState]
|
return [notification, ...prevState]
|
||||||
})
|
})
|
||||||
} else {
|
}else{
|
||||||
user.queues.forEach(queue => {
|
user.queues.forEach(queue =>{
|
||||||
if (queue.id === notify.data?.queue?.id) {
|
if(queue.id === notify.data?.queue?.id){
|
||||||
isQueue = true;
|
isQueue = true;
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (!isQueue) {
|
if(!isQueue){
|
||||||
return;
|
return;
|
||||||
} else {
|
}else {
|
||||||
const notification = new Notification(`${i18n.t("tickets.notification.messagePeding")} ${notify.data?.queue?.name}`);
|
const notification = new Notification(`${i18n.t("tickets.notification.messagePeding")} ${notify.data?.queue?.name}`);
|
||||||
notification.onclick = e => {
|
notification.onclick = e => {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
|
@ -3,8 +3,7 @@ import React, { useState, useEffect, useRef, useContext } from "react"
|
||||||
import * as Yup from "yup"
|
import * as Yup from "yup"
|
||||||
import { Formik, Form, Field } from "formik"
|
import { Formik, Form, Field } from "formik"
|
||||||
import { toast } from "react-toastify"
|
import { toast } from "react-toastify"
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
makeStyles,
|
makeStyles,
|
||||||
|
@ -87,9 +86,9 @@ const PositionModal = ({
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onSettingsPosition = (data) => {
|
socket.on('settings', (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSettings((prevState) => {
|
setSettings((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -98,12 +97,10 @@ const PositionModal = ({
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsPosition)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("settings", onSettingsPosition)
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
import React, { useEffect, useState, useContext } from "react";
|
import React, { useEffect, useState, useContext } from "react";
|
||||||
import QRCode from "qrcode.react";
|
import QRCode from "qrcode.react";
|
||||||
//import openSocket from "socket.io-client";
|
import openSocket from "socket.io-client";
|
||||||
import { socket } from "../../services/socket";
|
|
||||||
|
|
||||||
import toastError from "../../errors/toastError";
|
import toastError from "../../errors/toastError";
|
||||||
|
|
||||||
import { Dialog, DialogContent, Paper, Typography } from "@material-ui/core";
|
import { Dialog, DialogContent, Paper, Typography } from "@material-ui/core";
|
||||||
|
@ -33,9 +31,9 @@ const QrcodeModal = ({ open, onClose, whatsAppId }) => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!whatsAppId) return;
|
if (!whatsAppId) return;
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||||
|
|
||||||
const onWhatsAppSessionQrCode = data => {
|
socket.on("whatsappSession", data => {
|
||||||
if (data.action === "update" && data.session.id === whatsAppId) {
|
if (data.action === "update" && data.session.id === whatsAppId) {
|
||||||
setQrCode(data.session.qrcode);
|
setQrCode(data.session.qrcode);
|
||||||
}
|
}
|
||||||
|
@ -46,21 +44,19 @@ const QrcodeModal = ({ open, onClose, whatsAppId }) => {
|
||||||
|
|
||||||
if (data.action === "error") {
|
if (data.action === "error") {
|
||||||
|
|
||||||
console.log('user.profile: ', user.profile)
|
console.log('user.profile: ', user.profile)
|
||||||
|
|
||||||
if (user.profile === 'master') {
|
if(user.profile === 'master'){
|
||||||
|
|
||||||
alert(data.msg)
|
alert(data.msg)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
socket.on("whatsappSession", onWhatsAppSessionQrCode);
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("whatsappSession", onWhatsAppSessionQrCode);
|
socket.disconnect();
|
||||||
};
|
};
|
||||||
}, [whatsAppId, onClose, user.profile]);
|
}, [whatsAppId, onClose, user.profile]);
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ import { IconButton, InputAdornment } from "@material-ui/core"
|
||||||
import { Colorize } from "@material-ui/icons"
|
import { Colorize } from "@material-ui/icons"
|
||||||
|
|
||||||
import { AuthContext } from '../../context/Auth/AuthContext'
|
import { AuthContext } from '../../context/Auth/AuthContext'
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
|
|
||||||
const useStyles = makeStyles(theme => ({
|
const useStyles = makeStyles(theme => ({
|
||||||
|
@ -92,9 +92,9 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
||||||
}, [setting])
|
}, [setting])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onSettingsQueueModal = (data) => {
|
socket.on('settings', (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSettings((prevState) => {
|
setSettings((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -103,12 +103,10 @@ const QueueModal = ({ open, onClose, queueId }) => {
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsQueueModal)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("settings", onSettingsQueueModal)
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ import React, { useState, useEffect, useRef, useContext } from "react"
|
||||||
import * as Yup from "yup"
|
import * as Yup from "yup"
|
||||||
import { Formik, Form, Field } from "formik"
|
import { Formik, Form, Field } from "formik"
|
||||||
import { toast } from "react-toastify"
|
import { toast } from "react-toastify"
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
makeStyles,
|
makeStyles,
|
||||||
|
@ -101,9 +101,9 @@ const QuickAnswersModal = ({
|
||||||
}, [open,])
|
}, [open,])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onSettingsQuickAnswersModal = (data) => {
|
socket.on('settings', (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSettings((prevState) => {
|
setSettings((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -112,12 +112,10 @@ const QuickAnswersModal = ({
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsQuickAnswersModal)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("settings", onSettingsQuickAnswersModal)
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@ import React, { useState, useEffect, useRef, useContext } from "react"
|
||||||
import * as Yup from "yup"
|
import * as Yup from "yup"
|
||||||
import { Formik, Form, Field } from "formik"
|
import { Formik, Form, Field } from "formik"
|
||||||
import { toast } from "react-toastify"
|
import { toast } from "react-toastify"
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
makeStyles,
|
makeStyles,
|
||||||
|
@ -91,9 +91,9 @@ const StatusChatEndModal = ({
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onSettingsStatusChatEndModal = (data) => {
|
socket.on('settings', (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSettings((prevState) => {
|
setSettings((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -102,12 +102,10 @@ const StatusChatEndModal = ({
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsStatusChatEndModal)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("settings", onSettingsStatusChatEndModal)
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,7 @@ import React, { useState, useEffect } from "react"
|
||||||
import { useParams, useHistory } from "react-router-dom"
|
import { useParams, useHistory } from "react-router-dom"
|
||||||
|
|
||||||
import { toast } from "react-toastify"
|
import { toast } from "react-toastify"
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
import clsx from "clsx"
|
import clsx from "clsx"
|
||||||
|
|
||||||
import { Paper, makeStyles } from "@material-ui/core"
|
import { Paper, makeStyles } from "@material-ui/core"
|
||||||
|
@ -134,32 +132,22 @@ const Ticket = () => {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onConnectTicket = () => socket.emit("joinChatBox", ticketId)
|
socket.on("connect", () => socket.emit("joinChatBox", ticketId))
|
||||||
|
|
||||||
onConnectTicket()
|
|
||||||
|
|
||||||
socket.on("connect", onConnectTicket)
|
|
||||||
|
|
||||||
const onTicketTicket = (data) => {
|
|
||||||
const isSameTicket = +data?.ticket?.id === +ticketId || +data.ticketId === +ticketId
|
|
||||||
if (!isSameTicket) return
|
|
||||||
|
|
||||||
|
socket.on("ticket", (data) => {
|
||||||
if (data.action === "update") {
|
if (data.action === "update") {
|
||||||
setTicket(data.ticket)
|
setTicket(data.ticket)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.action === "deleteForever") {
|
if (data.action === "delete") {
|
||||||
console.log('delete forever')
|
|
||||||
toast.success("Ticket deleted sucessfully.")
|
toast.success("Ticket deleted sucessfully.")
|
||||||
history.push("/tickets")
|
history.push("/tickets")
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("ticket", onTicketTicket)
|
socket.on("contact", (data) => {
|
||||||
|
|
||||||
const onContactTicket = (data) => {
|
|
||||||
if (data.action === "update") {
|
if (data.action === "update") {
|
||||||
setContact((prevState) => {
|
setContact((prevState) => {
|
||||||
if (prevState.id === data.contact?.id) {
|
if (prevState.id === data.contact?.id) {
|
||||||
|
@ -168,11 +156,9 @@ const Ticket = () => {
|
||||||
return prevState
|
return prevState
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("contact", onContactTicket)
|
socket.on("remoteTickesControllIdleOpen", (data) => {
|
||||||
|
|
||||||
const onRemoteTicketsControllIdleOpenTicket = (data) => {
|
|
||||||
if (data.action === "update") {
|
if (data.action === "update") {
|
||||||
let url_ticketId
|
let url_ticketId
|
||||||
try {
|
try {
|
||||||
|
@ -189,15 +175,10 @@ const Ticket = () => {
|
||||||
console.log('error on try do the send seen: ', error)
|
console.log('error on try do the send seen: ', error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("remoteTickesControllIdleOpen", onRemoteTicketsControllIdleOpenTicket)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("connect", onConnectTicket)
|
socket.disconnect()
|
||||||
socket.off("ticket", onTicketTicket)
|
|
||||||
socket.off("contact", onContactTicket)
|
|
||||||
socket.off("remoteTickesControllIdleOpen", onRemoteTicketsControllIdleOpenTicket)
|
|
||||||
}
|
}
|
||||||
}, [ticketId, history])
|
}, [ticketId, history])
|
||||||
|
|
||||||
|
|
|
@ -22,8 +22,7 @@ import MarkdownWrapper from "../MarkdownWrapper"
|
||||||
import { Tooltip } from "@material-ui/core"
|
import { Tooltip } from "@material-ui/core"
|
||||||
import { AuthContext } from "../../context/Auth/AuthContext"
|
import { AuthContext } from "../../context/Auth/AuthContext"
|
||||||
import toastError from "../../errors/toastError"
|
import toastError from "../../errors/toastError"
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
const useStyles = makeStyles(theme => ({
|
const useStyles = makeStyles(theme => ({
|
||||||
ticket: {
|
ticket: {
|
||||||
|
@ -152,18 +151,17 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onRemoteTickesControllTicketListItem = (data) => {
|
socket.on('remoteTickesControll', (data) => {
|
||||||
console.log('REMOTE TICKETS CONTROLL UPDATE2: ', data.tickets)
|
console.log('REMOTE TICKETS CONTROLL UPDATE2: ', data.tickets)
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setRemoteTicketsControll(data.tickets)
|
setRemoteTicketsControll(data.tickets)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('remoteTickesControll', onRemoteTickesControllTicketListItem)
|
|
||||||
|
|
||||||
const onSettingsTicketListItem = (data) => {
|
socket.on('settings', (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSettings((prevState) => {
|
setSettings((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -172,13 +170,11 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsTicketListItem)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off('remoteTickesControll', onRemoteTickesControllTicketListItem);
|
socket.disconnect()
|
||||||
socket.off('settings', onSettingsTicketListItem);
|
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React, { useState, useEffect, useReducer, useContext } from "react"
|
import React, { useState, useEffect, useReducer, useContext } from "react"
|
||||||
|
|
||||||
//import openSocket from "socket.io-client"
|
|
||||||
import { socket } from "../../services/socket"
|
import openSocket from "socket.io-client"
|
||||||
|
|
||||||
import { makeStyles } from "@material-ui/core/styles"
|
import { makeStyles } from "@material-ui/core/styles"
|
||||||
import List from "@material-ui/core/List"
|
import List from "@material-ui/core/List"
|
||||||
|
@ -243,29 +243,27 @@ const TicketsList = (props) => {
|
||||||
|
|
||||||
// if (tab=='search')return
|
// if (tab=='search')return
|
||||||
|
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const shouldUpdateTicket = ticket =>
|
const shouldUpdateTicket = ticket =>
|
||||||
(status === ticket.status) &&
|
|
||||||
(!ticket.userId || ticket.userId === user?.id || showAll) &&
|
(!ticket.userId || ticket.userId === user?.id || showAll) &&
|
||||||
(!ticket.queueId || selectedQueueIds.indexOf(ticket.queueId) > -1)
|
(!ticket.queueId || selectedQueueIds.indexOf(ticket.queueId) > -1)
|
||||||
|
|
||||||
const notBelongsToUserQueues = ticket =>
|
const notBelongsToUserQueues = ticket =>
|
||||||
ticket.queueId && selectedQueueIds.indexOf(ticket.queueId) === -1
|
ticket.queueId && selectedQueueIds.indexOf(ticket.queueId) === -1
|
||||||
|
|
||||||
const onConnectTicketList = () => {
|
socket.on("connect", () => {
|
||||||
if (status) {
|
if (status) {
|
||||||
socket.emit("joinTickets", status)
|
socket.emit("joinTickets", status)
|
||||||
} else {
|
} else {
|
||||||
socket.emit("joinNotification")
|
socket.emit("joinNotification")
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
onConnectTicketList()
|
})
|
||||||
|
|
||||||
socket.on("connect", onConnectTicketList)
|
|
||||||
|
|
||||||
const onTicketTicketList = data => {
|
|
||||||
|
socket.on("ticket", data => {
|
||||||
|
|
||||||
if (data.action === "updateUnread") {
|
if (data.action === "updateUnread") {
|
||||||
|
|
||||||
|
@ -294,11 +292,10 @@ const TicketsList = (props) => {
|
||||||
if (data.action === "delete") {
|
if (data.action === "delete") {
|
||||||
dispatch({ type: "DELETE_TICKET", payload: data.ticketId })
|
dispatch({ type: "DELETE_TICKET", payload: data.ticketId })
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("ticket", onTicketTicketList)
|
|
||||||
|
|
||||||
const onAppMessageTicketList = data => {
|
socket.on("appMessage", data => {
|
||||||
if (data.action === "create" && shouldUpdateTicket(data.ticket)) {
|
if (data.action === "create" && shouldUpdateTicket(data.ticket)) {
|
||||||
|
|
||||||
|
|
||||||
|
@ -310,9 +307,7 @@ const TicketsList = (props) => {
|
||||||
payload: data,
|
payload: data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("appMessage", onAppMessageTicketList)
|
|
||||||
|
|
||||||
socket.on("contact", data => {
|
socket.on("contact", data => {
|
||||||
if (data.action === "update") {
|
if (data.action === "update") {
|
||||||
|
@ -323,16 +318,16 @@ const TicketsList = (props) => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const onRemoteTickesControllTicketList = (data) => {
|
|
||||||
|
socket.on('remoteTickesControll', (data) => {
|
||||||
console.log('REMOTE TICKETS CONTROLL UPDATE 1: ', data.tickets)
|
console.log('REMOTE TICKETS CONTROLL UPDATE 1: ', data.tickets)
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setRemoteTicketsControll(data.tickets)
|
setRemoteTicketsControll(data.tickets)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('remoteTickesControll', onRemoteTickesControllTicketList)
|
|
||||||
|
|
||||||
const onSettingsTicketList = (data) => {
|
socket.on('settings', (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSettings((prevState) => {
|
setSettings((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -341,17 +336,11 @@ const TicketsList = (props) => {
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsTicketList)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("ticket", onTicketTicketList)
|
socket.disconnect()
|
||||||
socket.off('appMessage', onAppMessageTicketList);
|
|
||||||
socket.removeAllListeners("contact")
|
|
||||||
socket.off('connect', onConnectTicketList);
|
|
||||||
socket.off('settings', onSettingsTicketList);
|
|
||||||
socket.off('remoteTickesControll', onRemoteTickesControllTicketList);
|
|
||||||
}
|
}
|
||||||
}, [status, showAll, user, selectedQueueIds, tab])
|
}, [status, showAll, user, selectedQueueIds, tab])
|
||||||
|
|
||||||
|
@ -360,7 +349,7 @@ const TicketsList = (props) => {
|
||||||
if (typeof updateCount === "function") {
|
if (typeof updateCount === "function") {
|
||||||
updateCount(ticketsList.length)
|
updateCount(ticketsList.length)
|
||||||
}
|
}
|
||||||
if (ticketsList && status === "pending") {
|
if (ticketsList && status === "pending"){
|
||||||
setTickets(ticketsList)
|
setTickets(ticketsList)
|
||||||
}
|
}
|
||||||
// else{
|
// else{
|
||||||
|
|
|
@ -19,6 +19,7 @@ import FindInPageIcon from '@material-ui/icons/FindInPage'
|
||||||
|
|
||||||
import FormControlLabel from "@material-ui/core/FormControlLabel"
|
import FormControlLabel from "@material-ui/core/FormControlLabel"
|
||||||
import Switch from "@material-ui/core/Switch"
|
import Switch from "@material-ui/core/Switch"
|
||||||
|
import openSocket from "socket.io-client"
|
||||||
|
|
||||||
import NewTicketModal from "../NewTicketModal"
|
import NewTicketModal from "../NewTicketModal"
|
||||||
import TicketsList from "../TicketsList"
|
import TicketsList from "../TicketsList"
|
||||||
|
@ -152,7 +153,7 @@ const TicketsManager = () => {
|
||||||
const [openCount, setOpenCount] = useState(0)
|
const [openCount, setOpenCount] = useState(0)
|
||||||
const [pendingCount, setPendingCount] = useState(0)
|
const [pendingCount, setPendingCount] = useState(0)
|
||||||
|
|
||||||
const userQueueIds = user?.queues?.map((q) => q?.id)
|
const userQueueIds = user.queues.map((q) => q.id)
|
||||||
const [selectedQueueIds, setSelectedQueueIds] = useState(userQueueIds || [])
|
const [selectedQueueIds, setSelectedQueueIds] = useState(userQueueIds || [])
|
||||||
|
|
||||||
const [showContentSearch, setShowContentSearch] = useState(false)
|
const [showContentSearch, setShowContentSearch] = useState(false)
|
||||||
|
@ -177,9 +178,9 @@ const TicketsManager = () => {
|
||||||
}, [setting])
|
}, [setting])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (user?.profile?.toUpperCase() === "ADMIN" ||
|
if (user.profile.toUpperCase() === "ADMIN" ||
|
||||||
user?.profile?.toUpperCase() === "SUPERVISOR" ||
|
user.profile.toUpperCase() === "SUPERVISOR" ||
|
||||||
user?.profile?.toUpperCase() === "MASTER") {
|
user.profile.toUpperCase() === "MASTER") {
|
||||||
setShowAllTickets(true)
|
setShowAllTickets(true)
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
@ -202,11 +203,11 @@ const TicketsManager = () => {
|
||||||
if (tickets.length > 0) {
|
if (tickets.length > 0) {
|
||||||
const now = new Date()
|
const now = new Date()
|
||||||
const differenceTime = tickets?.map(ticket => {
|
const differenceTime = tickets?.map(ticket => {
|
||||||
const createdAt = new Date(ticket?.createdAt)
|
const createdAt = new Date(ticket.createdAt)
|
||||||
const difference = now - createdAt
|
const difference = now - createdAt
|
||||||
return difference
|
return difference
|
||||||
})
|
})
|
||||||
const sumDifferences = differenceTime?.reduce((total, difference) => total + difference, 0)
|
const sumDifferences = differenceTime.reduce((total, difference) => total + difference, 0)
|
||||||
const averageTimeMilliseconds = sumDifferences / tickets?.length
|
const averageTimeMilliseconds = sumDifferences / tickets?.length
|
||||||
let hours = Math.floor(averageTimeMilliseconds / 3600000)
|
let hours = Math.floor(averageTimeMilliseconds / 3600000)
|
||||||
const minutes = Math.floor((averageTimeMilliseconds % 3600000) / 60000)
|
const minutes = Math.floor((averageTimeMilliseconds % 3600000) / 60000)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { useState, useContext, useMemo, useEffect } from "react"
|
import React, { useState, useContext, useMemo, useEffect } from "react"
|
||||||
import { useHistory } from "react-router-dom"
|
import { useHistory } from "react-router-dom"
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
import Button from "@material-ui/core/Button"
|
import Button from "@material-ui/core/Button"
|
||||||
import Dialog from "@material-ui/core/Dialog"
|
import Dialog from "@material-ui/core/Dialog"
|
||||||
|
@ -111,9 +110,9 @@ const TransferTicketModal = ({ modalOpen, onClose, ticketid }) => {
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onSettingsTransferTicketModal = (data) => {
|
socket.on('settings', (data) => {
|
||||||
console.log('settings updated ----------------------------xxxxxxxxxxxx')
|
console.log('settings updated ----------------------------xxxxxxxxxxxx')
|
||||||
|
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
|
@ -124,12 +123,10 @@ const TransferTicketModal = ({ modalOpen, onClose, ticketid }) => {
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsTransferTicketModal)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("settings", onSettingsTransferTicketModal)
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
@ -231,7 +228,7 @@ const TransferTicketModal = ({ modalOpen, onClose, ticketid }) => {
|
||||||
{i18n.t("transferTicketModal.title")}
|
{i18n.t("transferTicketModal.title")}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogContent dividers >
|
<DialogContent dividers >
|
||||||
<FormControl variant="outlined" className={classes.maxWidth} style={{ marginBottom: '8px' }}>
|
<FormControl variant="outlined" className={classes.maxWidth} style={{marginBottom: '8px'}}>
|
||||||
{/* <InputLabel>{i18n.t("transferTicketModal.fieldQueueLabel")}</InputLabel> */}
|
{/* <InputLabel>{i18n.t("transferTicketModal.fieldQueueLabel")}</InputLabel> */}
|
||||||
|
|
||||||
<InputLabel>{'Usuário'}</InputLabel>
|
<InputLabel>{'Usuário'}</InputLabel>
|
||||||
|
@ -262,7 +259,7 @@ const TransferTicketModal = ({ modalOpen, onClose, ticketid }) => {
|
||||||
required
|
required
|
||||||
>
|
>
|
||||||
<MenuItem style={{ background: "white", }} value={''}> </MenuItem>
|
<MenuItem style={{ background: "white", }} value={''}> </MenuItem>
|
||||||
{queues?.map((queue) => (
|
{queues.map((queue) => (
|
||||||
<MenuItem
|
<MenuItem
|
||||||
key={queue.id}
|
key={queue.id}
|
||||||
value={queue.id}
|
value={queue.id}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import { useState, useEffect } from 'react'
|
import { useState, useEffect } from 'react'
|
||||||
import { useHistory } from 'react-router-dom'
|
import { useHistory } from 'react-router-dom'
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from '../../services/socket'
|
|
||||||
|
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
|
|
||||||
|
@ -63,19 +62,19 @@ const useAuth = () => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const token = localStorage.getItem('token')
|
const token = localStorage.getItem('token')
|
||||||
; (async () => {
|
;(async () => {
|
||||||
if (token) {
|
if (token) {
|
||||||
try {
|
try {
|
||||||
const { data } = await api.post('/auth/refresh_token')
|
const { data } = await api.post('/auth/refresh_token')
|
||||||
api.defaults.headers.Authorization = `Bearer ${data.token}`
|
api.defaults.headers.Authorization = `Bearer ${data.token}`
|
||||||
setIsAuth(true)
|
setIsAuth(true)
|
||||||
setUser(data.user)
|
setUser(data.user)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toastError(err)
|
toastError(err)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
setLoading(false)
|
}
|
||||||
})()
|
setLoading(false)
|
||||||
|
})()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -91,7 +90,7 @@ const useAuth = () => {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
socket.on('user', (data) => {
|
socket.on('user', (data) => {
|
||||||
if (data.action === 'update' && data.user.id === user.id) {
|
if (data.action === 'update' && data.user.id === user.id) {
|
||||||
|
@ -99,7 +98,7 @@ const useAuth = () => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const onSettingsAuth = (data) => {
|
socket.on('settings', (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSetting((prevState) => {
|
setSetting((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -108,13 +107,10 @@ const useAuth = () => {
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsAuth)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.removeAllListeners('user');
|
socket.disconnect()
|
||||||
socket.off('settings', onSettingsAuth);
|
|
||||||
}
|
}
|
||||||
}, [user])
|
}, [user])
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
import { useState, useEffect, useReducer } from "react";
|
import { useState, useEffect, useReducer } from "react";
|
||||||
//import openSocket from "socket.io-client";
|
import openSocket from "socket.io-client";
|
||||||
import { socket } from "../../services/socket";
|
|
||||||
|
|
||||||
import toastError from "../../errors/toastError";
|
import toastError from "../../errors/toastError";
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,7 +126,7 @@ const useWhatsApps = () => {
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||||
|
|
||||||
socket.on("whatsapp", data => {
|
socket.on("whatsapp", data => {
|
||||||
if (data.action === "update") {
|
if (data.action === "update") {
|
||||||
|
@ -160,9 +158,7 @@ const useWhatsApps = () => {
|
||||||
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.removeAllListeners('whatsapp');
|
socket.disconnect();
|
||||||
socket.removeAllListeners('whatsappSession');
|
|
||||||
socket.removeAllListeners('whatsappSessionMonit');
|
|
||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,7 @@ import { i18n } from '../translate/i18n'
|
||||||
import { WhatsAppsContext } from '../context/WhatsApp/WhatsAppsContext'
|
import { WhatsAppsContext } from '../context/WhatsApp/WhatsAppsContext'
|
||||||
import { AuthContext } from '../context/Auth/AuthContext'
|
import { AuthContext } from '../context/Auth/AuthContext'
|
||||||
import { Can } from '../components/Can'
|
import { Can } from '../components/Can'
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from '../services/socket'
|
|
||||||
import api from '../services/api'
|
import api from '../services/api'
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,9 +118,9 @@ const MainListItems = (props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onSettingsMainListItem = (data) => {
|
socket.on('settings', (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSettings((prevState) => {
|
setSettings((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -130,12 +129,10 @@ const MainListItems = (props) => {
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsMainListItem)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off('settings', onSettingsMainListItem);
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
import React, { useState, useCallback, useEffect, useReducer, useContext } from 'react'
|
import React, { useState, useCallback, useEffect, useReducer, useContext } from 'react'
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
|
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from '../../services/socket'
|
|
||||||
|
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
import { green } from '@material-ui/core/colors'
|
import { green } from '@material-ui/core/colors'
|
||||||
|
@ -297,9 +296,10 @@ const Campaign = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onContactsBulkCampaing = (data) => {
|
|
||||||
|
socket.on("contactsBulkInsertOnQueueStatus", (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
|
|
||||||
if (String(data.insertOnQueue.adminId) === String(user.id)) {
|
if (String(data.insertOnQueue.adminId) === String(user.id)) {
|
||||||
|
@ -312,24 +312,19 @@ const Campaign = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("contactsBulkInsertOnQueueStatus", onContactsBulkCampaing)
|
socket.on('campaign', (data) => {
|
||||||
|
|
||||||
const onCampaignCampaign = (data) => {
|
|
||||||
|
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
dispatch({ type: "UPDATE_CAMPAIGNS", payload: data.campaign })
|
dispatch({ type: "UPDATE_CAMPAIGNS", payload: data.campaign })
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('campaign', onCampaignCampaign)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("campaign", onCampaignCampaign)
|
socket.disconnect()
|
||||||
socket.off("contactsBulkInsertOnQueueStatus", onContactsBulkCampaing)
|
|
||||||
}
|
}
|
||||||
}, [user.id])
|
}, [user.id])
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,7 @@ import React, { useState, useCallback, useEffect, useContext } from 'react'
|
||||||
import { toast } from 'react-toastify'
|
import { toast } from 'react-toastify'
|
||||||
import { format, parseISO } from 'date-fns'
|
import { format, parseISO } from 'date-fns'
|
||||||
|
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from '../../services/socket'
|
|
||||||
|
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
import { green, red, yellow, grey } from '@material-ui/core/colors'
|
import { green, red, yellow, grey } from '@material-ui/core/colors'
|
||||||
|
@ -452,17 +451,15 @@ const Connections = () => {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onDiskSpaceMonitConnections = (data) => {
|
socket.on('diskSpaceMonit', (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setDiskSpaceInfo(data.diskSpace)
|
setDiskSpaceInfo(data.diskSpace)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('diskSpaceMonit', onDiskSpaceMonitConnections)
|
socket.on('settings', (data) => {
|
||||||
|
|
||||||
const onSettingsConnections = (data) => {
|
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSettings((prevState) => {
|
setSettings((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -471,13 +468,10 @@ const Connections = () => {
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsConnections)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("settings", onSettingsConnections)
|
socket.disconnect()
|
||||||
socket.off("diskSpaceMonit", onDiskSpaceMonitConnections)
|
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React, { useState, useEffect, useReducer, useCallback, useContext } from "react"
|
import React, { useState, useEffect, useReducer, useCallback, useContext } from "react"
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
import { toast } from "react-toastify"
|
import { toast } from "react-toastify"
|
||||||
import { useHistory } from "react-router-dom"
|
import { useHistory } from "react-router-dom"
|
||||||
|
|
||||||
|
@ -261,9 +260,9 @@ const Contacts = () => {
|
||||||
}, [searchParam, pageNumber])
|
}, [searchParam, pageNumber])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onContactsBulkContacts = (data) => {
|
socket.on("contactsBulkInsertOnQueueStatus", (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
|
|
||||||
if (String(data.insertOnQueue.adminId) === String(user.id)) {
|
if (String(data.insertOnQueue.adminId) === String(user.id)) {
|
||||||
|
@ -279,11 +278,9 @@ const Contacts = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("contactsBulkInsertOnQueueStatus", onContactsBulkContacts)
|
socket.on("contact", (data) => {
|
||||||
|
|
||||||
const onContactContacts = (data) => {
|
|
||||||
if (data.action === "update" || data.action === "create") {
|
if (data.action === "update" || data.action === "create") {
|
||||||
dispatch({ type: "UPDATE_CONTACTS", payload: data.contact })
|
dispatch({ type: "UPDATE_CONTACTS", payload: data.contact })
|
||||||
}
|
}
|
||||||
|
@ -291,13 +288,10 @@ const Contacts = () => {
|
||||||
if (data.action === "delete") {
|
if (data.action === "delete") {
|
||||||
dispatch({ type: "DELETE_CONTACT", payload: +data.contactId })
|
dispatch({ type: "DELETE_CONTACT", payload: +data.contactId })
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("contact", onContactContacts)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("contact", onContactContacts)
|
socket.disconnect()
|
||||||
socket.off("contactsBulkInsertOnQueueStatus", onContactsBulkContacts)
|
|
||||||
}
|
}
|
||||||
}, [user, history])
|
}, [user, history])
|
||||||
|
|
||||||
|
|
|
@ -17,8 +17,7 @@ import { AuthContext } from "../../context/Auth/AuthContext"
|
||||||
import { i18n } from "../../translate/i18n";
|
import { i18n } from "../../translate/i18n";
|
||||||
import Chart from "./Chart"
|
import Chart from "./Chart"
|
||||||
import PieChart from "./PieChart"
|
import PieChart from "./PieChart"
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
import api from "../../services/api"
|
import api from "../../services/api"
|
||||||
|
|
||||||
import { Can } from "../../components/Can"
|
import { Can } from "../../components/Can"
|
||||||
|
@ -357,54 +356,46 @@ const Dashboard = () => {
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onTicketsStatusDashboard = (data) => {
|
socket.on("ticketStatus", (data) => {
|
||||||
if (data.action === "update") {
|
if (data.action === "update") {
|
||||||
setStatus("")
|
setStatus("")
|
||||||
setStatus(data.ticketStatus.status)
|
setStatus(data.ticketStatus.status)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("ticketStatus", onTicketsStatusDashboard)
|
socket.on("onlineStatus", (data) => {
|
||||||
|
|
||||||
const onOnlineStatusDashboard = (data) => {
|
|
||||||
if (data.action === "logout" || data.action === "update") {
|
if (data.action === "logout" || data.action === "update") {
|
||||||
|
|
||||||
dispatch({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime })
|
dispatch({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime })
|
||||||
} else if (data.action === "delete") {
|
} else if (data.action === "delete") {
|
||||||
dispatch({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime })
|
dispatch({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime })
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("onlineStatus", onOnlineStatusDashboard)
|
socket.on("user", (data) => {
|
||||||
|
|
||||||
const onUserDashboard = (data) => {
|
|
||||||
if (data.action === "delete") {
|
if (data.action === "delete") {
|
||||||
dispatch({ type: "DELETE_USER", payload: +data.userId })
|
dispatch({ type: "DELETE_USER", payload: +data.userId })
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("user", onUserDashboard)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("user", onUserDashboard)
|
socket.disconnect()
|
||||||
socket.off("onlineStatus", onOnlineStatusDashboard)
|
|
||||||
socket.off("ticketStatus", onTicketsStatusDashboard)
|
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const handleSelectedQueue = useCallback((queueSelected) => {
|
const handleSelectedQueue = useCallback((queueSelected) => {
|
||||||
if (queueSelected !== 'All') {
|
if(queueSelected !== 'All'){
|
||||||
const queueIndex = user?.queues?.findIndex((q) => q.id === parseInt(queueSelected));
|
const queueIndex = user?.queues?.findIndex((q) => q.id === parseInt(queueSelected));
|
||||||
const queueIds = []
|
const queueIds = []
|
||||||
queueIds.push(user?.queues[queueIndex]?.id);
|
queueIds.push(user?.queues[queueIndex]?.id);
|
||||||
setSelectedQueue(queueIds);
|
setSelectedQueue(queueIds);
|
||||||
} else {
|
}else{
|
||||||
const queueIds = user?.queues?.map((queue) => queue.id);
|
const queueIds = user?.queues?.map((queue) => queue.id);
|
||||||
setSelectedQueue(queueIds);
|
setSelectedQueue(queueIds);
|
||||||
}
|
}
|
||||||
}, [user, setSelectedQueue])
|
},[user, setSelectedQueue])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (ticketStatusChange === "") return
|
if (ticketStatusChange === "") return
|
||||||
|
@ -541,7 +532,7 @@ const Dashboard = () => {
|
||||||
<Grid item container spacing={3}>
|
<Grid item container spacing={3}>
|
||||||
<Grid item xs={12} sm={12} md={6} lg={6}>
|
<Grid item xs={12} sm={12} md={6} lg={6}>
|
||||||
<Paper className={classes.fixedHeightPaper} variant="outlined">
|
<Paper className={classes.fixedHeightPaper} variant="outlined">
|
||||||
<Chart allTickets={usersOnlineInfo} selectedQueue={selectedQueue} />
|
<Chart allTickets={usersOnlineInfo} selectedQueue = {selectedQueue}/>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} sm={12} md={6} lg={6}>
|
<Grid item xs={12} sm={12} md={6} lg={6}>
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React, { useState, useContext, useEffect, useReducer } from "react"
|
import React, { useState, useContext, useEffect, useReducer } from "react"
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
@ -126,9 +125,9 @@ const Position = () => {
|
||||||
}, [searchParam, pageNumber])
|
}, [searchParam, pageNumber])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onPositionPosition = (data) => {
|
socket.on("position", (data) => {
|
||||||
if (data.action === "update" || data.action === "create") {
|
if (data.action === "update" || data.action === "create") {
|
||||||
dispatch({ type: "UPDATE_POSITIONS", payload: data.position })
|
dispatch({ type: "UPDATE_POSITIONS", payload: data.position })
|
||||||
}
|
}
|
||||||
|
@ -139,12 +138,10 @@ const Position = () => {
|
||||||
payload: +data.positionId,
|
payload: +data.positionId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("position", onPositionPosition)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("position", onPositionPosition)
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { useEffect, useReducer, useState, useContext } from 'react'
|
import React, { useEffect, useReducer, useState, useContext } from 'react'
|
||||||
|
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from '../../services/socket'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
@ -124,9 +123,9 @@ const Queues = () => {
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onQueueQueues = (data) => {
|
socket.on('queue', (data) => {
|
||||||
if (data.action === 'update' || data.action === 'create') {
|
if (data.action === 'update' || data.action === 'create') {
|
||||||
dispatch({ type: 'UPDATE_QUEUES', payload: data.queue })
|
dispatch({ type: 'UPDATE_QUEUES', payload: data.queue })
|
||||||
}
|
}
|
||||||
|
@ -134,11 +133,9 @@ const Queues = () => {
|
||||||
if (data.action === 'delete') {
|
if (data.action === 'delete') {
|
||||||
dispatch({ type: 'DELETE_QUEUE', payload: data.queueId })
|
dispatch({ type: 'DELETE_QUEUE', payload: data.queueId })
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('queue', onQueueQueues)
|
socket.on('settings', (data) => {
|
||||||
|
|
||||||
const onSettingsQueues = (data) => {
|
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSettings((prevState) => {
|
setSettings((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -147,13 +144,10 @@ const Queues = () => {
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsQueues)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("settings", onSettingsQueues)
|
socket.disconnect()
|
||||||
socket.off("queue", onQueueQueues)
|
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React, { useState, useContext, useEffect, useReducer } from "react"
|
import React, { useState, useContext, useEffect, useReducer } from "react"
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
@ -126,9 +125,9 @@ const QuickAnswers = () => {
|
||||||
}, [searchParam, pageNumber])
|
}, [searchParam, pageNumber])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onQuickAnswerQuickAnswers = (data) => {
|
socket.on("quickAnswer", (data) => {
|
||||||
if (data.action === "update" || data.action === "create") {
|
if (data.action === "update" || data.action === "create") {
|
||||||
dispatch({ type: "UPDATE_QUICK_ANSWERS", payload: data.quickAnswer })
|
dispatch({ type: "UPDATE_QUICK_ANSWERS", payload: data.quickAnswer })
|
||||||
}
|
}
|
||||||
|
@ -139,11 +138,10 @@ const QuickAnswers = () => {
|
||||||
payload: +data.quickAnswerId,
|
payload: +data.quickAnswerId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
socket.on("quickAnswer", onQuickAnswerQuickAnswers)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("quickAnswer", onQuickAnswerQuickAnswers)
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,7 @@ import MaterialTable from 'material-table'
|
||||||
import LogoutIcon from '@material-ui/icons/CancelOutlined'
|
import LogoutIcon from '@material-ui/icons/CancelOutlined'
|
||||||
import apiBroker from "../../services/apiBroker"
|
import apiBroker from "../../services/apiBroker"
|
||||||
import fileDownload from 'js-file-download'
|
import fileDownload from 'js-file-download'
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
import { i18n } from "../../translate/i18n"
|
import { i18n } from "../../translate/i18n"
|
||||||
import Switch from '@mui/material/Switch'
|
import Switch from '@mui/material/Switch'
|
||||||
|
|
||||||
|
@ -382,10 +381,10 @@ const Report = () => {
|
||||||
const tickets = data.tickets.map(ticket => {
|
const tickets = data.tickets.map(ticket => {
|
||||||
ticket.isRemote = ticket.isRemote ? 'Remoto' : 'Comum';
|
ticket.isRemote = ticket.isRemote ? 'Remoto' : 'Comum';
|
||||||
return ({
|
return ({
|
||||||
...ticket,
|
...ticket,
|
||||||
messagesToFilter: ticket.messages.map(message => message.body).join(' '),
|
messagesToFilter: ticket.messages.map(message => message.body).join(' '),
|
||||||
link: `${process.env.REACT_APP_FRONTEND_URL}/tickets/${ticket.id}`
|
link: `${process.env.REACT_APP_FRONTEND_URL}/tickets/${ticket.id}`
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
dispatchQ({ type: "LOAD_QUERY", payload: tickets })
|
dispatchQ({ type: "LOAD_QUERY", payload: tickets })
|
||||||
setHasMore(data.hasMore)
|
setHasMore(data.hasMore)
|
||||||
|
@ -592,9 +591,9 @@ const Report = () => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onQueryOnQueueStatusReport = (data) => {
|
socket.on("queryOnQueueStatus", (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
|
|
||||||
if (String(data.queryOnQueue.adminId) === String(userA.id)) {
|
if (String(data.queryOnQueue.adminId) === String(userA.id)) {
|
||||||
|
@ -605,39 +604,35 @@ const Report = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("queryOnQueueStatus", onQueryOnQueueStatusReport)
|
|
||||||
|
|
||||||
const onOnlineStatusReport = (data) => {
|
|
||||||
|
|
||||||
let date = new Date().toLocaleDateString('pt-BR').split('/')
|
|
||||||
let dateToday = `${date[2]}-${date[1]}-${date[0]}`
|
|
||||||
|
|
||||||
if (data.action === "logout" || (data.action === "update" &&
|
|
||||||
((`${startDate}` === `${endDate}`) && (`${endDate}` === `${dateToday}`) && (`${startDate}` === `${dateToday}`)))) {
|
|
||||||
|
|
||||||
dispatchQ({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime })
|
|
||||||
|
|
||||||
}
|
|
||||||
else if (data.action === "delete") {
|
|
||||||
dispatchQ({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime })
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const onUserReport = (data) => {
|
|
||||||
|
|
||||||
if (data.action === "delete") {
|
|
||||||
dispatch({ type: "DELETE_USER", payload: +data.userId })
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reportOption === '2') {
|
if (reportOption === '2') {
|
||||||
|
|
||||||
socket.on("onlineStatus", onOnlineStatusReport)
|
|
||||||
|
|
||||||
socket.on("user", onUserReport)
|
socket.on("onlineStatus", (data) => {
|
||||||
|
|
||||||
|
let date = new Date().toLocaleDateString('pt-BR').split('/')
|
||||||
|
let dateToday = `${date[2]}-${date[1]}-${date[0]}`
|
||||||
|
|
||||||
|
if (data.action === "logout" || (data.action === "update" &&
|
||||||
|
((`${startDate}` === `${endDate}`) && (`${endDate}` === `${dateToday}`) && (`${startDate}` === `${dateToday}`)))) {
|
||||||
|
|
||||||
|
dispatchQ({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime })
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (data.action === "delete") {
|
||||||
|
dispatchQ({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime })
|
||||||
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
socket.on("user", (data) => {
|
||||||
|
|
||||||
|
if (data.action === "delete") {
|
||||||
|
dispatch({ type: "DELETE_USER", payload: +data.userId })
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (reportOption === "1") {
|
else if (reportOption === "1") {
|
||||||
|
@ -646,9 +641,7 @@ const Report = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("onlineStatus", onOnlineStatusReport)
|
socket.disconnect()
|
||||||
socket.off("user", onUserReport)
|
|
||||||
socket.off("queryOnQueueStatus", onQueryOnQueueStatusReport)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -694,7 +687,7 @@ const Report = () => {
|
||||||
|
|
||||||
|
|
||||||
const renderSwitch = (param) => {
|
const renderSwitch = (param) => {
|
||||||
if (userA.profile !== 'supervisor') {
|
if(userA.profile !== 'supervisor'){
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'empty':
|
case 'empty':
|
||||||
return (
|
return (
|
||||||
|
@ -887,7 +880,7 @@ const Report = () => {
|
||||||
<>
|
<>
|
||||||
<MTable data={query}
|
<MTable data={query}
|
||||||
columns={userA.profile !== 'supervisor' ? columnsData : columnsDataSuper}
|
columns={userA.profile !== 'supervisor' ? columnsData : columnsDataSuper}
|
||||||
hasChild={userA.profile !== 'supervisor' ? true : false}
|
hasChild={userA.profile !== 'supervisor' ? true :false}
|
||||||
removeClickRow={false}
|
removeClickRow={false}
|
||||||
|
|
||||||
handleScroll={handleScroll}
|
handleScroll={handleScroll}
|
||||||
|
|
|
@ -28,8 +28,8 @@ import { render } from '@testing-library/react'
|
||||||
// import Modal from "../../../..ChatEnd/ModalChatEnd";
|
// import Modal from "../../../..ChatEnd/ModalChatEnd";
|
||||||
import Modal from "../../components/ModalUpdateScheduleReminder"
|
import Modal from "../../components/ModalUpdateScheduleReminder"
|
||||||
|
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -204,9 +204,11 @@ const SchedulesReminder = () => {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
|
socket.on("schedulingNotify", (data) => {
|
||||||
|
|
||||||
|
|
||||||
const onSchedulingNotifySchedulesRemider = (data) => {
|
|
||||||
|
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
|
||||||
|
@ -226,12 +228,10 @@ const SchedulesReminder = () => {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
|
|
||||||
|
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("schedulingNotify", onSchedulingNotifySchedulesRemider)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("schedulingNotify", onSchedulingNotifySchedulesRemider)
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React, { useState, useEffect, useContext } from 'react'
|
import React, { useState, useEffect, useContext } from 'react'
|
||||||
//import openSocket from 'socket.io-client'
|
import openSocket from 'socket.io-client'
|
||||||
import { socket } from '../../services/socket.js'
|
|
||||||
|
|
||||||
import { makeStyles } from '@material-ui/core/styles'
|
import { makeStyles } from '@material-ui/core/styles'
|
||||||
import Paper from '@material-ui/core/Paper'
|
import Paper from '@material-ui/core/Paper'
|
||||||
|
@ -125,9 +124,9 @@ const Settings = () => {
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onSettingsSettings = (data) => {
|
socket.on('settings', (data) => {
|
||||||
console.log('settings updated ----------------------------')
|
console.log('settings updated ----------------------------')
|
||||||
|
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
|
@ -138,12 +137,10 @@ const Settings = () => {
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on('settings', onSettingsSettings)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("settings", onSettingsSettings)
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
@ -182,11 +179,7 @@ const Settings = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const getSettingValue = (key, _obj = false) => {
|
const getSettingValue = (key, _obj = false) => {
|
||||||
//const { value, obj } = settings.find((s) => s.key === key)
|
const { value, obj } = settings.find((s) => s.key === key)
|
||||||
const setting = settings.find((s) => s.key === key)
|
|
||||||
|
|
||||||
const value = setting?.value || ""
|
|
||||||
const obj = setting?.obj || null
|
|
||||||
|
|
||||||
if (_obj)
|
if (_obj)
|
||||||
return obj
|
return obj
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import React, { useState, useContext, useEffect, useReducer } from "react"
|
import React, { useState, useContext, useEffect, useReducer } from "react"
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
|
@ -132,9 +131,9 @@ const StatusChatEnd = () => {
|
||||||
}, [searchParam, pageNumber])
|
}, [searchParam, pageNumber])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onStatusChatEndStatusChatEnd = (data) => {
|
socket.on("statusChatEnd", (data) => {
|
||||||
if (data.action === "update" || data.action === "create") {
|
if (data.action === "update" || data.action === "create") {
|
||||||
dispatch({ type: "UPDATE_STATUS_CHAT_END", payload: data.statusChatEnd })
|
dispatch({ type: "UPDATE_STATUS_CHAT_END", payload: data.statusChatEnd })
|
||||||
}
|
}
|
||||||
|
@ -145,12 +144,10 @@ const StatusChatEnd = () => {
|
||||||
payload: +data.statusChatEndId,
|
payload: +data.statusChatEndId,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("statusChatEnd", onStatusChatEndStatusChatEnd)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("statusChatEnd", onStatusChatEndStatusChatEnd)
|
socket.disconnect()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import React, { useState, useEffect, useReducer, useContext } from "react"
|
import React, { useState, useEffect, useReducer, useContext } from "react"
|
||||||
import { toast } from "react-toastify"
|
import { toast } from "react-toastify"
|
||||||
//import openSocket from "socket.io-client"
|
import openSocket from "socket.io-client"
|
||||||
import { socket } from "../../services/socket"
|
|
||||||
|
|
||||||
import { makeStyles } from "@material-ui/core/styles"
|
import { makeStyles } from "@material-ui/core/styles"
|
||||||
import Paper from "@material-ui/core/Paper"
|
import Paper from "@material-ui/core/Paper"
|
||||||
|
@ -166,9 +165,9 @@ const Users = () => {
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
//const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
|
||||||
const onUserUsers = (data) => {
|
socket.on("user", (data) => {
|
||||||
if (data.action === "update" || data.action === "create") {
|
if (data.action === "update" || data.action === "create") {
|
||||||
dispatch({ type: "UPDATE_USERS", payload: data.user })
|
dispatch({ type: "UPDATE_USERS", payload: data.user })
|
||||||
}
|
}
|
||||||
|
@ -176,11 +175,10 @@ const Users = () => {
|
||||||
if (data.action === "delete") {
|
if (data.action === "delete") {
|
||||||
dispatch({ type: "DELETE_USER", payload: +data.userId })
|
dispatch({ type: "DELETE_USER", payload: +data.userId })
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
socket.on("user", onUserUsers)
|
|
||||||
|
|
||||||
const onSettingsUsers = (data) => {
|
socket.on('settings', (data) => {
|
||||||
if (data.action === 'update') {
|
if (data.action === 'update') {
|
||||||
setSettings((prevState) => {
|
setSettings((prevState) => {
|
||||||
const aux = [...prevState]
|
const aux = [...prevState]
|
||||||
|
@ -189,12 +187,10 @@ const Users = () => {
|
||||||
return aux
|
return aux
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
socket.on('settings', onSettingsUsers)
|
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
socket.off("settings", onSettingsUsers)
|
socket.disconnect()
|
||||||
socket.off("user", onUserUsers)
|
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
import { io } from 'socket.io-client';
|
|
||||||
|
|
||||||
// "undefined" means the URL will be computed from the `window.location` object
|
|
||||||
const URL = process.env.REACT_APP_BACKEND_URL
|
|
||||||
|
|
||||||
export const socket = io(URL,
|
|
||||||
//{
|
|
||||||
// withCredentials: true,
|
|
||||||
// extraHeaders: {
|
|
||||||
// "my-custom-header": "abcd"
|
|
||||||
// },
|
|
||||||
// transports: ['websocket', 'polling']
|
|
||||||
//}
|
|
||||||
);
|
|
Loading…
Reference in New Issue