+
-
+
diff --git a/frontend/src/components/TicketActionButtons/index.js b/frontend/src/components/TicketActionButtons/index.js
index 3919503..58feff5 100644
--- a/frontend/src/components/TicketActionButtons/index.js
+++ b/frontend/src/components/TicketActionButtons/index.js
@@ -12,167 +12,147 @@ import ButtonWithSpinner from "../ButtonWithSpinner";
import toastError from "../../errors/toastError";
import { AuthContext } from "../../context/Auth/AuthContext";
-import Modal from "../ChatEnd/ModalChatEnd";
-import { render } from '@testing-library/react';
+import Modal from "../ChatEnd/ModalChatEnd";
+import { render } from "@testing-library/react";
-const useStyles = makeStyles(theme => ({
- actionButtons: {
- marginRight: 6,
- flex: "none",
- alignSelf: "center",
- marginLeft: "auto",
- "& > *": {
- margin: theme.spacing(1),
- },
- },
+const useStyles = makeStyles((theme) => ({
+ actionButtons: {
+ marginRight: 6,
+ flex: "none",
+ alignSelf: "center",
+ marginLeft: "auto",
+ "& > *": {
+ margin: theme.spacing(1),
+ },
+ },
}));
const TicketActionButtons = ({ ticket, statusChatEnd }) => {
- const classes = useStyles();
- const history = useHistory();
- const [anchorEl, setAnchorEl] = useState(null);
- const [loading, setLoading] = useState(false);
- const ticketOptionsMenuOpen = Boolean(anchorEl);
- const { user } = useContext(AuthContext);
-
- const handleOpenTicketOptionsMenu = e => {
- setAnchorEl(e.currentTarget);
- };
+ const classes = useStyles();
+ const history = useHistory();
+ const [anchorEl, setAnchorEl] = useState(null);
+ const [loading, setLoading] = useState(false);
+ const ticketOptionsMenuOpen = Boolean(anchorEl);
+ const { user } = useContext(AuthContext);
- const handleCloseTicketOptionsMenu = e => {
- setAnchorEl(null);
- };
+ const handleOpenTicketOptionsMenu = (e) => {
+ setAnchorEl(e.currentTarget);
+ };
-
- const chatEndVal = (data) => {
-
- if(data){
+ const handleCloseTicketOptionsMenu = (e) => {
+ setAnchorEl(null);
+ };
- data = {...data, 'ticketId': ticket.id}
-
- console.log('ChatEnd: ',(data));
+ const chatEndVal = (data) => {
+ if (data) {
+ data = { ...data, ticketId: ticket.id };
- handleUpdateTicketStatus(null, "closed", user?.id, data)
+ console.log("ChatEnd: ", data);
- }
-
- }
+ handleUpdateTicketStatus(null, "closed", user?.id, data);
+ }
+ };
+ const handleModal = (/*status, userId*/) => {
+ render(
+
+ );
+ };
- const handleModal = (/*status, userId*/) => {
+ const handleUpdateTicketStatus = async (e, status, userId, schedulingData = {}) => {
+ setLoading(true);
+ try {
+ if (status === "closed") {
+ await api.put(`/tickets/${ticket.id}`, {
+ status: status,
+ userId: userId || null,
+ schedulingNotifyData: JSON.stringify(schedulingData),
+ });
+ } else {
+ await api.put(`/tickets/${ticket.id}`, {
+ status: status,
+ userId: userId || null,
+ });
+ }
- render(
)
-
- };
-
+ setLoading(false);
+ if (status === "open") {
+ history.push(`/tickets/${ticket.id}`);
+ } else {
+ history.push("/tickets");
+ }
+ } catch (err) {
+ setLoading(false);
+ toastError(err);
+ }
+ };
- const handleUpdateTicketStatus = async (e, status, userId, schedulingData={}) => {
-
- setLoading(true);
- try {
-
- if(status==='closed'){
+ return (
+
+ {ticket.status === "closed" && (
+
}
+ size="small"
+ onClick={(e) => handleUpdateTicketStatus(e, "open", user?.id)}
+ >
+ {i18n.t("messagesList.header.buttons.reopen")}
+
+ )}
+ {ticket.status === "open" && (
+ <>
+
}
+ size="small"
+ onClick={(e) => handleUpdateTicketStatus(e, "pending", null)}
+ >
+ {i18n.t("messagesList.header.buttons.return")}
+
- await api.put(`/tickets/${ticket.id}`, {
- status: status,
- userId: userId || null,
- schedulingNotifyData: JSON.stringify(schedulingData)
- });
+
{
+ handleModal();
+ // handleUpdateTicketStatus(e, "closed", user?.id)
+ }}
+ >
+ {i18n.t("messagesList.header.buttons.resolve")}
+
- }
- else{
-
- await api.put(`/tickets/${ticket.id}`, {
- status: status,
- userId: userId || null
- });
-
- }
-
- setLoading(false);
- if (status === "open") {
- history.push(`/tickets/${ticket.id}`);
- } else {
- history.push("/tickets");
- }
- } catch (err) {
- setLoading(false);
- toastError(err);
- }
-
-
-
-
- };
-
- return (
-
- {ticket.status === "closed" && (
- }
- size="small"
- onClick={e => handleUpdateTicketStatus(e, "open", user?.id)}
- >
- {i18n.t("messagesList.header.buttons.reopen")}
-
- )}
- {ticket.status === "open" && (
- <>
- }
- size="small"
- onClick={e => handleUpdateTicketStatus(e, "pending", null)}
- >
- {i18n.t("messagesList.header.buttons.return")}
-
-
- {
-
-
- handleModal()
- // handleUpdateTicketStatus(e, "closed", user?.id)
-
- }}
- >
- {i18n.t("messagesList.header.buttons.resolve")}
-
-
-
-
-
-
- >
- )}
- {ticket.status === "pending" && (
- handleUpdateTicketStatus(e, "open", user?.id)}
- >
- {i18n.t("messagesList.header.buttons.accept")}
-
- )}
-
- );
+
+
+
+
+ >
+ )}
+ {ticket.status === "pending" && (
+
handleUpdateTicketStatus(e, "open", user?.id)}
+ >
+ {i18n.t("messagesList.header.buttons.accept")}
+
+ )}
+
+ );
};
export default TicketActionButtons;
+
diff --git a/frontend/src/components/TicketsQueueSelect/index.js b/frontend/src/components/TicketsQueueSelect/index.js
index 2d4d225..e3d1f09 100644
--- a/frontend/src/components/TicketsQueueSelect/index.js
+++ b/frontend/src/components/TicketsQueueSelect/index.js
@@ -6,55 +6,52 @@ import Select from "@material-ui/core/Select";
import { Checkbox, ListItemText } from "@material-ui/core";
import { i18n } from "../../translate/i18n";
-const TicketsQueueSelect = ({
- userQueues,
- selectedQueueIds = [],
- onChange,
-}) => {
- const handleChange = e => {
- onChange(e.target.value);
- };
+const TicketsQueueSelect = ({ userQueues, selectedQueueIds = [], onChange }) => {
+ const handleChange = (e) => {
+ onChange(e.target.value);
+ };
- return (
-
-
-
-
-
- );
+ return (
+
+
+
+
+
+ );
};
export default TicketsQueueSelect;
+
diff --git a/frontend/src/components/UserModal/UserModal.jsx b/frontend/src/components/UserModal/UserModal.jsx
index 3f9776c..f3cd056 100644
--- a/frontend/src/components/UserModal/UserModal.jsx
+++ b/frontend/src/components/UserModal/UserModal.jsx
@@ -6,30 +6,62 @@ import api from "../../services/api";
import { AuthContext } from "../../context/Auth/AuthContext";
import { Can } from "../Can";
-import BtnComponent from "../Base/BTN/Btn";
+import BtnComponent from "../Base/Btn/Btn";
import FormComponent from "../Base/Form/FormComponent";
import InputComponent from "../Base/Form/Input/InputComponent";
import UserModalComponent from "./UserModalImg/UserModalComponent";
import UserImg from "../../assets/images/User/user.jpg";
-const UserModal = ({ modal, click }) => {
+const UserModal = ({ modal, click, userId }) => {
const { user } = React.useContext(AuthContext);
- const initalData = {
- name: user.name,
- email: user.email,
- perfil:user.profile,
- }
- console.log(user);
+ const InitalState = {
+ name: "",
+ email: "",
+ password: "",
+ profile: "",
+ };
+ const [userData, setUserData] = React.useState(InitalState);
+ const [selectedQueueIds, setSelectedQueueIds] = React.useState([]);
+
+ React.useEffect(() => {
+ // const fetchUser = async () => {
+ // if (!userId) return;
+ // try {
+ // const { data } = await api.get(`/users/${userId}`);
+ // setUserData((prevState) => {
+ // return console.log({ ...prevState, ...data });
+ // });
+ // const userQueueIds = data.queues?.map((queue) => queue.id);
+ // setSelectedQueueIds(userQueueIds);
+ // } catch (err) {
+ // alert(err);
+ // }
+ // };
+
+ // fetchUser();
+ }, [userId]);
return (
-
-
+ setUserData({ name: event.target.data })}
+ />
+ setUserData({ email: event.target.data })}
+ />
@@ -53,4 +85,5 @@ id: 2
name: "teste"
profile: "master"
queues: []
-tokenVersion: 0 */
\ No newline at end of file
+tokenVersion: 0 */
+
diff --git a/frontend/src/layout/index.js b/frontend/src/layout/index.js
index 353899e..cfc1d04 100644
--- a/frontend/src/layout/index.js
+++ b/frontend/src/layout/index.js
@@ -1,21 +1,16 @@
import React from "react";
-import Loading from "../components/LoadingScreen/Loading";
+import LoadingScreen from "../components/LoadingScreen/LoadingScreen";
import MainContainer from "../components/Base/MainContainer/MainContainer";
import { AuthContext } from "../context/Auth/AuthContext";
import { i18n } from "../translate/i18n";
import MenuComponent from "../components/Menu/MenuComponent";
const LoggedInLayout = ({ children }) => {
- const { handleLogout, loading, isAuth } = React.useContext(AuthContext);
- const logout = (e) => {
- handleLogout();
- };
- const { user } = React.useContext(AuthContext);
- console.log(user.name);
+ const { loading, user } = React.useContext(AuthContext);
if (loading) {
- return ;
+ return ;
}
return (
diff --git a/frontend/src/pages/Report/index.js b/frontend/src/pages/Report/index.js
index 4b5d94d..be8b5c1 100644
--- a/frontend/src/pages/Report/index.js
+++ b/frontend/src/pages/Report/index.js
@@ -2,109 +2,97 @@ import React, { useState, useEffect, useReducer, useContext, useRef } from "reac
import MainContainer from "../../components/MainContainer";
import api from "../../services/api";
import SelectField from "../../components/Report/SelectField";
-//import { data } from '../../components/Report/MTable/data';
-import DatePicker1 from '../../components/Report/DatePicker'
-import DatePicker2 from '../../components/Report/DatePicker'
+//import { data } from '../../components/Report/MTable/data';
+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 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 ReportModal from "../../components/ReportModal";
-import MaterialTable from 'material-table';
+import MaterialTable from "material-table";
-import LogoutIcon from '@material-ui/icons/CancelOutlined';
+import LogoutIcon from "@material-ui/icons/CancelOutlined";
import { CSVLink } from "react-csv";
+import openSocket from "socket.io-client";
-import openSocket from "socket.io-client";
-
-const report = [{ 'value': '1', 'label': 'Atendimento por atendentes' }, { 'value': '2', 'label': 'Usuários online/offline' }]
+const report = [
+ { value: "1", label: "Atendimento por atendentes" },
+ { value: "2", label: "Usuários online/offline" },
+];
let columns = [
{
- key: 'ticket.whatsapp.name',
- label: 'Loja',
-
+ key: "ticket.whatsapp.name",
+ label: "Loja",
},
{
- key: 'id',
- label: 'id Mensagem',
+ key: "id",
+ label: "id Mensagem",
},
{
- key: 'ticket.id',
- label: 'id Conversa',
+ key: "ticket.id",
+ label: "id Conversa",
},
{
- key: 'ticket.contact.name',
- label: 'Cliente',
+ key: "ticket.contact.name",
+ label: "Cliente",
},
{
- key: 'ticket.user.name',
- label: 'Atendente',
+ key: "ticket.user.name",
+ label: "Atendente",
},
{
- key: 'body',
- label: 'Mensagem',
+ key: "body",
+ label: "Mensagem",
},
{
- key: 'fromMe',
- label: 'Sentido',
+ key: "fromMe",
+ label: "Sentido",
},
{
- key: 'createdAt',
- label: 'Criada',
+ key: "createdAt",
+ label: "Criada",
},
{
- key: 'ticket.contact.number',
- label: 'Telefone cliente',
+ key: "ticket.contact.number",
+ label: "Telefone cliente",
},
{
- key: 'ticket.queue.name',
- label: 'Fila',
+ key: "ticket.queue.name",
+ label: "Fila",
},
{
- key: 'ticket.status',
- label: 'Status',
+ key: "ticket.status",
+ label: "Status",
},
{
- key: 'ticket.statusChatEnd',
- label: 'Status de encerramento',
- }
-
-]
+ key: "ticket.statusChatEnd",
+ label: "Status de encerramento",
+ },
+];
//
-
-
-
-
-
-
-
const reducerQ = (state, action) => {
-
-
-
-
if (action.type === "DELETE_USER_STATUS") {
-
const userId = action.payload;
//console.log('Entrou no delete user status userId: ', userId)
const userIndex = state.findIndex((u) => `${u.id}` === `${userId}`);
- // console.log('>>>>>>>>>>>>>>>>>>>>> userIndex: ', userIndex)
+ // console.log('>>>>>>>>>>>>>>>>>>>>> userIndex: ', userIndex)
if (userIndex !== -1) {
state.splice(userIndex, 1);
@@ -113,115 +101,90 @@ const reducerQ = (state, action) => {
return [...state];
}
-
-
- if (action.type === 'LOAD_QUERY') {
-
-
- const queries = action.payload
- const newQueries = []
+ if (action.type === "LOAD_QUERY") {
+ const queries = action.payload;
+ const newQueries = [];
queries.forEach((query) => {
-
- const queryIndex = state.findIndex((q) => q.id === query.id)
+ const queryIndex = state.findIndex((q) => q.id === query.id);
if (queryIndex !== -1) {
- state[queryIndex] = query
- }
- else {
- newQueries.push(query)
+ state[queryIndex] = query;
+ } else {
+ newQueries.push(query);
}
+ });
- })
-
- return [...state, ...newQueries]
+ return [...state, ...newQueries];
}
-
if (action.type === "UPDATE_STATUS_ONLINE") {
+ let onlineUser = action.payload;
+ let index = -1;
- let onlineUser = action.payload
- let index = -1
-
- // console.log('sssssssssstate: ', state, ' | ONLINE USERS: onlineUser.userId ', onlineUser.userId)
+ // console.log('sssssssssstate: ', state, ' | ONLINE USERS: onlineUser.userId ', onlineUser.userId)
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}`)
+ 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}`);
}
- //console.log(' *********************** index: ', index)
-
-
+ //console.log(' *********************** index: ', index)
if (index !== -1) {
-
- // console.log('ENTROU NO INDEX')
-
+ // console.log('ENTROU NO INDEX')
if (!("statusOnline" in state[index])) {
- state[index].statusOnline = onlineUser
+ state[index].statusOnline = onlineUser;
+ } else if ("statusOnline" in state[index]) {
+ state[index].statusOnline["status"] = onlineUser.status;
}
- 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] }
+ 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) {
-
if ("sumOpen" in state[index]) {
- // console.log(' >>>>>>>>>>>>>>>>>> sumOpen 1 | state[index].sumOpen["count"]: ', state[index].sumOpen['count'], ' | onlineUser.sumOpen.count: ', onlineUser.sumOpen.count)
- state[index].sumOpen['count'] = onlineUser.sumOpen.count
+ // console.log(' >>>>>>>>>>>>>>>>>> sumOpen 1 | state[index].sumOpen["count"]: ', state[index].sumOpen['count'], ' | onlineUser.sumOpen.count: ', onlineUser.sumOpen.count)
+ state[index].sumOpen["count"] = onlineUser.sumOpen.count;
} else if (!("sumOpen" in state[index])) {
- // console.log(' >>>>>>>>>>>>>>>>>> sumOpen 1')
- state[index].sumOpen = onlineUser.sumOpen
+ // console.log(' >>>>>>>>>>>>>>>>>> sumOpen 1')
+ state[index].sumOpen = onlineUser.sumOpen;
}
-
}
if (onlineUser.sumClosed) {
-
if ("sumClosed" in state[index]) {
- // console.log(' >>>>>>>>>>>>>>>>>> sumClosed 1 | state[index].sumClosed["count"]: ', state[index].sumClosed['count'], ' | onlineUser.sumClosed.count: ', onlineUser.sumClosed.count)
- state[index].sumClosed['count'] = onlineUser.sumClosed.count
+ // console.log(' >>>>>>>>>>>>>>>>>> sumClosed 1 | state[index].sumClosed["count"]: ', state[index].sumClosed['count'], ' | onlineUser.sumClosed.count: ', onlineUser.sumClosed.count)
+ state[index].sumClosed["count"] = onlineUser.sumClosed.count;
} else if (!("sumClosed" in state[index])) {
- // console.log(' >>>>>>>>>>>>>>>>>> sumOpen 1')
- state[index].sumClosed = onlineUser.sumClosed
+ // console.log(' >>>>>>>>>>>>>>>>>> sumOpen 1')
+ state[index].sumClosed = onlineUser.sumClosed;
}
-
}
-
-
}
- return [...state]
-
+ return [...state];
}
-
-
if (action.type === "RESET") {
return [];
}
-
-}
-
-
+};
const reducer = (state, action) => {
-
if (action.type === "LOAD_USERS") {
const users = action.payload;
const newUsers = [];
@@ -253,24 +216,20 @@ const reducer = (state, action) => {
}
};
-
-
-
function Item(props) {
const { sx, ...other } = props;
return (
(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',
+ 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',
+ fontSize: "0.875rem",
+ fontWeight: "700",
...sx,
}}
{...other}
@@ -280,76 +239,64 @@ function Item(props) {
Item.propTypes = {
sx: PropTypes.oneOfType([
- PropTypes.arrayOf(
- PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool]),
- ),
+ PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.func, PropTypes.object, PropTypes.bool])),
PropTypes.func,
PropTypes.object,
]),
};
-
-
let columnsData = [
- { title: 'Unidade', field: 'whatsapp.name' },
- { title: 'Atendente', field: 'user.name' },
- { title: 'Contato', field: 'contact.number' },
- { title: 'Nome', field: 'contact.name' },
- { title: 'Assunto', field: 'queue.name' },
+ { title: "Unidade", field: "whatsapp.name" },
+ { title: "Atendente", field: "user.name" },
+ { title: "Contato", field: "contact.number" },
+ { title: "Nome", field: "contact.name" },
+ { title: "Assunto", field: "queue.name" },
- { title: 'Status', field: 'status' },
-
- { title: 'Criado', field: 'createdAt' },
+ { title: "Status", field: "status" },
+
+ { title: "Criado", field: "createdAt" },
//{title: 'Atualizado', field: 'updatedAt'},
- {title: 'Status de encerramento', field: 'statusChatEnd'}];
-
+ { title: "Status de encerramento", field: "statusChatEnd" },
+];
const Report = () => {
-
- const csvLink = useRef()
+ const csvLink = useRef();
const { user: userA } = useContext(AuthContext);
- //--------
+ //--------
const [searchParam] = useState("");
//const [loading, setLoading] = useState(false);
- //const [hasMore, setHasMore] = useState(false);
+ //const [hasMore, setHasMore] = useState(false);
const [pageNumber, setPageNumber] = useState(1);
const [users, dispatch] = useReducer(reducer, []);
- //const [columns, setColums] = useState([])
- const [startDate, setDatePicker1] = useState(new Date())
- const [endDate, setDatePicker2] = useState(new Date())
- const [userId, setUser] = useState(null)
- const [query, dispatchQ] = useReducer(reducerQ, [])
+ //const [columns, setColums] = useState([])
+ const [startDate, setDatePicker1] = useState(new Date());
+ const [endDate, setDatePicker2] = useState(new Date());
+ const [userId, setUser] = useState(null);
+ const [query, dispatchQ] = useReducer(reducerQ, []);
- const [dataCSV, setDataCSV] = useState([])
+ const [dataCSV, setDataCSV] = useState([]);
const [isMount, setIsMount] = useState(true);
- const [reportOption, setReport] = useState('1')
- const [reporList,] = useState(report)
- const [profile, setProfile] = useState('')
+ const [reportOption, setReport] = useState("1");
+ const [reporList] = useState(report);
+ const [profile, setProfile] = useState("");
const [dataRows, setData] = useState([]);
-
-
-
useEffect(() => {
dispatch({ type: "RESET" });
- dispatchQ({ type: "RESET" })
+ dispatchQ({ type: "RESET" });
setPageNumber(1);
}, [searchParam, profile]);
-
-
useEffect(() => {
- //setLoading(true);
+ //setLoading(true);
const delayDebounceFn = setTimeout(() => {
-
const fetchUsers = async () => {
try {
-
//console.log('profile: ', profile)
const { data } = await api.get("/users/", {
@@ -358,111 +305,87 @@ const Report = () => {
dispatch({ type: "LOAD_USERS", payload: data.users });
//setHasMore(data.hasMore);
- //setLoading(false);
-
-
+ //setLoading(false);
} catch (err) {
console.log(err);
}
};
fetchUsers();
-
}, 500);
return () => clearTimeout(delayDebounceFn);
}, [searchParam, pageNumber, reportOption, profile]);
-
-
useEffect(() => {
-
//setLoading(true);
const delayDebounceFn = setTimeout(() => {
-
const fetchQueries = async () => {
try {
-
- if (reportOption === '1') {
-
- const dataQuery = await api.get("/reports/", { params: { userId, startDate, endDate }, });
- dispatchQ({ type: "RESET" })
+ if (reportOption === "1") {
+ const dataQuery = await api.get("/reports/", {
+ params: { userId, startDate, endDate },
+ });
+ dispatchQ({ type: "RESET" });
dispatchQ({ type: "LOAD_QUERY", payload: dataQuery.data });
//setLoading(false);
- // console.log('dataQuery: ', dataQuery.data)
+ // console.log('dataQuery: ', dataQuery.data)
- // console.log()
-
- }
- else if (reportOption === '2') {
-
- const dataQuery = await api.get("/reports/user/services", { params: { userId, startDate, endDate }, });
- dispatchQ({ type: "RESET" })
+ // console.log()
+ } else if (reportOption === "2") {
+ const dataQuery = await api.get("/reports/user/services", {
+ params: { userId, startDate, endDate },
+ });
+ dispatchQ({ type: "RESET" });
dispatchQ({ type: "LOAD_QUERY", payload: dataQuery.data });
//setLoading(false);
- // console.log('REPORT 2 dataQuery : ', dataQuery.data)
+ // console.log('REPORT 2 dataQuery : ', dataQuery.data)
//console.log()
-
}
-
} catch (err) {
console.log(err);
}
};
fetchQueries();
-
}, 500);
return () => clearTimeout(delayDebounceFn);
-
}, [userId, startDate, endDate, reportOption]);
-
// Get from child 1
const datePicker1Value = (data) => {
-
- setDatePicker1(data)
- }
+ setDatePicker1(data);
+ };
// Get from child 2
const datePicker2Value = (data) => {
-
- setDatePicker2(data)
- }
+ setDatePicker2(data);
+ };
// Get from child 3
const textFieldSelectUser = (data) => {
-
- setUser(data)
- }
-
-
-
+ setUser(data);
+ };
// Get from report option
const reportValue = (data) => {
+ setReport(data);
- setReport(data)
-
- // console.log(' data: ', data)
- }
+ // console.log(' data: ', data)
+ };
useEffect(() => {
-
- if (reportOption === '1') {
- setProfile('')
+ if (reportOption === "1") {
+ setProfile("");
+ } else if (reportOption === "2") {
+ setProfile("user");
}
- else if (reportOption === '2') {
- setProfile('user')
- }
-
- }, [reportOption])
-
+ }, [reportOption]);
// useEffect(() => {
@@ -470,108 +393,87 @@ const Report = () => {
// }, [query])
-
-
- // test del
+ // test del
const handleCSVMessages = () => {
-
- // setLoading(true);
+ // setLoading(true);
const fetchQueries = async () => {
-
try {
+ const dataQuery = await api.get("/reports/messages", {
+ params: { userId, startDate, endDate },
+ });
- const dataQuery = await api.get("/reports/messages", { params: { userId, startDate, endDate }, });
-
- // console.log('dataQuery messages: ', dataQuery.data)
+ // console.log('dataQuery messages: ', dataQuery.data)
if (dataQuery.data.length > 0) {
-
let dataCSVFormat = dataQuery.data;
for (var i = 0; i < dataCSVFormat.length; i++) {
if (dataCSVFormat[i].fromMe) {
- dataCSVFormat[i].fromMe = 'Atendente'
- }
- else {
- dataCSVFormat[i].fromMe = 'Cliente'
+ dataCSVFormat[i].fromMe = "Atendente";
+ } else {
+ dataCSVFormat[i].fromMe = "Cliente";
}
}
// console.log('dataCSVFormat: ', dataCSVFormat)
- setDataCSV(dataCSVFormat)
+ setDataCSV(dataCSVFormat);
setIsMount(false);
// setDataCSV(dataQuery.data)
}
- // setLoading(false);
-
+ // setLoading(false);
} catch (err) {
console.log(err);
}
};
fetchQueries();
-
- }
-
-
-
-
+ };
useEffect(() => {
-
if (isMount) {
return;
}
- csvLink.current.link.click()
-
+ csvLink.current.link.click();
}, [dataCSV, isMount, csvLink]);
-
-
-
useEffect(() => {
-
- if (reportOption === '2') {
-
+ if (reportOption === "2") {
const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
socket.on("onlineStatus", (data) => {
+ // setLoading(true);
- // setLoading(true);
+ let date = new Date().toLocaleDateString("pt-BR").split("/");
+ let dateToday = `${date[2]}-${date[1]}-${date[0]}`;
+ // console.log('date: ', new Date(startDate).toLocaleDateString('pt-BR'))
+ // console.log('date2: ', startDate)
- let date = new Date().toLocaleDateString('pt-BR').split('/')
- let dateToday = `${date[2]}-${date[1]}-${date[0]}`
-
- // console.log('date: ', new Date(startDate).toLocaleDateString('pt-BR'))
- // console.log('date2: ', startDate)
-
-
- if (data.action === "logout" || (data.action === "update" &&
- ((`${startDate}` === `${endDate}`) && (`${endDate}` === `${dateToday}`) && (`${startDate}` === `${dateToday}`)))) {
-
+ if (
+ data.action === "logout" ||
+ (data.action === "update" &&
+ `${startDate}` === `${endDate}` &&
+ `${endDate}` === `${dateToday}` &&
+ `${startDate}` === `${dateToday}`)
+ ) {
//console.log('UPDATE FROM ONLINE/OFFLINE LOGED USERS: ', data.userOnlineTime, ' | data.action : ', data.action)
dispatchQ({ type: "UPDATE_STATUS_ONLINE", payload: data.userOnlineTime });
-
- }
- else if (data.action === "delete") {
+ } else if (data.action === "delete") {
dispatchQ({ type: "DELETE_USER_STATUS", payload: data.userOnlineTime });
}
// setLoading(false);
-
});
socket.on("user", (data) => {
-
if (data.action === "delete") {
- // console.log(' entrou no delete user: ', data)
+ // console.log(' entrou no delete user: ', data)
dispatch({ type: "DELETE_USER", payload: +data.userId });
}
});
@@ -579,13 +481,9 @@ const Report = () => {
return () => {
socket.disconnect();
};
-
}
-
-
}, [reportOption, startDate, endDate]);
-
// const handleDeleteRows = (id) => {
// let _data = [...dataRows];
@@ -593,46 +491,42 @@ const Report = () => {
// _data.forEach(rd => {
// _data = _data.filter(t => t.id !== id);
// });
- // setData(_data);
+ // setData(_data);
// };
-
useEffect(() => {
-
- //if (!loading) {
-
+ //if (!loading) {
// setData(query.map(({ scheduleReminder, ...others }) => (
// { ...others, 'scheduleReminder': `${others.statusChatEndId}` === '3' ? 'Agendamento' : 'Lembrete' }
// )))
// }
- setData(query.map((column) => { return { ...column } }))
-
- }, [query])
+ setData(
+ query.map((column) => {
+ return { ...column };
+ })
+ );
+ }, [query]);
const handleLogouOnlineUser = async (userId) => {
try {
await api.get(`/users/logout/${userId}`);
//toast.success(("Desloged!"));
- //handleDeleteRows(scheduleId)
+ //handleDeleteRows(scheduleId)
} catch (err) {
// toastError(err);
}
-
-
};
-
return (
-
(
-
+
- {
@@ -642,13 +536,27 @@ const Report = () => {
- -
+
-
+
+
+ -
+
+
+ -
-
-
- {reportOption === '1' &&
+
{/*
-
- }
-
-
+ )}
-
-
-
-
-
-
-
- -
-
- {reportOption === '1' &&
-
-
+
-
+ {reportOption === "1" && (
+
- }
- {reportOption === '2' &&
-
+ table_title={"Atendimento por atendentes"}
+ />
+ )}
+ {reportOption === "2" && (
},
+ { title: "Nome", field: "name", cellStyle: { whiteSpace: "nowrap" } },
+
+ {
+ title: "Status",
+ field: "statusOnline.status",
+
+ cellStyle: (e, rowData) => {
+ if (rowData["statusOnline"] && rowData["statusOnline"].status) {
+ if (rowData["statusOnline"].status === "offline") {
+ return { color: "red" };
+ } else if (rowData["statusOnline"].status === "online") {
+ return { color: "green" };
+ } else if (rowData["statusOnline"].status === "logout...") {
+ return { color: "orange" };
+ } else if (rowData["statusOnline"].status === "waiting...") {
+ return { color: "orange" };
+ }
+ }
+ },
},
- }}
-
- title="Usuários online/offline"
- columns={
- [
-
- // { title: 'Foto', field: 'ticket.contact.profilePicUrl', render: rowData =>
},
- { title: 'Nome', field: 'name', cellStyle: {whiteSpace: 'nowrap'}, },
-
- {
- title: 'Status', field: 'statusOnline.status',
-
- cellStyle: (e, rowData) => {
-
- if (rowData['statusOnline'] && rowData['statusOnline'].status) {
-
- if (rowData['statusOnline'].status === 'offline') {
-
- return { color: "red" };
- }
- else if (rowData['statusOnline'].status === 'online') {
- return { color: "green" };
- }
- else if (rowData['statusOnline'].status === 'logout...') {
- return { color: "orange" };
- }
- else if (rowData['statusOnline'].status === 'waiting...') {
- return { color: "orange" };
- }
- }
-
-
- },
-
- },
-
- { title: 'Tempo online', field: 'sumOnlineTime.sum' },
- { title: 'Data inicio', field: 'startDate' },
- { title: 'Data fim', field: 'endDate' },
- { title: 'Em atendimento', field: 'sumOpen.count' },
- { title: 'Finalizado', field: 'sumClosed.count' },
-
- ]
- }
+ { title: "Tempo online", field: "sumOnlineTime.sum" },
+ { title: "Data inicio", field: "startDate" },
+ { title: "Data fim", field: "endDate" },
+ { title: "Em atendimento", field: "sumOpen.count" },
+ { title: "Finalizado", field: "sumClosed.count" },
+ ]}
data={dataRows}
// icons={tableIcons}
actions={[
(rowData) => {
-
- if (rowData.statusOnline &&
- rowData.statusOnline['status'] &&
- rowData.statusOnline['status'] === 'online') {
-
-
+ if (
+ rowData.statusOnline &&
+ rowData.statusOnline["status"] &&
+ rowData.statusOnline["status"] === "online"
+ ) {
return {
icon: LogoutIcon,
- tooltip: 'deslogar',
+ tooltip: "deslogar",
disable: false,
onClick: (event, rowData) => {
-
- // console.log(' ROW DATA INFO: ', rowData, ' | rowData: ', rowData.id)
- handleLogouOnlineUser(rowData.id)
- }
- }
-
-
+ // console.log(' ROW DATA INFO: ', rowData, ' | rowData: ', rowData.id)
+ handleLogouOnlineUser(rowData.id);
+ },
+ };
}
- }
+ },
]}
+ options={{
+ search: true,
+ selection: false,
+ paging: false,
+ padding: "dense",
+ sorting: true,
+ //loadingType: 'linear',
+ searchFieldStyle: {
+ width: 300,
+ },
+ pageSize: 20,
+ headerStyle: {
+ position: "sticky",
+ top: "0",
+ },
+ maxBodyHeight: "400px",
- options={
- {
- search: true,
- selection: false,
- paging: false,
- padding: 'dense',
- sorting: true,
- //loadingType: 'linear',
- searchFieldStyle: {
- width: 300,
- },
+ rowStyle: {
+ fontSize: 14,
+ },
- pageSize: 20,
- headerStyle: {
- position: "sticky",
- top: "0"
- },
- maxBodyHeight: "400px",
+ // cellStyle: (rowData) => {
+ // return {
+ // fontSize: 12,
+ // color: "#fff",
- rowStyle: {
- fontSize: 14,
- }
-
-
- // cellStyle: (rowData) => {
- // return {
- // fontSize: 12,
- // color: "#fff",
-
- // };
- // }
-
-
-
-
-
-
-
- }}
+ // };
+ // }
+ }}
/>
-
- }
-
+ )}
-
-
)}
/>
- )
+ );
};
export default Report;
+
diff --git a/frontend/src/pages/Tickets/Tickets.jsx b/frontend/src/pages/Tickets/Tickets.jsx
new file mode 100644
index 0000000..78ef468
--- /dev/null
+++ b/frontend/src/pages/Tickets/Tickets.jsx
@@ -0,0 +1,20 @@
+import React from "react";
+import { useParams } from "react-router-dom";
+
+import TicketsStyled from "./Tickets.style";
+
+import TicketsManager from "../../components/Ticket/TicketsManager/TicketsManager";
+import Ticket from "../../components/Ticket/Ticket";
+
+const Tickets = () => {
+ const { ticketId } = useParams();
+ return (
+
+
+ {ticketId ? : Não tem nada
}
+
+ );
+};
+
+export default Tickets;
+
diff --git a/frontend/src/pages/Tickets/Tickets.style.jsx b/frontend/src/pages/Tickets/Tickets.style.jsx
new file mode 100644
index 0000000..b690fc6
--- /dev/null
+++ b/frontend/src/pages/Tickets/Tickets.style.jsx
@@ -0,0 +1,10 @@
+import styled from "styled-components";
+
+const TicketsStyled = styled.div`
+ display: flex;
+ flex-direction: row;
+ min-height: auto;
+
+`;
+
+export default TicketsStyled
\ No newline at end of file
diff --git a/frontend/src/pages/Tickets/index.js b/frontend/src/pages/Tickets/index.js
index 461145a..1c68971 100644
--- a/frontend/src/pages/Tickets/index.js
+++ b/frontend/src/pages/Tickets/index.js
@@ -4,7 +4,7 @@ import Grid from "@material-ui/core/Grid";
import Paper from "@material-ui/core/Paper";
import { makeStyles } from "@material-ui/core/styles";
-import TicketsManager from "../../components/TicketsManager/";
+import TicketsManager from "../../components/Ticket/TicketsManager/index";
import Ticket from "../../components/Ticket/";
import { i18n } from "../../translate/i18n";
diff --git a/frontend/src/routes/Route.js b/frontend/src/routes/Route.js
index 788501e..8aa58b5 100644
--- a/frontend/src/routes/Route.js
+++ b/frontend/src/routes/Route.js
@@ -2,7 +2,7 @@ import React, { useContext } from "react";
import { Route as RouterRoute, Redirect } from "react-router-dom";
import { AuthContext } from "../context/Auth/AuthContext";
-import Loading from "../components/LoadingScreen/Loading"
+import LoadingScreen from "../components/LoadingScreen/LoadingScreen"
const Route = ({ component: Component, isPrivate = false, ...rest }) => {
const { isAuth, loading } = useContext(AuthContext);
@@ -10,7 +10,7 @@ const Route = ({ component: Component, isPrivate = false, ...rest }) => {
if (!isAuth && isPrivate) {
return (
<>
- {loading &&
}
+ {loading &&
}
>
);
@@ -19,7 +19,7 @@ const Route = ({ component: Component, isPrivate = false, ...rest }) => {
if (isAuth && !isPrivate) {
return (
<>
- {loading &&
}
+ {loading &&
}
;
>
);
@@ -27,7 +27,7 @@ const Route = ({ component: Component, isPrivate = false, ...rest }) => {
return (
<>
- {loading &&
}
+ {loading &&
}
>
);
diff --git a/frontend/src/routes/index.js b/frontend/src/routes/index.js
index 431140c..ac11b68 100644
--- a/frontend/src/routes/index.js
+++ b/frontend/src/routes/index.js
@@ -10,7 +10,7 @@ import SchedulesReminder from "../pages/SchedulesReminder/";
import Login from "../pages/Login/";
import Signup from "../pages/Signup/";
-import Tickets from "../pages/Tickets/";
+import Tickets from "../pages/Tickets/Tickets";
import Connections from "../pages/Connections/";
import Settings from "../pages/Settings/";
import Users from "../pages/Users";
diff --git a/frontend/src/style/varibles.jsx b/frontend/src/style/varibles.jsx
index ecf66e6..68e8e71 100644
--- a/frontend/src/style/varibles.jsx
+++ b/frontend/src/style/varibles.jsx
@@ -39,22 +39,24 @@ export const color = {
grisOscuro: "#3C3C3B",
blanco: "#FFFFFF",
},
- complement:{
+ complement: {
azulCielo: "#55A5DC",
azulOscuro: "#212F3C",
crisClaro: "#F6F6F6",
},
- status:{
+ status: {
no: "#FF0000",
yes: "#00BE1E",
- warning: "#FFC700"
+ warning: "#ffc800c7",
},
- gradient:{
- bgOpacity:"#212F3CD8",
- placeholder:"#ffffff83"
+ gradient: {
+ bgOpacity: "#212f3cd7",
+ placeholder: "#ffffff83",
+ border: "#55A5DC3F",
+ text: "#AEBAC1",
+ },
+ shadow: {
+ dark: "2px 2px 4px 2px",
},
- shadow:{
- dark:"2px 2px 4px 2px"
- }
};