Alteração para consultas nos campos usuario, dataInicio, dataFim. Atenção: Houve um bug nesse até esse commit que está impedindo que o whatssap seja lido pelo qrcode

pull/1/head
adriano 2022-01-25 18:54:46 -03:00
parent 39453e791d
commit 1b4347d585
4 changed files with 43 additions and 29 deletions

View File

@ -7,30 +7,43 @@ import Queue from "../../models/Queue";
import Message from "../../models/Message"; import Message from "../../models/Message";
import { userInfo } from "os"; import { userInfo } from "os";
import { Op } from "sequelize"; import { Op, where } from "sequelize";
import { Sequelize } from "sequelize"; import { Sequelize } from "sequelize";
import moment from 'moment'; import moment from 'moment';
import { startOfDay, endOfDay, parseISO, getDate} from "date-fns"; import { startOfDay, endOfDay, parseISO, getDate} from "date-fns";
import { string } from "yup/lib/locale";
//Report by user, startDate, endDate //Report by user, startDate, endDate
const ShowTicketReport = async (id: string | number, startDate: string, endDate: string): Promise<Ticket[]> => { const ShowTicketReport = async (id: string | number, startDate: string, endDate: string): Promise<Ticket[]> => {
const ticket = await Ticket.findAll({ let where_clause = {}
where: {
userid: id, if(id=='0'){
//createdAt: { where_clause = {
// [Op.between]: [+new Date('2022-01-24').toISOString(), +new Date().toISOString()]
//},
createdAt: { createdAt: {
[Op.gte]: startDate+' 00:00:00.000000', [Op.gte]: startDate+' 00:00:00.000000',
[Op.lte]: endDate +' 23:59:59.999999' [Op.lte]: endDate +' 23:59:59.999999'
} },
}
}, }
else{
where_clause = {
userid: id,
createdAt: {
[Op.gte]: startDate+' 00:00:00.000000',
[Op.lte]: endDate +' 23:59:59.999999'
},
}
}
const ticket = await Ticket.findAll({
where: where_clause ,
attributes: ['id', 'status', 'createdAt', 'updatedAt'], attributes: ['id', 'status', 'createdAt', 'updatedAt'],
include: [ include: [
{ {

View File

@ -10,14 +10,10 @@ const MTable = (props) => {
const [selectedRow, setSelectedRow] = useState(null); const [selectedRow, setSelectedRow] = useState(null);
console.log('rederizou....................: ',props.data)
const dataLoad = props.data.map((dt) => { return { ...dt }}); const dataLoad = props.data.map((dt) => { return { ...dt }});
const columnsLoad = props.columns.map((column) => { return { ...column }}); const columnsLoad = props.columns.map((column) => { return { ...column }});
console.log('dataLoad....................: ',dataLoad)
console.log('columnsLoad....................: ',columnsLoad)
useEffect(() => { useEffect(() => {
console.log(`You have clicked the button ${selectedRow} times`) console.log(`You have clicked the button ${selectedRow} times`)
@ -31,6 +27,7 @@ const MTable = (props) => {
columns={columnsLoad} columns={columnsLoad}
data={dataLoad} data={dataLoad}
onRowClick={(evt, selectedRow) => { onRowClick={(evt, selectedRow) => {
console.log(selectedRow.tableData.id); console.log(selectedRow.tableData.id);
@ -48,6 +45,8 @@ const MTable = (props) => {
search: true, search: true,
selection: false, selection: false,
paging: false, paging: false,
padding: 'dense',
//loadingType: 'linear',
searchFieldStyle: { searchFieldStyle: {
width: 300, width: 300,
}, },

View File

@ -176,7 +176,7 @@ const Report = () => {
const [query, dispatchQ] = useReducer(reducerQ, []) const [query, dispatchQ] = useReducer(reducerQ, [])
useEffect(() => { useEffect(() => {
dispatch({ type: "RESET" }); dispatch({ type: "RESET" });
dispatchQ({ type: "RESET" }) dispatchQ({ type: "RESET" })
setPageNumber(1); setPageNumber(1);
@ -184,6 +184,7 @@ const Report = () => {
useEffect(() => { useEffect(() => {
setLoading(true); setLoading(true);
const delayDebounceFn = setTimeout(() => { const delayDebounceFn = setTimeout(() => {
const fetchUsers = async () => { const fetchUsers = async () => {
@ -216,10 +217,10 @@ const Report = () => {
const fetchQueries = async () => { const fetchQueries = async () => {
try { try {
const dataQuery = await api.get("/reports/", {params: {userId, startDate, endDate },});
console.log('fffffffffffffffffffff query: ', dataQuery.data) /*const dataQuery = await api.get("/reports/", {params: {userId, startDate, endDate },});
dispatchQ({ type: "LOAD_QUERY", payload: dataQuery.data }); dispatchQ({ type: "RESET" })
dispatchQ({ type: "LOAD_QUERY", payload: dataQuery.data }); */
setLoading(false); setLoading(false);
@ -274,6 +275,7 @@ console.log('XXXXXXXXX: ', query)
<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)=>{