fix issues for websocket merge

merge-socket
adriano 2024-08-29 18:09:00 -03:00
parent 1f8d5eb29b
commit 0a031bd9a8
5 changed files with 22 additions and 21 deletions

View File

@ -59,14 +59,14 @@ export const initIO = (httpServer: Server): SocketIO => {
io = new SocketIO(httpServer, { io = new SocketIO(httpServer, {
cors: { cors: {
origin: "*", origin: process.env.FRONTEND_URL,
allowedHeaders: ["my-custom-header"], //allowedHeaders: ["my-custom-header"],
credentials: true //credentials: true
}, },
maxHttpBufferSize: 1e8, maxHttpBufferSize: 1e8,
pingInterval: 25000, // pingInterval: 25000,
pingTimeout: 60000, // pingTimeout: 60000,
adapter: createAdapter(pubClient, subClient) // adapter: createAdapter(pubClient, subClient)
}); });

View File

@ -6,4 +6,4 @@ app.use(express.static(path.join(__dirname, "build")));
app.get("/*", function (req, res) { app.get("/*", function (req, res) {
res.sendFile(path.join(__dirname, "build", "index.html")); res.sendFile(path.join(__dirname, "build", "index.html"));
}); });
app.listen(3331); app.listen(3333);

View File

@ -152,7 +152,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 +177,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 +202,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)

View File

@ -1,7 +1,7 @@
import axios from "axios"; import axios from "axios";
const api = axios.create({ const api = axios.create({
baseURL: process.env.REACT_APP_BACKEND_URL + "/api", baseURL: process.env.REACT_APP_BACKEND_URL,
withCredentials: true, withCredentials: true,
}); });

View File

@ -3,11 +3,12 @@ import { io } from 'socket.io-client';
// "undefined" means the URL will be computed from the `window.location` object // "undefined" means the URL will be computed from the `window.location` object
const URL = process.env.REACT_APP_BACKEND_URL const URL = process.env.REACT_APP_BACKEND_URL
export const socket = io(URL, { export const socket = io(URL,
path: "/api-ws/socketio", //{
withCredentials: true, // withCredentials: true,
extraHeaders: { // extraHeaders: {
"my-custom-header": "abcd" // "my-custom-header": "abcd"
}, // },
// transports: ['websocket', 'polling'] // transports: ['websocket', 'polling']
}); //}
);