Merge branch 'testeA'
commit
d038631045
|
@ -11,27 +11,14 @@ type IndexQuery = {
|
||||||
endDate: string;
|
endDate: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*export const reportUser = async (req: Request, res: Response): Promise<Response> => {
|
|
||||||
|
|
||||||
const { userId } = req.params;
|
|
||||||
|
|
||||||
console.log('******* Estrou no report: ', userId)
|
|
||||||
|
|
||||||
const test = await ShowTicketReport(userId);
|
|
||||||
|
|
||||||
return res.status(200).json(test);
|
|
||||||
|
|
||||||
};*/
|
|
||||||
|
|
||||||
|
|
||||||
export const reportUserByDateStartDateEnd = async (req: Request, res: Response): Promise<Response> => {
|
export const reportUserByDateStartDateEnd = async (req: Request, res: Response): Promise<Response> => {
|
||||||
|
|
||||||
const { userId, startDate, endDate } = req.query as IndexQuery
|
if (req.user.profile !== "master" && req.user.profile !== "admin") {
|
||||||
|
throw new AppError("ERR_NO_PERMISSION", 403);
|
||||||
|
}
|
||||||
|
|
||||||
console.log('******* Estrou no report')
|
const { userId, startDate, endDate } = req.query as IndexQuery
|
||||||
console.log('******* userId: ', userId)
|
|
||||||
console.log('******* startDate: ', startDate)
|
|
||||||
console.log('******* endDate: ', endDate)
|
|
||||||
|
|
||||||
const data_query = await ShowTicketReport(userId, startDate, endDate);
|
const data_query = await ShowTicketReport(userId, startDate, endDate);
|
||||||
|
|
||||||
|
@ -39,13 +26,6 @@ export const reportUserByDateStartDateEnd = async (req: Request, res: Response):
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*export const reportAll = async (req: Request, res: Response): Promise<Response> => {
|
|
||||||
|
|
||||||
const test = await ShowTicketReport();
|
|
||||||
|
|
||||||
return res.status(200).json(test);
|
|
||||||
|
|
||||||
};*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,6 @@ import * as ReportController from "../controllers/ReportController";
|
||||||
|
|
||||||
const reportRoutes = express.Router();
|
const reportRoutes = express.Router();
|
||||||
|
|
||||||
//reportRoutes.get("/reports/:userId", /*isAuth,*/ ReportController.reportUser);
|
reportRoutes.get("/reports", isAuth, ReportController.reportUserByDateStartDateEnd);
|
||||||
|
|
||||||
reportRoutes.get("/reports", /*isAuth,*/ ReportController.reportUserByDateStartDateEnd);
|
|
||||||
|
|
||||||
//reportRoutes.get("/reports", /*isAuth,*/ ReportController.reportAll);
|
|
||||||
|
|
||||||
export default reportRoutes;
|
export default reportRoutes;
|
||||||
|
|
|
@ -81,41 +81,6 @@ const ShowTicketReport = async (id: string | number, startDate: string, endDate:
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*//Report by user
|
|
||||||
const ShowTicketReport = async (id: string | number): Promise<Ticket[]> => {
|
|
||||||
|
|
||||||
const ticket = await Ticket.findAll({
|
|
||||||
where: {userid: id} ,
|
|
||||||
attributes: ['id', 'status', 'createdAt', 'updatedAt'],
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
model: Message,
|
|
||||||
required:true,
|
|
||||||
separate: true,
|
|
||||||
attributes: ['body', 'read', 'mediaType','fromMe', 'mediaUrl','createdAt'],
|
|
||||||
order: [
|
|
||||||
['createdAt', 'ASC']
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
model: Contact,
|
|
||||||
attributes: ['name', 'number']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
model: User,
|
|
||||||
attributes: ['name', 'email']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
model: Queue,
|
|
||||||
attributes: ['name']
|
|
||||||
},
|
|
||||||
|
|
||||||
],
|
|
||||||
|
|
||||||
}); */
|
|
||||||
|
|
||||||
if (!ticket) {
|
if (!ticket) {
|
||||||
throw new AppError("ERR_NO_TICKET_FOUND", 404);
|
throw new AppError("ERR_NO_TICKET_FOUND", 404);
|
||||||
}
|
}
|
||||||
|
@ -123,45 +88,4 @@ const ShowTicketReport = async (id: string | number): Promise<Ticket[]> => {
|
||||||
return ticket;
|
return ticket;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Report all
|
|
||||||
/*const ShowTicketReport = async (): Promise<Message[]> => {
|
|
||||||
|
|
||||||
const ticket = await Message.findAll({
|
|
||||||
//raw: true,
|
|
||||||
attributes: ['body', 'createdAt', 'ticketId'],
|
|
||||||
include: [
|
|
||||||
{
|
|
||||||
model: Ticket,
|
|
||||||
attributes: ['contactid', 'userid', 'queueid', 'status'],
|
|
||||||
include:[
|
|
||||||
{
|
|
||||||
model: Contact,
|
|
||||||
attributes: ['name', 'number']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
model: User,
|
|
||||||
attributes: ['name', 'email']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
model: Queue,
|
|
||||||
attributes: ['name']
|
|
||||||
}
|
|
||||||
],
|
|
||||||
},
|
|
||||||
|
|
||||||
],
|
|
||||||
order:
|
|
||||||
['ticketId', 'createdAt']
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
if (!ticket) {
|
|
||||||
throw new AppError("ERR_NO_TICKET_FOUND", 404);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ticket;
|
|
||||||
};*/
|
|
||||||
|
|
||||||
export default ShowTicketReport;
|
export default ShowTicketReport;
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import React, { useState, useEffect, useReducer} from "react";
|
import React, { useState, useEffect, useReducer, useContext} from "react";
|
||||||
import MainContainer from "../../components/MainContainer";
|
import MainContainer from "../../components/MainContainer";
|
||||||
import api from "../../services/api";
|
import api from "../../services/api";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
import SelectField from "../../components/Report/SelectField";
|
import SelectField from "../../components/Report/SelectField";
|
||||||
import { data } from '../../components/Report/MTable/data';
|
import { data } from '../../components/Report/MTable/data';
|
||||||
import DatePicker1 from '../../components/Report/DatePicker'
|
import DatePicker1 from '../../components/Report/DatePicker'
|
||||||
|
@ -12,7 +9,8 @@ import { Button } from "@material-ui/core";
|
||||||
import MTable from "../../components/Report/MTable";
|
import MTable from "../../components/Report/MTable";
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
|
import { AuthContext } from "../../context/Auth/AuthContext";
|
||||||
|
import { Can } from "../../components/Can";
|
||||||
|
|
||||||
|
|
||||||
const reducerQ = (state, action) =>{
|
const reducerQ = (state, action) =>{
|
||||||
|
@ -158,21 +156,18 @@ let columnsData = [
|
||||||
|
|
||||||
const Report = () => {
|
const Report = () => {
|
||||||
|
|
||||||
|
const { user: userA } = useContext(AuthContext);
|
||||||
|
|
||||||
//--------
|
//--------
|
||||||
const [searchParam, setSearchParam] = useState("");
|
const [searchParam, setSearchParam] = useState("");
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [hasMore, setHasMore] = useState(false);
|
const [hasMore, setHasMore] = useState(false);
|
||||||
const [pageNumber, setPageNumber] = useState(1);
|
const [pageNumber, setPageNumber] = useState(1);
|
||||||
const [users, dispatch] = useReducer(reducer, []);
|
const [users, dispatch] = useReducer(reducer, []);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const [columns, setColums] = useState([])
|
const [columns, setColums] = useState([])
|
||||||
|
|
||||||
const [startDate, setDatePicker1] = useState(new Date())
|
const [startDate, setDatePicker1] = useState(new Date())
|
||||||
const [endDate, setDatePicker2] = useState(new Date())
|
const [endDate, setDatePicker2] = useState(new Date())
|
||||||
const [userId, setUser] = useState(null)
|
const [userId, setUser] = useState(null)
|
||||||
|
|
||||||
const [query, dispatchQ] = useReducer(reducerQ, [])
|
const [query, dispatchQ] = useReducer(reducerQ, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
@ -262,27 +257,23 @@ function handleQuery (){
|
||||||
console.log('endDate: ', endDate)
|
console.log('endDate: ', endDate)
|
||||||
console.log('userid: ', userId)
|
console.log('userid: ', userId)
|
||||||
|
|
||||||
/* if(tot == 3){
|
|
||||||
setColums(columns1)
|
|
||||||
} */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('XXXXXXXXX: ', query)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
|
<Can
|
||||||
|
role={userA.profile}
|
||||||
|
perform="ticket-report:show"
|
||||||
|
yes={() => (
|
||||||
|
|
||||||
<MainContainer>
|
<MainContainer>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)' }}>
|
<Box sx={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)' }}>
|
||||||
|
|
||||||
<Item><SelectField func={textFieldSelectUser} currencies={users.map((obj)=>{
|
<Item><SelectField func={textFieldSelectUser} currencies={users.map((obj)=>{
|
||||||
return {'value': obj.id, 'label': obj.name}
|
return {'value': obj.id, 'label': obj.name}
|
||||||
})}/></Item>
|
})}/></Item>
|
||||||
|
|
||||||
|
|
||||||
<Item><DatePicker1 func={datePicker1Value} title={'Data inicio'}/></Item>
|
<Item><DatePicker1 func={datePicker1Value} title={'Data inicio'}/></Item>
|
||||||
<Item><DatePicker2 func={datePicker2Value} title={'Data fim'}/></Item>
|
<Item><DatePicker2 func={datePicker2Value} title={'Data fim'}/></Item>
|
||||||
|
|
||||||
|
@ -295,71 +286,19 @@ console.log('XXXXXXXXX: ', query)
|
||||||
<Box sx={{
|
<Box sx={{
|
||||||
display: 'grid',
|
display: 'grid',
|
||||||
}}>
|
}}>
|
||||||
<Item sx={{ gridColumn: '1', gridRow: 'span 1' }}>
|
|
||||||
|
|
||||||
|
<Item sx={{ gridColumn: '1', gridRow: 'span 1' }}>
|
||||||
<MTable data={query}
|
<MTable data={query}
|
||||||
columns={columnsData}
|
columns={columnsData}
|
||||||
hasChild={true}
|
hasChild={true}
|
||||||
table_title={'Relatório de atendimento por atendentes'}/>
|
table_title={'Relatório de atendimento por atendentes'}/>
|
||||||
|
|
||||||
</Item>
|
</Item>
|
||||||
|
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{/* <MainHeader>
|
|
||||||
<Title>{i18n.t("users.title")}</Title>
|
|
||||||
<MainHeaderButtonsWrapper>
|
|
||||||
|
|
||||||
</MainHeaderButtonsWrapper>
|
|
||||||
</MainHeader>
|
|
||||||
|
|
||||||
|
|
||||||
<Paper
|
|
||||||
className={classes.mainPaper}
|
|
||||||
variant="outlined"
|
|
||||||
onScroll={handleScroll}
|
|
||||||
>
|
|
||||||
<Table size="small">
|
|
||||||
<TableHead>
|
|
||||||
<TableRow>
|
|
||||||
<TableCell align="center">{i18n.t("users.table.name")}</TableCell>
|
|
||||||
<TableCell align="center">
|
|
||||||
{i18n.t("users.table.email")}
|
|
||||||
</TableCell>
|
|
||||||
<TableCell align="center">
|
|
||||||
{i18n.t("users.table.profile")}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
<TableCell align="center">
|
|
||||||
{i18n.t("users.table.actions")}
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
</TableRow>
|
|
||||||
</TableHead>
|
|
||||||
<TableBody>
|
|
||||||
<>
|
|
||||||
{users.map((user) => (
|
|
||||||
<TableRow key={user.id}>
|
|
||||||
<TableCell align="center">{user.name}</TableCell>
|
|
||||||
<TableCell align="center">{user.email}</TableCell>
|
|
||||||
<TableCell align="center">{user.profile}</TableCell>
|
|
||||||
|
|
||||||
<TableCell align="center">
|
|
||||||
|
|
||||||
|
|
||||||
</TableCell>
|
|
||||||
|
|
||||||
</TableRow>
|
|
||||||
))}
|
|
||||||
{loading && <TableRowSkeleton columns={4} />}
|
|
||||||
</>
|
|
||||||
</TableBody>
|
|
||||||
</Table>
|
|
||||||
</Paper>*/}
|
|
||||||
|
|
||||||
</MainContainer>
|
</MainContainer>
|
||||||
|
|
||||||
|
)}
|
||||||
|
/>
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,11 +11,11 @@ const rules = {
|
||||||
"user-modal:editQueues",
|
"user-modal:editQueues",
|
||||||
"ticket-options:deleteTicket",
|
"ticket-options:deleteTicket",
|
||||||
"contacts-page:deleteContact",
|
"contacts-page:deleteContact",
|
||||||
|
|
||||||
"connections-view:show",
|
"connections-view:show",
|
||||||
"dashboard-view:show",
|
"dashboard-view:show",
|
||||||
"queues-view:show",
|
"queues-view:show",
|
||||||
"user-view:show",
|
"user-view:show",
|
||||||
|
"ticket-report:show",
|
||||||
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
@ -28,17 +28,16 @@ const rules = {
|
||||||
"user-modal:editQueues",
|
"user-modal:editQueues",
|
||||||
"ticket-options:deleteTicket",
|
"ticket-options:deleteTicket",
|
||||||
"contacts-page:deleteContact",
|
"contacts-page:deleteContact",
|
||||||
|
|
||||||
"connections-view:show",
|
"connections-view:show",
|
||||||
"dashboard-view:show",
|
"dashboard-view:show",
|
||||||
"queues-view:show",
|
"queues-view:show",
|
||||||
"user-view:show",
|
"user-view:show",
|
||||||
"settings-view:show",
|
"settings-view:show",
|
||||||
|
|
||||||
"btn-add-user",
|
"btn-add-user",
|
||||||
"icon-remove-user",
|
"icon-remove-user",
|
||||||
"btn-add-whatsapp",
|
"btn-add-whatsapp",
|
||||||
"btn-remove-whatsapp",
|
"btn-remove-whatsapp",
|
||||||
|
"ticket-report:show",
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue