2024-01-30 12:50:37 +00:00
|
|
|
import React, { useState, useEffect, useReducer, useContext } from "react"
|
|
|
|
import MainContainer from "../../components/MainContainer"
|
|
|
|
import api from "../../services/api"
|
|
|
|
import SelectField from "../../components/Report/SelectField"
|
2022-05-16 02:48:06 +00:00
|
|
|
import DatePicker1 from '../../components/Report/DatePicker'
|
|
|
|
import DatePicker2 from '../../components/Report/DatePicker'
|
2024-01-30 12:50:37 +00:00
|
|
|
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"
|
2024-02-28 13:48:36 +00:00
|
|
|
import FormControlLabel from "@mui/material/FormControlLabel"
|
|
|
|
import Checkbox from '@mui/material/Checkbox'
|
|
|
|
|
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
import { Button } from "@material-ui/core"
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
import ReportModal from "../../components/ReportModal"
|
|
|
|
import MaterialTable from 'material-table'
|
2022-05-16 03:33:09 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
import LogoutIcon from '@material-ui/icons/CancelOutlined'
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
import apiBroker from "../../services/apiBroker"
|
2022-08-29 01:09:00 +00:00
|
|
|
import fileDownload from 'js-file-download'
|
2022-08-18 15:18:42 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
import openSocket from "socket.io-client"
|
|
|
|
|
|
|
|
import { i18n } from "../../translate/i18n"
|
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
import Switch from '@mui/material/Switch'
|
|
|
|
|
|
|
|
const label = { inputProps: { 'aria-label': 'Size switch demo' } }
|
2022-12-15 22:20:33 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
const report = [{ 'value': '1', 'label': 'Atendimento por atendentes' }, { 'value': '2', 'label': 'Usuários online/offline' }]
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
const reducerQ = (state, action) => {
|
|
|
|
|
|
|
|
if (action.type === "DELETE_USER_STATUS") {
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
const userId = action.payload
|
|
|
|
|
|
|
|
const userIndex = state.findIndex((u) => `${u.id}` === `${userId}`)
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
if (userIndex !== -1) {
|
2024-01-30 12:50:37 +00:00
|
|
|
state.splice(userIndex, 1)
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
return [...state]
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (action.type === 'LOAD_QUERY') {
|
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
let queries = action.payload
|
2022-01-25 14:24:05 +00:00
|
|
|
const newQueries = []
|
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
if (queries?.hasOwnProperty('usersProfile')) {
|
|
|
|
queries = queries.usersProfile
|
|
|
|
}
|
|
|
|
|
2022-01-25 14:24:05 +00:00
|
|
|
queries.forEach((query) => {
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-01-25 14:24:05 +00:00
|
|
|
const queryIndex = state.findIndex((q) => q.id === query.id)
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
if (queryIndex !== -1) {
|
2022-01-25 14:24:05 +00:00
|
|
|
state[queryIndex] = query
|
|
|
|
}
|
2022-05-16 02:48:06 +00:00
|
|
|
else {
|
2022-01-25 14:24:05 +00:00
|
|
|
newQueries.push(query)
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
return [...state, ...newQueries]
|
|
|
|
}
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (action.type === "UPDATE_STATUS_ONLINE") {
|
|
|
|
|
|
|
|
let onlineUser = action.payload
|
|
|
|
let index = -1
|
2024-01-30 12:50:37 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
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}`)
|
|
|
|
}
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
|
|
|
|
if (index !== -1) {
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
if (!("statusOnline" in state[index])) {
|
|
|
|
state[index].statusOnline = onlineUser
|
|
|
|
}
|
|
|
|
else if ("statusOnline" in state[index]) {
|
|
|
|
state[index].statusOnline['status'] = onlineUser.status
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ("onlineTime" in onlineUser) {
|
|
|
|
|
|
|
|
if ("sumOnlineTime" in state[index]) {
|
|
|
|
state[index].sumOnlineTime['sum'] = (onlineUser.onlineTime).split(" ")[1]
|
|
|
|
}
|
|
|
|
else if (!("sumOnlineTime" in state[index])) {
|
|
|
|
state[index].sumOnlineTime = { userId: onlineUser.userId, sum: (onlineUser.onlineTime).split(" ")[1] }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (onlineUser.sumOpen) {
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
if ("sumOpen" in state[index]) {
|
2022-05-16 02:48:06 +00:00
|
|
|
state[index].sumOpen['count'] = onlineUser.sumOpen.count
|
2024-01-30 12:50:37 +00:00
|
|
|
} else if (!("sumOpen" in state[index])) {
|
2022-05-16 02:48:06 +00:00
|
|
|
state[index].sumOpen = onlineUser.sumOpen
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (onlineUser.sumClosed) {
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
if ("sumClosed" in state[index]) {
|
2022-05-16 02:48:06 +00:00
|
|
|
state[index].sumClosed['count'] = onlineUser.sumClosed.count
|
2024-01-30 12:50:37 +00:00
|
|
|
} else if (!("sumClosed" in state[index])) {
|
2022-05-16 02:48:06 +00:00
|
|
|
state[index].sumClosed = onlineUser.sumClosed
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
return [...state]
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-25 14:24:05 +00:00
|
|
|
if (action.type === "RESET") {
|
2024-01-30 12:50:37 +00:00
|
|
|
return []
|
2022-01-25 14:24:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
const reducer = (state, action) => {
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
if (action.type === "LOAD_USERS") {
|
2024-01-30 12:50:37 +00:00
|
|
|
const users = action.payload
|
|
|
|
const newUsers = []
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
users.forEach((user) => {
|
2024-01-30 12:50:37 +00:00
|
|
|
const userIndex = state.findIndex((u) => u.id === user.id)
|
2022-01-24 11:44:42 +00:00
|
|
|
if (userIndex !== -1) {
|
2024-01-30 12:50:37 +00:00
|
|
|
state[userIndex] = user
|
2022-01-24 11:44:42 +00:00
|
|
|
} else {
|
2024-01-30 12:50:37 +00:00
|
|
|
newUsers.push(user)
|
2022-01-24 11:44:42 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
})
|
2022-01-24 11:44:42 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
return [...state, ...newUsers]
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action.type === "DELETE_USER") {
|
2024-01-30 12:50:37 +00:00
|
|
|
const userId = action.payload
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
const userIndex = state.findIndex((u) => u.id === userId)
|
2022-05-16 02:48:06 +00:00
|
|
|
if (userIndex !== -1) {
|
2024-01-30 12:50:37 +00:00
|
|
|
state.splice(userIndex, 1)
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
return [...state]
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
if (action.type === "RESET") {
|
2024-01-30 12:50:37 +00:00
|
|
|
return []
|
2022-01-24 11:44:42 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
}
|
2022-01-24 11:44:42 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
function Item(props) {
|
2024-01-30 12:50:37 +00:00
|
|
|
const { sx, ...other } = props
|
2022-01-24 11:44:42 +00:00
|
|
|
return (
|
|
|
|
<Box
|
|
|
|
sx={{
|
|
|
|
bgcolor: (theme) => (theme.palette.mode === 'dark' ? '#101010' : '#fff'),
|
|
|
|
color: (theme) => (theme.palette.mode === 'dark' ? 'grey.300' : 'grey.800'),
|
|
|
|
border: '1px solid',
|
|
|
|
borderColor: (theme) =>
|
|
|
|
theme.palette.mode === 'dark' ? 'grey.800' : 'grey.300',
|
|
|
|
p: 1,
|
|
|
|
m: 1,
|
|
|
|
borderRadius: 2,
|
|
|
|
fontSize: '0.875rem',
|
|
|
|
fontWeight: '700',
|
|
|
|
...sx,
|
|
|
|
}}
|
|
|
|
{...other}
|
|
|
|
/>
|
2024-01-30 12:50:37 +00:00
|
|
|
)
|
2022-01-24 11:44:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Item.propTypes = {
|
|
|
|
sx: PropTypes.oneOfType([
|
|
|
|
PropTypes.arrayOf(
|
|
|
|
PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool]),
|
|
|
|
),
|
|
|
|
PropTypes.func,
|
|
|
|
PropTypes.object,
|
|
|
|
]),
|
2024-01-30 12:50:37 +00:00
|
|
|
}
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
let columnsData = [
|
2022-12-15 22:20:33 +00:00
|
|
|
{ title: `${i18n.t("reports.listColumns.column1_1")}`, field: 'whatsapp.name' },
|
|
|
|
{ title: `${i18n.t("reports.listColumns.column1_2")}`, field: 'user.name' },
|
|
|
|
{ title: `${i18n.t("reports.listColumns.column0_4")}`, field: 'contact.number' },
|
|
|
|
{ title: `${i18n.t("reports.listColumns.column0_3")}`, field: 'contact.name' },
|
|
|
|
{ title: `${i18n.t("reports.listColumns.column1_5")}`, field: 'queue.name' },
|
2022-05-19 21:29:38 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
{ title: 'Status', field: 'status' },
|
2022-07-28 17:55:23 +00:00
|
|
|
|
2022-12-15 22:20:33 +00:00
|
|
|
{ title: `${i18n.t("reports.listColumns.column1_7")}`, field: 'createdAt' },
|
2024-01-30 12:50:37 +00:00
|
|
|
{ title: `${i18n.t("reports.listColumns.column1_8")}`, field: 'updatedAt' },
|
|
|
|
{ title: `${i18n.t("reports.listColumns.column1_9")}`, field: 'statusChatEnd' }]
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-02-01 20:46:23 +00:00
|
|
|
let columnsDataSuper = [
|
|
|
|
{ title: `${i18n.t("reports.listColumns.column1_1")}`, field: 'whatsapp.name' },
|
|
|
|
{ title: `${i18n.t("reports.listColumns.column1_2")}`, field: 'user.name' },
|
|
|
|
{ title: `${i18n.t("reports.listColumns.column0_3")}`, field: 'contact.name' },
|
|
|
|
{ title: `${i18n.t("reports.listColumns.column1_5")}`, field: 'queue.name' },
|
|
|
|
|
|
|
|
{ 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' }
|
|
|
|
]
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
// 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)
|
|
|
|
|
|
|
|
// if (isDesiredFormat) {
|
|
|
|
// // Convert the input date string to a JavaScript Date object
|
|
|
|
// const dateObj = new Date(dateString)
|
2022-07-28 17:55:23 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
// // 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)
|
2022-01-24 11:44:42 +00:00
|
|
|
//--------
|
2024-01-30 12:50:37 +00:00
|
|
|
const [searchParam] = useState("")
|
2022-07-28 17:55:23 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
const [loading, setLoading] = useState(false)
|
|
|
|
const [hasMore, setHasMore] = useState(false)
|
|
|
|
const [pageNumberTickets, setTicketsPageNumber] = useState(1)
|
|
|
|
const [totalCountTickets, setTotalCountTickets] = useState(0)
|
2022-07-28 17:55:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
const [pageNumber, setPageNumber] = useState(1)
|
|
|
|
const [users, dispatch] = useReducer(reducer, [])
|
2022-05-16 02:48:06 +00:00
|
|
|
const [startDate, setDatePicker1] = useState(new Date())
|
|
|
|
const [endDate, setDatePicker2] = useState(new Date())
|
|
|
|
const [userId, setUser] = useState(null)
|
2024-02-28 13:48:36 +00:00
|
|
|
const [query, dispatchQ] = useReducer(reducerQ, [])
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
const [reportOption, setReport] = useState('1')
|
|
|
|
const [reporList,] = useState(report)
|
|
|
|
const [profile, setProfile] = useState('')
|
2024-01-30 12:50:37 +00:00
|
|
|
const [dataRows, setData] = useState([])
|
2022-07-28 17:55:23 +00:00
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
const [onQueueStatus, setOnQueueProcessStatus] = useState(undefined)
|
2024-02-28 13:48:36 +00:00
|
|
|
const [csvFile, setCsvFile] = useState()
|
|
|
|
const [selectedValue, setSelectedValue] = useState('created')
|
|
|
|
const [checked, setChecked] = useState(true)
|
|
|
|
const [queues, setQueues] = useState([])
|
|
|
|
const [queueId, setQueue] = useState(null)
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
useEffect(() => {
|
2024-01-30 12:50:37 +00:00
|
|
|
dispatch({ type: "RESET" })
|
2022-01-25 14:24:05 +00:00
|
|
|
dispatchQ({ type: "RESET" })
|
2022-07-28 17:55:23 +00:00
|
|
|
setTicketsPageNumber(1)
|
2024-01-30 12:50:37 +00:00
|
|
|
setPageNumber(1)
|
2024-02-28 13:48:36 +00:00
|
|
|
}, [searchParam, profile])
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
2022-02-11 12:54:22 +00:00
|
|
|
//setLoading(true);
|
2022-01-25 21:54:46 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
const delayDebounceFn = setTimeout(() => {
|
2022-01-25 14:24:05 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
const fetchUsers = async () => {
|
|
|
|
try {
|
2024-01-30 12:50:37 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
const { data } = await api.get("/users/", {
|
2022-05-16 02:48:06 +00:00
|
|
|
params: { searchParam, pageNumber, profile },
|
2024-01-30 12:50:37 +00:00
|
|
|
})
|
2024-02-28 13:48:36 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
dispatch({ type: "LOAD_USERS", payload: data.users })
|
2022-08-29 13:55:07 +00:00
|
|
|
//setLoading(false);
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
} catch (err) {
|
2024-01-30 12:50:37 +00:00
|
|
|
console.log(err)
|
2022-01-24 11:44:42 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
}
|
2022-01-25 14:24:05 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
fetchUsers()
|
2022-01-25 14:24:05 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
}, 500)
|
|
|
|
return () => clearTimeout(delayDebounceFn)
|
|
|
|
}, [searchParam, pageNumber, reportOption, profile])
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
|
2022-01-25 14:24:05 +00:00
|
|
|
useEffect(() => {
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
//setLoading(true);
|
2022-01-25 14:24:05 +00:00
|
|
|
|
|
|
|
const delayDebounceFn = setTimeout(() => {
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
setLoading(true)
|
2022-01-25 14:24:05 +00:00
|
|
|
const fetchQueries = async () => {
|
|
|
|
try {
|
2024-02-28 13:48:36 +00:00
|
|
|
if (reportOption === '1') {
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
// const { data } = await api.get("/reports/", { params: { userId: userId ? userId : 0, startDate: convertAndFormatDate(startDate), endDate: convertAndFormatDate(endDate), pageNumber: pageNumberTickets }, })
|
2022-07-28 17:55:23 +00:00
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
const { data } = await api.get("/reports/", { params: { userId, startDate, endDate, pageNumber: pageNumberTickets, createdOrUpdated: selectedValue, queueId }, userQueues: userA.queues })
|
2024-01-30 12:50:37 +00:00
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
let ticketsQueue = data.tickets
|
|
|
|
let userQueues = userA.queues
|
|
|
|
let filterQueuesTickets = []
|
|
|
|
if (userQueues.length > 1) {
|
|
|
|
filterQueuesTickets = ticketsQueue.filter(ticket => userQueues.some(queue => queue?.name === ticket?.queue?.name))
|
|
|
|
} else if (userQueues.length > 0) {
|
|
|
|
filterQueuesTickets = ticketsQueue.filter(ticket => ticket?.queue?.name === userQueues[0]?.name)
|
2024-02-01 20:46:23 +00:00
|
|
|
}
|
2024-02-28 13:48:36 +00:00
|
|
|
data.tickets = filterQueuesTickets
|
2024-01-30 12:50:37 +00:00
|
|
|
dispatchQ({ type: "LOAD_QUERY", payload: data.tickets })
|
|
|
|
|
|
|
|
setHasMore(data.hasMore)
|
2022-07-28 17:55:23 +00:00
|
|
|
setTotalCountTickets(data.count)
|
2024-01-30 12:50:37 +00:00
|
|
|
setLoading(false)
|
2024-02-28 13:48:36 +00:00
|
|
|
setQueues(data.queues)
|
|
|
|
|
2022-01-25 14:24:05 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
else if (reportOption === '2') {
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
const dataQuery = await api.get("/reports/user/services", { params: { userId, startDate, endDate }, })
|
2022-05-16 02:48:06 +00:00
|
|
|
dispatchQ({ type: "RESET" })
|
2024-01-30 12:50:37 +00:00
|
|
|
dispatchQ({ type: "LOAD_QUERY", payload: dataQuery.data })
|
2022-10-25 14:16:36 +00:00
|
|
|
//setLoading(false);
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
}
|
2022-04-17 21:02:15 +00:00
|
|
|
|
2022-01-25 14:24:05 +00:00
|
|
|
} catch (err) {
|
2024-01-30 12:50:37 +00:00
|
|
|
console.log(err)
|
2022-01-25 14:24:05 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
}
|
2022-01-25 14:24:05 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
fetchQueries()
|
2022-01-24 11:44:42 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
}, 500)
|
|
|
|
return () => clearTimeout(delayDebounceFn)
|
2022-01-24 11:44:42 +00:00
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
}, [userId, queueId, checked, startDate, endDate, reportOption, pageNumberTickets, totalCountTickets, selectedValue])
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
const handleCheckBoxChange = (value) => {
|
|
|
|
setSelectedValue(value)
|
|
|
|
}
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
// Get from child 1
|
|
|
|
const datePicker1Value = (data) => {
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
setDatePicker1(data)
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get from child 2
|
|
|
|
const datePicker2Value = (data) => {
|
2022-01-24 11:44:42 +00:00
|
|
|
|
|
|
|
setDatePicker2(data)
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Get from child 3
|
|
|
|
const textFieldSelectUser = (data) => {
|
2024-02-28 13:48:36 +00:00
|
|
|
setQueue(null)
|
2022-01-24 11:44:42 +00:00
|
|
|
setUser(data)
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
2022-04-18 14:12:49 +00:00
|
|
|
|
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
const textFieldSelectQueue = (data) => {
|
|
|
|
setUser(0)
|
|
|
|
setQueue(data)
|
|
|
|
}
|
2022-04-18 14:12:49 +00:00
|
|
|
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
// Get from report option
|
2024-03-01 20:47:18 +00:00
|
|
|
const reportValue = (data) => {
|
|
|
|
if (data === '2') {
|
2024-02-28 13:48:36 +00:00
|
|
|
setChecked(true)
|
|
|
|
}
|
2024-03-01 20:47:18 +00:00
|
|
|
setReport(data)
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
useEffect(() => {
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
if (reportOption === '1') {
|
|
|
|
setProfile('')
|
|
|
|
}
|
|
|
|
else if (reportOption === '2') {
|
|
|
|
setProfile('user')
|
|
|
|
}
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2022-08-18 15:18:42 +00:00
|
|
|
}, [reportOption])
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
const delayDebounceFn = setTimeout(() => {
|
|
|
|
|
|
|
|
const fetchReportOnQueue = async () => {
|
|
|
|
try {
|
|
|
|
|
|
|
|
const queryOnQueue = await apiBroker.get("/reports/status/query/onqueue", {
|
|
|
|
params: {
|
|
|
|
adminId: userA.id,
|
2022-09-21 04:29:54 +00:00
|
|
|
baseURL: process.env.REACT_APP_BACKEND_URL_PRIVATE,
|
2022-08-29 01:09:00 +00:00
|
|
|
identifier: 'csv'
|
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
})
|
2022-08-29 01:09:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (queryOnQueue.data) {
|
|
|
|
setCsvFile(queryOnQueue.data.app.file)
|
|
|
|
setOnQueueProcessStatus(queryOnQueue.data.app.status)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
setOnQueueProcessStatus('empty')
|
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
|
|
|
|
} catch (err) {
|
2024-01-30 12:50:37 +00:00
|
|
|
console.log(err)
|
2022-08-29 01:09:00 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
}
|
2022-08-29 01:09:00 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
fetchReportOnQueue()
|
2022-08-29 01:09:00 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
}, 500)
|
|
|
|
return () => clearTimeout(delayDebounceFn)
|
2022-08-29 01:09:00 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
}, [userA])
|
|
|
|
|
|
|
|
|
|
|
|
const handleCSVDownload = async () => {
|
2022-08-29 01:09:00 +00:00
|
|
|
|
2022-09-06 04:09:52 +00:00
|
|
|
setOnQueueProcessStatus('downloading')
|
2022-08-29 01:09:00 +00:00
|
|
|
|
2022-08-29 13:55:07 +00:00
|
|
|
try {
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
let res = await apiBroker.get(`/reports/download/${csvFile}`, { responseType: 'blob' })
|
2022-08-29 01:09:00 +00:00
|
|
|
|
2022-08-29 13:55:07 +00:00
|
|
|
if (res) {
|
2024-01-30 12:50:37 +00:00
|
|
|
fileDownload(res.data, `${csvFile}`)
|
|
|
|
setOnQueueProcessStatus('empty')
|
2022-08-29 01:09:00 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
|
|
|
|
} catch (err) {
|
2024-01-30 12:50:37 +00:00
|
|
|
console.log(err)
|
2022-08-29 01:09:00 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
|
2022-08-18 15:18:42 +00:00
|
|
|
const handleCSVMessages = () => {
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
const fetchQueries = async () => {
|
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
try {
|
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
const querySavedOnQueue = await apiBroker.post("/reports/messages",
|
|
|
|
{
|
|
|
|
app: {
|
|
|
|
adminId: userA.id,
|
2022-09-21 04:29:54 +00:00
|
|
|
baseURL: process.env.REACT_APP_BACKEND_URL_PRIVATE,
|
2022-08-29 01:09:00 +00:00
|
|
|
frontURL: process.env.REACT_APP_FRONTEND_URL,
|
|
|
|
identifier: 'csv'
|
|
|
|
},
|
|
|
|
query_params: {
|
2024-03-01 20:47:18 +00:00
|
|
|
queueId: queueId,
|
2022-08-29 01:09:00 +00:00
|
|
|
userId: userId,
|
|
|
|
startDate: startDate,
|
|
|
|
endDate: endDate
|
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
})
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
const onQueueStatus = querySavedOnQueue.data.queueStatus
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
setOnQueueProcessStatus(onQueueStatus)
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
} catch (err) {
|
2024-01-30 12:50:37 +00:00
|
|
|
console.log(err)
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
}
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
fetchQueries()
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
|
2022-04-18 18:21:28 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
useEffect(() => {
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
2022-08-29 01:09:00 +00:00
|
|
|
|
|
|
|
socket.on("queryOnQueueStatus", (data) => {
|
|
|
|
if (data.action === 'update') {
|
|
|
|
|
2022-08-29 13:55:07 +00:00
|
|
|
if (String(data.queryOnQueue.adminId) === String(userA.id)) {
|
2022-08-29 01:09:00 +00:00
|
|
|
|
|
|
|
setCsvFile(data.queryOnQueue.file)
|
|
|
|
setOnQueueProcessStatus(data.queryOnQueue.queueStatus)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
if (reportOption === '2') {
|
2024-01-30 12:50:37 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-08-18 15:18:42 +00:00
|
|
|
socket.on("onlineStatus", (data) => {
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
let date = new Date().toLocaleDateString('pt-BR').split('/')
|
2022-08-18 15:18:42 +00:00
|
|
|
let dateToday = `${date[2]}-${date[1]}-${date[0]}`
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
if (data.action === "logout" || (data.action === "update" &&
|
2024-01-30 12:50:37 +00:00
|
|
|
((`${startDate}` === `${endDate}`) && (`${endDate}` === `${dateToday}`) && (`${startDate}` === `${dateToday}`)))) {
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
dispatchQ({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime })
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
else if (data.action === "delete") {
|
2024-01-30 12:50:37 +00:00
|
|
|
dispatchQ({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime })
|
2022-08-18 15:18:42 +00:00
|
|
|
}
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
})
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
socket.on("user", (data) => {
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
if (data.action === "delete") {
|
|
|
|
dispatch({ type: "DELETE_USER", payload: +data.userId })
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
})
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
}
|
2022-07-28 17:55:23 +00:00
|
|
|
else if (reportOption === "1") {
|
|
|
|
dispatchQ({ type: "RESET" })
|
|
|
|
setTicketsPageNumber(1)
|
|
|
|
}
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
return () => {
|
2024-01-30 12:50:37 +00:00
|
|
|
socket.disconnect()
|
|
|
|
}
|
2022-08-29 01:09:00 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
}, [reportOption, startDate, endDate, userId, queueId, checked, userA, selectedValue])
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
|
|
|
|
useEffect(() => {
|
2022-01-25 14:24:05 +00:00
|
|
|
|
2022-08-18 15:18:42 +00:00
|
|
|
setData(query.map((column) => { return { ...column } }))
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
}, [query])
|
|
|
|
|
|
|
|
const handleLogouOnlineUser = async (userId) => {
|
|
|
|
try {
|
2024-01-30 12:50:37 +00:00
|
|
|
await api.get(`/users/logout/${userId}`)
|
2022-05-16 02:48:06 +00:00
|
|
|
//toast.success(("Desloged!"));
|
|
|
|
//handleDeleteRows(scheduleId)
|
|
|
|
} catch (err) {
|
|
|
|
// toastError(err);
|
|
|
|
}
|
|
|
|
|
2022-07-28 17:55:23 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
}
|
2022-07-28 17:55:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
const loadMore = () => {
|
2024-01-30 12:50:37 +00:00
|
|
|
setTicketsPageNumber((prevState) => prevState + 1)
|
|
|
|
}
|
2022-07-28 17:55:23 +00:00
|
|
|
|
|
|
|
const handleScroll = (e) => {
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
if (!hasMore || loading) return
|
2022-07-28 17:55:23 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
const { scrollTop, scrollHeight, clientHeight } = e.currentTarget
|
2022-07-28 17:55:23 +00:00
|
|
|
|
2022-08-18 15:18:42 +00:00
|
|
|
if (scrollHeight - (scrollTop + 1) < clientHeight) {
|
2022-07-28 17:55:23 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
loadMore()
|
|
|
|
|
2022-07-28 17:55:23 +00:00
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
}
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
const renderSwitch = (param) => {
|
|
|
|
switch (param) {
|
|
|
|
case 'empty':
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Button
|
2022-08-29 13:55:07 +00:00
|
|
|
disabled={query && query.length > 0 ? false : true}
|
2022-08-29 01:09:00 +00:00
|
|
|
variant="contained"
|
|
|
|
color="primary"
|
|
|
|
onClick={(e) => {
|
|
|
|
handleCSVMessages()
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{"CSV ALL"}
|
|
|
|
</Button>
|
2024-01-30 12:50:37 +00:00
|
|
|
</>)
|
2022-08-29 01:09:00 +00:00
|
|
|
|
|
|
|
case 'pending' || 'processing':
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<span>PROCESSING...</span>
|
2024-01-30 12:50:37 +00:00
|
|
|
</>)
|
2022-08-29 01:09:00 +00:00
|
|
|
|
|
|
|
case 'success':
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Button
|
|
|
|
variant="contained"
|
2024-01-30 12:50:37 +00:00
|
|
|
color="primary"
|
2022-08-29 01:09:00 +00:00
|
|
|
onClick={(e) => {
|
2022-09-06 04:09:52 +00:00
|
|
|
handleCSVDownload(e)
|
2022-08-29 01:09:00 +00:00
|
|
|
}}
|
|
|
|
>
|
2022-09-06 04:09:52 +00:00
|
|
|
{'CSV DOWNLOAD'}
|
2022-08-29 01:09:00 +00:00
|
|
|
</Button>
|
2024-01-30 12:50:37 +00:00
|
|
|
</>)
|
|
|
|
case 'downloading':
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<span>DOWNLOADING...</span>
|
|
|
|
</>)
|
|
|
|
|
2022-08-29 01:09:00 +00:00
|
|
|
|
|
|
|
default:
|
2024-01-30 12:50:37 +00:00
|
|
|
return (<><span>WAITING...</span></>)
|
2022-08-29 01:09:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
const handleChange = (event) => {
|
|
|
|
setChecked(event.target.checked)
|
|
|
|
}
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
return (
|
2022-01-25 14:24:05 +00:00
|
|
|
|
2022-01-27 00:33:16 +00:00
|
|
|
<Can
|
2022-05-16 02:48:06 +00:00
|
|
|
role={userA.profile}
|
|
|
|
perform="ticket-report:show"
|
|
|
|
yes={() => (
|
|
|
|
|
|
|
|
<MainContainer>
|
2024-02-28 13:48:36 +00:00
|
|
|
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 2fr) repeat(2, 1fr)', gap: '8px' }}>
|
|
|
|
|
|
|
|
<Box sx={{ display: 'flex', flexDirection: 'column', padding: '10px 0', alignItems: 'center', }}>
|
|
|
|
|
|
|
|
{checked ?
|
|
|
|
<SelectField
|
|
|
|
func={textFieldSelectUser}
|
|
|
|
emptyField={true}
|
|
|
|
header={i18n.t("reports.user")}
|
|
|
|
currencies={users.map((obj) => {
|
|
|
|
return { 'value': obj.id, 'label': obj.name }
|
|
|
|
})} /> :
|
|
|
|
<SelectField
|
|
|
|
func={textFieldSelectQueue}
|
|
|
|
emptyField={true}
|
|
|
|
header={'Filas'}
|
|
|
|
currencies={queues.map((obj) => {
|
|
|
|
return { 'value': obj.id, 'label': obj.name }
|
|
|
|
})} />
|
|
|
|
}
|
|
|
|
|
|
|
|
{reportOption === '1' &&
|
|
|
|
<div>
|
|
|
|
<label>
|
|
|
|
Filas
|
|
|
|
<Switch
|
|
|
|
checked={checked}
|
|
|
|
onChange={handleChange}
|
|
|
|
inputProps={{ 'aria-label': 'controlled' }}
|
|
|
|
/>
|
|
|
|
Usuarios
|
|
|
|
</label>
|
|
|
|
</div>
|
|
|
|
}
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
</Box>
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
<Box sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
|
|
|
|
<DatePicker1 func={datePicker1Value} minDate={false} startEmpty={false} title={i18n.t("reports.dateStart")} />
|
|
|
|
</Box>
|
|
|
|
<Box sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center' }}><DatePicker2 func={datePicker2Value} minDate={false} startEmpty={false} title={i18n.t("reports.dateEnd")} /></Box>
|
|
|
|
|
|
|
|
{reportOption === '1' ?
|
|
|
|
<Box sx={{ display: 'flex', flexDirection: 'column', padding: '10px 0', }}>
|
|
|
|
<FormControlLabel
|
|
|
|
control={<Checkbox checked={selectedValue === 'created'} onChange={() => handleCheckBoxChange('created')} />}
|
|
|
|
label="Criado"
|
|
|
|
/>
|
|
|
|
<FormControlLabel
|
|
|
|
control={<Checkbox checked={selectedValue === 'updated'} onChange={() => handleCheckBoxChange('updated')} />}
|
|
|
|
label="Atualizado"
|
|
|
|
/>
|
|
|
|
</Box> :
|
|
|
|
|
|
|
|
<Box sx={{ display: 'flex', flexDirection: 'column', padding: '10px 0', }}>
|
|
|
|
|
|
|
|
</Box>
|
|
|
|
}
|
|
|
|
|
|
|
|
<Box sx={{ display: 'flex', flexDirection: 'column', padding: '10px 0', gap: '8px', width: '100px', alignItems: 'center' }}>
|
2022-04-18 14:12:49 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
<ReportModal currencies={reporList} func={reportValue} reportOption={reportOption} />
|
|
|
|
|
2022-05-16 03:33:09 +00:00
|
|
|
<div style={{ margin: '2px' }}></div>
|
|
|
|
|
2022-08-29 13:55:07 +00:00
|
|
|
{reportOption === '1' &&
|
2022-07-28 17:55:23 +00:00
|
|
|
<div>
|
2022-08-29 01:09:00 +00:00
|
|
|
{renderSwitch(onQueueStatus)}
|
2022-05-16 03:33:09 +00:00
|
|
|
</div>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
|
2024-02-28 13:48:36 +00:00
|
|
|
</Box>
|
2022-05-16 03:33:09 +00:00
|
|
|
|
2022-01-24 11:44:42 +00:00
|
|
|
</Box>
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
<Box sx={{
|
|
|
|
display: 'grid',
|
|
|
|
}}>
|
|
|
|
|
|
|
|
<Item sx={{ gridColumn: '1', gridRow: 'span 1' }}>
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
{reportOption === '1' &&
|
2022-07-28 17:55:23 +00:00
|
|
|
|
2024-03-01 20:47:18 +00:00
|
|
|
<>
|
2022-07-28 17:55:23 +00:00
|
|
|
<MTable data={query}
|
2024-02-28 13:48:36 +00:00
|
|
|
columns={userA.profile !== 'supervisor' ? columnsData : columnsDataSuper}
|
2022-07-28 17:55:23 +00:00
|
|
|
hasChild={true}
|
|
|
|
removeClickRow={false}
|
|
|
|
|
|
|
|
handleScroll={handleScroll}
|
|
|
|
|
2024-03-01 20:47:18 +00:00
|
|
|
table_title={i18n.t("reports.listTitles.title1_1")} />
|
2022-07-28 17:55:23 +00:00
|
|
|
</>
|
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
{reportOption === '2' &&
|
|
|
|
|
|
|
|
<MaterialTable
|
|
|
|
|
|
|
|
localization={{
|
|
|
|
|
|
|
|
header: {
|
|
|
|
actions: 'Deslogar'
|
|
|
|
},
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
2022-12-15 22:20:33 +00:00
|
|
|
title={i18n.t("reports.listTitles.title3_1")}
|
2022-05-16 02:48:06 +00:00
|
|
|
columns={
|
|
|
|
[
|
|
|
|
|
|
|
|
// { title: 'Foto', field: 'ticket.contact.profilePicUrl', render: rowData => <img src={rowData['ticket.contact.profilePicUrl']} alt="imagem de perfil do whatsapp" style={{ width: 40, borderRadius: '50%' }} /> },
|
2022-07-28 17:55:23 +00:00
|
|
|
{ title: 'Nome', field: 'name', cellStyle: { whiteSpace: 'nowrap' }, },
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
title: 'Status', field: 'statusOnline.status',
|
|
|
|
|
|
|
|
cellStyle: (e, rowData) => {
|
|
|
|
|
|
|
|
if (rowData['statusOnline'] && rowData['statusOnline'].status) {
|
2022-05-16 03:33:09 +00:00
|
|
|
|
2022-05-16 02:48:06 +00:00
|
|
|
if (rowData['statusOnline'].status === 'offline') {
|
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
return { color: "red" }
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
else if (rowData['statusOnline'].status === 'online') {
|
2024-01-30 12:50:37 +00:00
|
|
|
return { color: "green" }
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
else if (rowData['statusOnline'].status === 'logout...') {
|
2024-01-30 12:50:37 +00:00
|
|
|
return { color: "orange" }
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
else if (rowData['statusOnline'].status === 'waiting...') {
|
2024-01-30 12:50:37 +00:00
|
|
|
return { color: "orange" }
|
2022-05-16 02:48:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
{ title: 'Tempo online', field: 'sumOnlineTime.sum' },
|
2022-12-15 22:20:33 +00:00
|
|
|
{ title: `${i18n.t("reports.dateStart")}`, field: 'startDate' },
|
2022-12-27 14:25:50 +00:00
|
|
|
{ title: `${i18n.t("reports.dateEnd")}`, field: 'endDate' },
|
2022-05-16 02:48:06 +00:00
|
|
|
{ title: 'Em atendimento', field: 'sumOpen.count' },
|
|
|
|
{ title: 'Finalizado', field: 'sumClosed.count' },
|
|
|
|
|
|
|
|
]
|
|
|
|
}
|
2024-01-30 12:50:37 +00:00
|
|
|
data={dataRows}
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
actions={[
|
|
|
|
(rowData) => {
|
|
|
|
|
|
|
|
if (rowData.statusOnline &&
|
|
|
|
rowData.statusOnline['status'] &&
|
|
|
|
rowData.statusOnline['status'] === 'online') {
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
icon: LogoutIcon,
|
|
|
|
tooltip: 'deslogar',
|
|
|
|
disable: false,
|
2024-01-30 12:50:37 +00:00
|
|
|
onClick: (event, rowData) => {
|
2022-05-16 02:48:06 +00:00
|
|
|
handleLogouOnlineUser(rowData.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]}
|
|
|
|
|
|
|
|
|
|
|
|
options={
|
|
|
|
{
|
|
|
|
search: true,
|
|
|
|
selection: false,
|
|
|
|
paging: false,
|
|
|
|
padding: 'dense',
|
2024-01-30 12:50:37 +00:00
|
|
|
sorting: true,
|
2022-05-16 02:48:06 +00:00
|
|
|
searchFieldStyle: {
|
|
|
|
width: 300,
|
|
|
|
},
|
|
|
|
|
|
|
|
pageSize: 20,
|
|
|
|
headerStyle: {
|
|
|
|
position: "sticky",
|
|
|
|
top: "0"
|
|
|
|
},
|
|
|
|
maxBodyHeight: "400px",
|
|
|
|
|
|
|
|
rowStyle: {
|
|
|
|
fontSize: 14,
|
2024-01-30 12:50:37 +00:00
|
|
|
}
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</Item>
|
|
|
|
|
|
|
|
</Box>
|
2022-01-24 11:44:42 +00:00
|
|
|
</MainContainer>
|
2022-05-16 02:48:06 +00:00
|
|
|
|
|
|
|
)}
|
|
|
|
/>
|
2022-01-24 11:44:42 +00:00
|
|
|
)
|
2024-01-30 12:50:37 +00:00
|
|
|
}
|
2022-01-24 11:44:42 +00:00
|
|
|
|
2024-01-30 12:50:37 +00:00
|
|
|
export default Report
|