Compare commits
No commits in common. "0751374fb7f7931c6982bf801fe9d37a00adcc9d" and "763448fdabf4bd2400f039cd3d993bff68dc67dc" have entirely different histories.
0751374fb7
...
763448fdab
|
@ -44,33 +44,26 @@ type ReportOnQueue = {
|
|||
|
||||
export const reportUserByDateStartDateEnd = async (req: Request, res: Response): Promise<Response> => {
|
||||
|
||||
if (
|
||||
req.user.profile !== "master" &&
|
||||
req.user.profile !== "admin" &&
|
||||
req.user.profile !== "supervisor"
|
||||
) {
|
||||
if (req.user.profile !== "master" && req.user.profile !== "admin") {
|
||||
throw new AppError("ERR_NO_PERMISSION", 403);
|
||||
}
|
||||
|
||||
const { userId, startDate, endDate, pageNumber } = req.query as IndexQuery
|
||||
|
||||
console.log("userId, startDate, endDate, pageNumber: ", userId, startDate, endDate, pageNumber);
|
||||
|
||||
const { tickets, count, hasMore } = await ShowTicketReport({ userId, startDate, endDate, pageNumber });
|
||||
|
||||
// console.log('kkkkkkkkkkkkkkkkkk tickets: ', JSON.stringify(tickets, null, 6))
|
||||
|
||||
return res.status(200).json({ tickets, count, hasMore });
|
||||
};
|
||||
|
||||
|
||||
export const reportUserService = async (req: Request, res: Response): Promise<Response> => {
|
||||
export const reportUserService = async (req: Request, res: Response): Promise<Response> => {
|
||||
|
||||
if (req.user.profile !== "master" && req.user.profile !== "admin" && req.user.profile !=="supervisor") {
|
||||
if (req.user.profile !== "master" && req.user.profile !== "admin") {
|
||||
throw new AppError("ERR_NO_PERMISSION", 403);
|
||||
}
|
||||
const { userId, startDate, endDate } = req.query as IndexQuery
|
||||
|
||||
const { userId, startDate, endDate } = req.query as IndexQuery
|
||||
|
||||
|
||||
// let usersProfile = await ListUserParamiterService({ profile: 'user' })
|
||||
let usersProfile = await ListUserParamiterService({
|
||||
profiles: ["user", "supervisor"],
|
||||
|
@ -195,11 +188,7 @@ export const reportUserService = async (req: Request, res: Response): Promise<Re
|
|||
|
||||
export const reportMessagesUserByDateStartDateEnd = async (req: Request, res: Response): Promise<Response> => {
|
||||
|
||||
if (
|
||||
req.user.profile !== "master" &&
|
||||
req.user.profile !== "admin" &&
|
||||
req.user.profile !== "supervisor"
|
||||
) {
|
||||
if (req.user.profile !== "master" && req.user.profile !== "admin") {
|
||||
throw new AppError("ERR_NO_PERMISSION", 403);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
const usersSocket = require("../libs/socket");
|
||||
|
||||
export const removeUserFromOlineList = (userId: any) => {
|
||||
let index = usersSocket?.ob?.listOnline?.findIndex((o: any) => o?.id == userId);
|
||||
let index = usersSocket.ob.listOnline.findIndex((o: any) => o.id == userId);
|
||||
|
||||
if (index != -1) {
|
||||
usersSocket?.ob?.listOnline?.splice(index, 1);
|
||||
usersSocket.ob.listOnline.splice(index, 1);
|
||||
}
|
||||
|
||||
index = -1;
|
||||
|
||||
index = usersSocket?.ob?.listOnlineAux?.findIndex((o: any) => o?.id == userId);
|
||||
index = usersSocket.ob.listOnlineAux.findIndex((o: any) => o.id == userId);
|
||||
|
||||
if (index != -1) {
|
||||
usersSocket?.ob?.listOnlineAux?.splice(index, 1);
|
||||
usersSocket.ob.listOnlineAux.splice(index, 1);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -194,12 +194,8 @@ const ListTicketsService = async ({
|
|||
|
||||
const userProfile: any = await User.findByPk(userId)
|
||||
|
||||
if (
|
||||
userProfile.dataValues.profile != "admin" &&
|
||||
userProfile.dataValues.profile != "master"
|
||||
// userProfile.dataValues.profile != "supervisor"
|
||||
) {
|
||||
whereCondition = { ...whereCondition, userId };
|
||||
if (userProfile.dataValues.profile != 'admin' && userProfile.dataValues.profile != 'master') {
|
||||
whereCondition = { ...whereCondition, userId }
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -103,11 +103,11 @@ const MainListItems = (props) => {
|
|||
primary={i18n.t('mainDrawer.listItems.quickAnswers')}
|
||||
icon={<QuestionAnswerOutlinedIcon />}
|
||||
/>
|
||||
|
||||
|
||||
|
||||
|
||||
<Can
|
||||
role={user.profile}
|
||||
perform="dashboard-view:show"
|
||||
perform="menu-users:view"
|
||||
yes={() => (
|
||||
<>
|
||||
<Divider />
|
||||
|
@ -117,24 +117,11 @@ const MainListItems = (props) => {
|
|||
primary={i18n.t("mainDrawer.listItems.users")}
|
||||
icon={<PeopleAltOutlinedIcon />}
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/"
|
||||
primary="Dashboard"
|
||||
icon={<DashboardOutlinedIcon />}
|
||||
/>
|
||||
<ListItemLink
|
||||
to="/report"
|
||||
primary="Relatório"
|
||||
icon={<ReportOutlinedIcon />}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<Can
|
||||
role={user.profile}
|
||||
perform="drawer-admin-items:view"
|
||||
|
@ -157,17 +144,17 @@ const MainListItems = (props) => {
|
|||
}
|
||||
/>
|
||||
|
||||
{/* <ListItemLink
|
||||
<ListItemLink
|
||||
to="/"
|
||||
primary="Dashboard"
|
||||
icon={<DashboardOutlinedIcon />}
|
||||
/> */}
|
||||
/>
|
||||
|
||||
{/* <ListItemLink
|
||||
<ListItemLink
|
||||
to="/report"
|
||||
primary="Relatório"
|
||||
icon={<ReportOutlinedIcon />}
|
||||
/> */}
|
||||
/>
|
||||
|
||||
<ListItemLink
|
||||
to="/campaign"
|
||||
|
|
|
@ -283,7 +283,7 @@ const Dashboard = () => {
|
|||
try {
|
||||
let date = new Date().toLocaleDateString("pt-BR").split("/")
|
||||
let dateToday = `${date[2]}-${date[1]}-${date[0]}`
|
||||
|
||||
|
||||
const { data } = await api.get("/reports/user/services", {
|
||||
params: { userId: null, startDate: dateToday, endDate: dateToday },
|
||||
})
|
||||
|
|
|
@ -1,47 +1,47 @@
|
|||
import React, { useState, useEffect, useReducer, useContext } from "react"
|
||||
import MainContainer from "../../components/MainContainer"
|
||||
import api from "../../services/api"
|
||||
import SelectField from "../../components/Report/SelectField"
|
||||
import React, { useState, useEffect, useReducer, useContext } from "react";
|
||||
import MainContainer from "../../components/MainContainer";
|
||||
import api from "../../services/api";
|
||||
import SelectField from "../../components/Report/SelectField";
|
||||
import DatePicker1 from '../../components/Report/DatePicker'
|
||||
import DatePicker2 from '../../components/Report/DatePicker'
|
||||
import MTable from "../../components/Report/MTable"
|
||||
import PropTypes from 'prop-types'
|
||||
import Box from '@mui/material/Box'
|
||||
import { AuthContext } from "../../context/Auth/AuthContext"
|
||||
import { Can } from "../../components/Can"
|
||||
import MTable from "../../components/Report/MTable";
|
||||
import PropTypes from 'prop-types';
|
||||
import Box from '@mui/material/Box';
|
||||
import { AuthContext } from "../../context/Auth/AuthContext";
|
||||
import { Can } from "../../components/Can";
|
||||
|
||||
import { Button } from "@material-ui/core"
|
||||
import { Button } from "@material-ui/core";
|
||||
|
||||
import ReportModal from "../../components/ReportModal"
|
||||
import MaterialTable from 'material-table'
|
||||
import ReportModal from "../../components/ReportModal";
|
||||
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 openSocket from "socket.io-client";
|
||||
|
||||
import openSocket from "socket.io-client"
|
||||
|
||||
import { i18n } from "../../translate/i18n"
|
||||
|
||||
import { i18n } from "../../translate/i18n";
|
||||
|
||||
|
||||
const report = [{ 'value': '1', 'label': 'Atendimento por atendentes' }, { 'value': '2', 'label': 'Usuários online/offline' }]
|
||||
|
||||
|
||||
|
||||
const reducerQ = (state, action) => {
|
||||
|
||||
if (action.type === "DELETE_USER_STATUS") {
|
||||
|
||||
const userId = action.payload
|
||||
|
||||
const userIndex = state.findIndex((u) => `${u.id}` === `${userId}`)
|
||||
const userId = action.payload;
|
||||
|
||||
const userIndex = state.findIndex((u) => `${u.id}` === `${userId}`);
|
||||
|
||||
if (userIndex !== -1) {
|
||||
state.splice(userIndex, 1)
|
||||
state.splice(userIndex, 1);
|
||||
}
|
||||
|
||||
return [...state]
|
||||
return [...state];
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,16 +72,16 @@ const reducerQ = (state, action) => {
|
|||
|
||||
let onlineUser = action.payload
|
||||
let index = -1
|
||||
|
||||
|
||||
if (onlineUser.sumOpen || onlineUser.sumClosed) {
|
||||
index = state.findIndex((e) => ((onlineUser.sumOpen && e.id === onlineUser.sumOpen.userId) || (onlineUser.sumClosed && e.id === onlineUser.sumClosed.userId)))
|
||||
}
|
||||
else {
|
||||
index = state.findIndex((e) => `${e.id}` === `${onlineUser.userId}`)
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (index !== -1) {
|
||||
if (index !== -1) {
|
||||
|
||||
if (!("statusOnline" in state[index])) {
|
||||
state[index].statusOnline = onlineUser
|
||||
|
@ -104,9 +104,9 @@ const reducerQ = (state, action) => {
|
|||
|
||||
if (onlineUser.sumOpen) {
|
||||
|
||||
if ("sumOpen" in state[index]) {
|
||||
if ("sumOpen" in state[index]) {
|
||||
state[index].sumOpen['count'] = onlineUser.sumOpen.count
|
||||
} else if (!("sumOpen" in state[index])) {
|
||||
} else if (!("sumOpen" in state[index])) {
|
||||
state[index].sumOpen = onlineUser.sumOpen
|
||||
}
|
||||
|
||||
|
@ -114,9 +114,9 @@ const reducerQ = (state, action) => {
|
|||
|
||||
if (onlineUser.sumClosed) {
|
||||
|
||||
if ("sumClosed" in state[index]) {
|
||||
if ("sumClosed" in state[index]) {
|
||||
state[index].sumClosed['count'] = onlineUser.sumClosed.count
|
||||
} else if (!("sumClosed" in state[index])) {
|
||||
} else if (!("sumClosed" in state[index])) {
|
||||
state[index].sumClosed = onlineUser.sumClosed
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ const reducerQ = (state, action) => {
|
|||
|
||||
|
||||
if (action.type === "RESET") {
|
||||
return []
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -141,41 +141,41 @@ const reducerQ = (state, action) => {
|
|||
const reducer = (state, action) => {
|
||||
|
||||
if (action.type === "LOAD_USERS") {
|
||||
const users = action.payload
|
||||
const newUsers = []
|
||||
const users = action.payload;
|
||||
const newUsers = [];
|
||||
|
||||
users.forEach((user) => {
|
||||
const userIndex = state.findIndex((u) => u.id === user.id)
|
||||
const userIndex = state.findIndex((u) => u.id === user.id);
|
||||
if (userIndex !== -1) {
|
||||
state[userIndex] = user
|
||||
state[userIndex] = user;
|
||||
} else {
|
||||
newUsers.push(user)
|
||||
newUsers.push(user);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
return [...state, ...newUsers]
|
||||
return [...state, ...newUsers];
|
||||
}
|
||||
|
||||
if (action.type === "DELETE_USER") {
|
||||
const userId = action.payload
|
||||
const userId = action.payload;
|
||||
|
||||
const userIndex = state.findIndex((u) => u.id === userId)
|
||||
const userIndex = state.findIndex((u) => u.id === userId);
|
||||
if (userIndex !== -1) {
|
||||
state.splice(userIndex, 1)
|
||||
state.splice(userIndex, 1);
|
||||
}
|
||||
return [...state]
|
||||
return [...state];
|
||||
}
|
||||
|
||||
if (action.type === "RESET") {
|
||||
return []
|
||||
return [];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
function Item(props) {
|
||||
const { sx, ...other } = props
|
||||
const { sx, ...other } = props;
|
||||
return (
|
||||
<Box
|
||||
sx={{
|
||||
|
@ -193,7 +193,7 @@ function Item(props) {
|
|||
}}
|
||||
{...other}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Item.propTypes = {
|
||||
|
@ -204,7 +204,7 @@ Item.propTypes = {
|
|||
PropTypes.func,
|
||||
PropTypes.object,
|
||||
]),
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -218,65 +218,51 @@ let columnsData = [
|
|||
{ title: 'Status', field: 'status' },
|
||||
|
||||
{ title: `${i18n.t("reports.listColumns.column1_7")}`, field: 'createdAt' },
|
||||
{ title: `${i18n.t("reports.listColumns.column1_8")}`, field: 'updatedAt' },
|
||||
{ title: `${i18n.t("reports.listColumns.column1_9")}`, field: 'statusChatEnd' }]
|
||||
{title: `${i18n.t("reports.listColumns.column1_8")}`, field: 'updatedAt'},
|
||||
{ title: `${i18n.t("reports.listColumns.column1_9")}`, field: 'statusChatEnd' }];
|
||||
|
||||
|
||||
|
||||
// function convertAndFormatDate(dateString) {
|
||||
// // Check if the input date string is in the desired format
|
||||
// const isDesiredFormat = /^\w{3} \w{3} \d{2} \d{4} \d{2}:\d{2}:\d{2} GMT[-+]\d{4} \([\w\s]+\)$/i.test(dateString)
|
||||
const Report = () => {
|
||||
|
||||
// if (isDesiredFormat) {
|
||||
// // Convert the input date string to a JavaScript Date object
|
||||
// const dateObj = new Date(dateString)
|
||||
|
||||
// // Format the date to the desired string format (e.g., 'yyyy-MM-dd') in the Brazil time zone
|
||||
// const formattedDate = `${dateObj.getUTCFullYear()}-${(dateObj.getUTCMonth() + 1).toString().padStart(2, '0')}-${dateObj.getUTCDate().toString().padStart(2, '0')}`
|
||||
|
||||
// return formattedDate
|
||||
// }
|
||||
|
||||
// // If the date is not in the desired format, return the original input string
|
||||
// return dateString
|
||||
// }
|
||||
|
||||
|
||||
const Report = () => {
|
||||
|
||||
const { user: userA } = useContext(AuthContext)
|
||||
const { user: userA } = useContext(AuthContext);
|
||||
|
||||
//--------
|
||||
const [searchParam] = useState("")
|
||||
const [searchParam] = useState("");
|
||||
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [hasMore, setHasMore] = useState(false)
|
||||
const [pageNumberTickets, setTicketsPageNumber] = useState(1)
|
||||
const [totalCountTickets, setTotalCountTickets] = useState(0)
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [hasMore, setHasMore] = useState(false);
|
||||
const [pageNumberTickets, setTicketsPageNumber] = useState(1);
|
||||
const [totalCountTickets, setTotalCountTickets] = useState(0);
|
||||
|
||||
|
||||
|
||||
const [pageNumber, setPageNumber] = useState(1)
|
||||
const [users, dispatch] = useReducer(reducer, [])
|
||||
const [pageNumber, setPageNumber] = useState(1);
|
||||
const [users, dispatch] = useReducer(reducer, []);
|
||||
const [startDate, setDatePicker1] = useState(new Date())
|
||||
const [endDate, setDatePicker2] = useState(new Date())
|
||||
const [userId, setUser] = useState(null)
|
||||
const [query, dispatchQ] = useReducer(reducerQ, [])
|
||||
|
||||
|
||||
const [reportOption, setReport] = useState('1')
|
||||
const [reporList,] = useState(report)
|
||||
const [profile, setProfile] = useState('')
|
||||
const [dataRows, setData] = useState([])
|
||||
const [dataRows, setData] = useState([]);
|
||||
|
||||
const [onQueueStatus, setOnQueueProcessStatus] = useState(undefined)
|
||||
const [csvFile, setCsvFile] = useState()
|
||||
const [csvFile, setCsvFile] = useState()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
dispatch({ type: "RESET" })
|
||||
dispatch({ type: "RESET" });
|
||||
dispatchQ({ type: "RESET" })
|
||||
setTicketsPageNumber(1)
|
||||
setPageNumber(1)
|
||||
}, [searchParam, profile])
|
||||
setPageNumber(1);
|
||||
}, [searchParam, profile]);
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -286,24 +272,24 @@ const Report = () => {
|
|||
|
||||
const fetchUsers = async () => {
|
||||
try {
|
||||
|
||||
|
||||
const { data } = await api.get("/users/", {
|
||||
params: { searchParam, pageNumber, profile },
|
||||
})
|
||||
|
||||
dispatch({ type: "LOAD_USERS", payload: data.users })
|
||||
});
|
||||
|
||||
dispatch({ type: "LOAD_USERS", payload: data.users });
|
||||
//setLoading(false);
|
||||
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fetchUsers()
|
||||
fetchUsers();
|
||||
|
||||
}, 500)
|
||||
return () => clearTimeout(delayDebounceFn)
|
||||
}, [searchParam, pageNumber, reportOption, profile])
|
||||
}, 500);
|
||||
return () => clearTimeout(delayDebounceFn);
|
||||
}, [searchParam, pageNumber, reportOption, profile]);
|
||||
|
||||
|
||||
|
||||
|
@ -313,45 +299,42 @@ const Report = () => {
|
|||
|
||||
const delayDebounceFn = setTimeout(() => {
|
||||
|
||||
setLoading(true)
|
||||
setLoading(true);
|
||||
const fetchQueries = async () => {
|
||||
try {
|
||||
|
||||
if (reportOption === '1') {
|
||||
if (reportOption === '1') {
|
||||
|
||||
// const { data } = await api.get("/reports/", { params: { userId: userId ? userId : 0, startDate: convertAndFormatDate(startDate), endDate: convertAndFormatDate(endDate), pageNumber: pageNumberTickets }, })
|
||||
const { data } = await api.get("/reports/", { params: { userId, startDate, endDate, pageNumber: pageNumberTickets }, });
|
||||
|
||||
dispatchQ({ type: "LOAD_QUERY", payload: data.tickets });
|
||||
|
||||
const { data } = await api.get("/reports/", { params: { userId, startDate, endDate, pageNumber: pageNumberTickets }, })
|
||||
|
||||
|
||||
dispatchQ({ type: "LOAD_QUERY", payload: data.tickets })
|
||||
|
||||
setHasMore(data.hasMore)
|
||||
setHasMore(data.hasMore);
|
||||
setTotalCountTickets(data.count)
|
||||
setLoading(false)
|
||||
setLoading(false);
|
||||
|
||||
|
||||
}
|
||||
else if (reportOption === '2') {
|
||||
|
||||
const dataQuery = await api.get("/reports/user/services", { params: { userId, startDate, endDate }, })
|
||||
const dataQuery = await api.get("/reports/user/services", { params: { userId, startDate, endDate }, });
|
||||
dispatchQ({ type: "RESET" })
|
||||
dispatchQ({ type: "LOAD_QUERY", payload: dataQuery.data })
|
||||
dispatchQ({ type: "LOAD_QUERY", payload: dataQuery.data });
|
||||
//setLoading(false);
|
||||
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fetchQueries()
|
||||
fetchQueries();
|
||||
|
||||
}, 500)
|
||||
return () => clearTimeout(delayDebounceFn)
|
||||
}, 500);
|
||||
return () => clearTimeout(delayDebounceFn);
|
||||
|
||||
}, [userId, startDate, endDate, reportOption, pageNumberTickets, totalCountTickets])
|
||||
}, [userId, startDate, endDate, reportOption, pageNumberTickets, totalCountTickets]);
|
||||
|
||||
|
||||
// Get from child 1
|
||||
|
@ -379,7 +362,7 @@ const Report = () => {
|
|||
const reportValue = (data) => {
|
||||
|
||||
setReport(data)
|
||||
|
||||
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
|
@ -408,7 +391,7 @@ const Report = () => {
|
|||
baseURL: process.env.REACT_APP_BACKEND_URL_PRIVATE,
|
||||
identifier: 'csv'
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
if (queryOnQueue.data) {
|
||||
|
@ -418,50 +401,52 @@ const Report = () => {
|
|||
else {
|
||||
setOnQueueProcessStatus('empty')
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fetchReportOnQueue()
|
||||
fetchReportOnQueue();
|
||||
|
||||
}, 500)
|
||||
return () => clearTimeout(delayDebounceFn)
|
||||
}, 500);
|
||||
return () => clearTimeout(delayDebounceFn);
|
||||
|
||||
}, [userA])
|
||||
|
||||
|
||||
const handleCSVDownload = async () => {
|
||||
}, [ userA ])
|
||||
|
||||
|
||||
const handleCSVDownload = async () => {
|
||||
|
||||
setOnQueueProcessStatus('downloading')
|
||||
|
||||
try {
|
||||
|
||||
let res = await apiBroker.get(`/reports/download/${csvFile}`, { responseType: 'blob' })
|
||||
let res = await apiBroker.get(`/reports/download/${csvFile}`, { responseType: 'blob' });
|
||||
|
||||
if (res) {
|
||||
fileDownload(res.data, `${csvFile}`)
|
||||
setOnQueueProcessStatus('empty')
|
||||
fileDownload(res.data, `${csvFile}`);
|
||||
setOnQueueProcessStatus('empty')
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
const handleCSVMessages = () => {
|
||||
|
||||
const fetchQueries = async () => {
|
||||
|
||||
try {
|
||||
|
||||
try {
|
||||
|
||||
// const dataQuery = await api.get("/reports/messages", { params: { userId, startDate, endDate }, });
|
||||
|
||||
const querySavedOnQueue = await apiBroker.post("/reports/messages",
|
||||
{
|
||||
app: {
|
||||
|
@ -475,26 +460,26 @@ const Report = () => {
|
|||
startDate: startDate,
|
||||
endDate: endDate
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const onQueueStatus = querySavedOnQueue.data.queueStatus
|
||||
|
||||
setOnQueueProcessStatus(onQueueStatus)
|
||||
setOnQueueProcessStatus(onQueueStatus)
|
||||
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fetchQueries()
|
||||
fetchQueries();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
|
||||
|
||||
socket.on("queryOnQueueStatus", (data) => {
|
||||
if (data.action === 'update') {
|
||||
|
@ -510,7 +495,7 @@ const Report = () => {
|
|||
})
|
||||
|
||||
if (reportOption === '2') {
|
||||
|
||||
|
||||
|
||||
socket.on("onlineStatus", (data) => {
|
||||
|
||||
|
@ -518,24 +503,24 @@ const Report = () => {
|
|||
let dateToday = `${date[2]}-${date[1]}-${date[0]}`
|
||||
|
||||
if (data.action === "logout" || (data.action === "update" &&
|
||||
((`${startDate}` === `${endDate}`) && (`${endDate}` === `${dateToday}`) && (`${startDate}` === `${dateToday}`)))) {
|
||||
((`${startDate}` === `${endDate}`) && (`${endDate}` === `${dateToday}`) && (`${startDate}` === `${dateToday}`)))) {
|
||||
|
||||
dispatchQ({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime })
|
||||
dispatchQ({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime });
|
||||
|
||||
}
|
||||
else if (data.action === "delete") {
|
||||
dispatchQ({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime })
|
||||
dispatchQ({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime });
|
||||
}
|
||||
|
||||
})
|
||||
});
|
||||
|
||||
socket.on("user", (data) => {
|
||||
|
||||
if (data.action === "delete") {
|
||||
dispatch({ type: "DELETE_USER", payload: +data.userId })
|
||||
if (data.action === "delete") {
|
||||
dispatch({ type: "DELETE_USER", payload: +data.userId });
|
||||
}
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
else if (reportOption === "1") {
|
||||
|
@ -544,14 +529,14 @@ const Report = () => {
|
|||
}
|
||||
|
||||
return () => {
|
||||
socket.disconnect()
|
||||
}
|
||||
socket.disconnect();
|
||||
};
|
||||
|
||||
|
||||
}, [reportOption, startDate, endDate, userId, userA])
|
||||
}, [reportOption, startDate, endDate, userId, userA]);
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
useEffect(() => {
|
||||
|
||||
setData(query.map((column) => { return { ...column } }))
|
||||
|
||||
|
@ -560,7 +545,7 @@ const Report = () => {
|
|||
|
||||
const handleLogouOnlineUser = async (userId) => {
|
||||
try {
|
||||
await api.get(`/users/logout/${userId}`)
|
||||
await api.get(`/users/logout/${userId}`);
|
||||
//toast.success(("Desloged!"));
|
||||
//handleDeleteRows(scheduleId)
|
||||
} catch (err) {
|
||||
|
@ -568,25 +553,25 @@ const Report = () => {
|
|||
}
|
||||
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const loadMore = () => {
|
||||
setTicketsPageNumber((prevState) => prevState + 1)
|
||||
}
|
||||
setTicketsPageNumber((prevState) => prevState + 1);
|
||||
};
|
||||
|
||||
const handleScroll = (e) => {
|
||||
|
||||
if (!hasMore || loading) return
|
||||
if (!hasMore || loading) return;
|
||||
|
||||
const { scrollTop, scrollHeight, clientHeight } = e.currentTarget
|
||||
const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;
|
||||
|
||||
if (scrollHeight - (scrollTop + 1) < clientHeight) {
|
||||
|
||||
loadMore()
|
||||
|
||||
loadMore();
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const renderSwitch = (param) => {
|
||||
|
@ -604,36 +589,36 @@ const Report = () => {
|
|||
>
|
||||
{"CSV ALL"}
|
||||
</Button>
|
||||
</>)
|
||||
</>);
|
||||
|
||||
case 'pending' || 'processing':
|
||||
return (
|
||||
<>
|
||||
<span>PROCESSING...</span>
|
||||
</>)
|
||||
</>);
|
||||
|
||||
case 'success':
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
variant="contained"
|
||||
color="primary"
|
||||
color="primary"
|
||||
onClick={(e) => {
|
||||
handleCSVDownload(e)
|
||||
}}
|
||||
>
|
||||
{'CSV DOWNLOAD'}
|
||||
</Button>
|
||||
</>)
|
||||
case 'downloading':
|
||||
return (
|
||||
<>
|
||||
<span>DOWNLOADING...</span>
|
||||
</>)
|
||||
|
||||
</>);
|
||||
case 'downloading':
|
||||
return (
|
||||
<>
|
||||
<span>DOWNLOADING...</span>
|
||||
</>);
|
||||
|
||||
|
||||
default:
|
||||
return (<><span>WAITING...</span></>)
|
||||
return (<><span>WAITING...</span></>);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -679,7 +664,7 @@ const Report = () => {
|
|||
|
||||
<Item sx={{ gridColumn: '1', gridRow: 'span 1' }}>
|
||||
|
||||
{reportOption === '1' &&
|
||||
{reportOption === '1' &&
|
||||
|
||||
<>
|
||||
|
||||
|
@ -723,16 +708,16 @@ const Report = () => {
|
|||
|
||||
if (rowData['statusOnline'].status === 'offline') {
|
||||
|
||||
return { color: "red" }
|
||||
return { color: "red" };
|
||||
}
|
||||
else if (rowData['statusOnline'].status === 'online') {
|
||||
return { color: "green" }
|
||||
return { color: "green" };
|
||||
}
|
||||
else if (rowData['statusOnline'].status === 'logout...') {
|
||||
return { color: "orange" }
|
||||
return { color: "orange" };
|
||||
}
|
||||
else if (rowData['statusOnline'].status === 'waiting...') {
|
||||
return { color: "orange" }
|
||||
return { color: "orange" };
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -749,7 +734,7 @@ const Report = () => {
|
|||
|
||||
]
|
||||
}
|
||||
data={dataRows}
|
||||
data={dataRows}
|
||||
|
||||
actions={[
|
||||
(rowData) => {
|
||||
|
@ -763,7 +748,7 @@ const Report = () => {
|
|||
icon: LogoutIcon,
|
||||
tooltip: 'deslogar',
|
||||
disable: false,
|
||||
onClick: (event, rowData) => {
|
||||
onClick: (event, rowData) => {
|
||||
handleLogouOnlineUser(rowData.id)
|
||||
}
|
||||
}
|
||||
|
@ -780,7 +765,7 @@ const Report = () => {
|
|||
selection: false,
|
||||
paging: false,
|
||||
padding: 'dense',
|
||||
sorting: true,
|
||||
sorting: true,
|
||||
searchFieldStyle: {
|
||||
width: 300,
|
||||
},
|
||||
|
@ -794,7 +779,7 @@ const Report = () => {
|
|||
|
||||
rowStyle: {
|
||||
fontSize: 14,
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
/>
|
||||
|
@ -809,6 +794,6 @@ const Report = () => {
|
|||
)}
|
||||
/>
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
export default Report
|
||||
export default Report;
|
||||
|
|
|
@ -7,9 +7,7 @@ const rules = {
|
|||
static: [
|
||||
"menu-users:view",
|
||||
"user-view:show",
|
||||
"user-modal:editQueues",
|
||||
'dashboard-view:show',
|
||||
'ticket-report:show'
|
||||
"user-modal:editQueues"
|
||||
]
|
||||
},
|
||||
|
||||
|
@ -43,6 +41,7 @@ const rules = {
|
|||
'show-icon-edit-queue',
|
||||
'show-icon-delete-queue',
|
||||
'space-disk-info:show',
|
||||
|
||||
'drawer-admin-items:view',
|
||||
'tickets-manager:showall',
|
||||
'user-modal:editProfile',
|
||||
|
|
Loading…
Reference in New Issue