diff --git a/backend/src/services/TicketServices/ListTicketsService.ts b/backend/src/services/TicketServices/ListTicketsService.ts index 91bca39..c20154c 100644 --- a/backend/src/services/TicketServices/ListTicketsService.ts +++ b/backend/src/services/TicketServices/ListTicketsService.ts @@ -39,7 +39,7 @@ const ListTicketsService = async ({ showAll, userId, withUnreadMessages, - unlimited='false' + unlimited = 'false' }: Request): Promise => { let whereCondition: Filterable["where"] = { [Op.or]: [{ userId }, { status: "pending" }], @@ -47,6 +47,8 @@ const ListTicketsService = async ({ }; let includeCondition: Includeable[]; + + includeCondition = [ { model: Contact, @@ -65,20 +67,21 @@ const ListTicketsService = async ({ } if (status) { - whereCondition = { - ...whereCondition, - status - }; - // if (unlimited) { - // whereCondition = { - // ...whereCondition, - // createdAt: { - // [Op.gte]: dateToday.fullDate + ' 00:00:00.000000', - // [Op.lte]: dateToday.fullDate + ' 23:59:59.999999' - // } - // } - // } + whereCondition = { ...whereCondition, status }; + + // console.log('TEST unlimited: ', unlimited) + + if (unlimited === 'true' && status !== 'pending') { + + whereCondition = { + ...whereCondition, + createdAt: { + [Op.gte]: dateToday.fullDate + ' 00:00:00.000000', + [Op.lte]: dateToday.fullDate + ' 23:59:59.999999' + } + } + } } @@ -92,11 +95,7 @@ const ListTicketsService = async ({ as: "messages", attributes: ["id", "body"], where: { - body: where( - fn("LOWER", col("body")), - "LIKE", - `%${sanitizedSearchParam}%` - ) + body: where(fn("LOWER", col("body")), "LIKE", `%${sanitizedSearchParam}%`) }, required: false, duplicating: false @@ -107,19 +106,13 @@ const ListTicketsService = async ({ ...whereCondition, [Op.or]: [ { - "$contact.name$": where( - fn("LOWER", col("contact.name")), - "LIKE", - `%${sanitizedSearchParam}%` - ) + "$contact.name$": where(fn("LOWER", col("contact.name")), "LIKE", `%${sanitizedSearchParam}%`) }, + { "$contact.number$": { [Op.like]: `%${sanitizedSearchParam}%` } }, - { - "$message.body$": where( - fn("LOWER", col("body")), - "LIKE", - `%${sanitizedSearchParam}%` - ) + + { + "$message.body$": where(fn("LOWER", col("body")), "LIKE", `%${sanitizedSearchParam}%`) } ] }; @@ -151,7 +144,7 @@ const ListTicketsService = async ({ where: whereCondition, include: includeCondition, distinct: true, - limit, + limit, offset, order: [["updatedAt", "DESC"]] }); diff --git a/frontend/src/components/Report/MTable/index.js b/frontend/src/components/Report/MTable/index.js index b3f5dbe..d2f7c55 100644 --- a/frontend/src/components/Report/MTable/index.js +++ b/frontend/src/components/Report/MTable/index.js @@ -125,7 +125,7 @@ const MTable = (props) => { exportAllData: true, sorting: true ? props.hasChild : false, - loadingType: 'circular', + // loadingType: 'circular', searchFieldStyle: { width: 300, }, diff --git a/frontend/src/components/TicketsList/index.js b/frontend/src/components/TicketsList/index.js index 442cbd4..3a1d336 100644 --- a/frontend/src/components/TicketsList/index.js +++ b/frontend/src/components/TicketsList/index.js @@ -195,6 +195,9 @@ const TicketsList = (props) => { useEffect(() => { if (!status && !searchParam) return; + + // console.log('lllllllllllllllllllllllllllllllll') + dispatch({ type: "LOAD_TICKETS", payload: tickets, diff --git a/frontend/src/components/TicketsManager/index.js b/frontend/src/components/TicketsManager/index.js index 88e6ea0..2da1d18 100644 --- a/frontend/src/components/TicketsManager/index.js +++ b/frontend/src/components/TicketsManager/index.js @@ -124,7 +124,7 @@ const TicketsManager = () => { let searchTimeout; const handleSearch = (e) => { - const searchedTerm = e.target.value.toLowerCase(); + const searchedTerm = e.target.value.toLowerCase(); clearTimeout(searchTimeout); diff --git a/frontend/src/pages/Dashboard/Chart.js b/frontend/src/pages/Dashboard/Chart.js index a1480f8..d6207f5 100644 --- a/frontend/src/pages/Dashboard/Chart.js +++ b/frontend/src/pages/Dashboard/Chart.js @@ -20,7 +20,7 @@ const Chart = () => { const theme = useTheme(); const date = useRef(new Date().toISOString()); - const { tickets } = useTickets({ date: date.current }); + const { tickets } = useTickets({ date: date.current, unlimited: "true" }); const [chartData, setChartData] = useState([ { time: "08:00", amount: 0 }, diff --git a/frontend/src/pages/Dashboard/index.js b/frontend/src/pages/Dashboard/index.js index 7ca5e15..674b040 100644 --- a/frontend/src/pages/Dashboard/index.js +++ b/frontend/src/pages/Dashboard/index.js @@ -75,6 +75,7 @@ const Dashboard = () => {
+ @@ -107,15 +108,17 @@ const Dashboard = () => { {GetTickets("closed", "true", "false", "true")} - - + + + +
diff --git a/frontend/src/pages/Report/index.js b/frontend/src/pages/Report/index.js index cd59b8b..c2467c6 100644 --- a/frontend/src/pages/Report/index.js +++ b/frontend/src/pages/Report/index.js @@ -397,8 +397,8 @@ const Report = () => { const { data } = await api.get("/reports/", { params: { userId, startDate, endDate, pageNumber: pageNumberTickets }, }); - console.log('dataQuery: ', data) - console.log('pageNumberTickets: ', pageNumberTickets) + // console.log('dataQuery: ', data) + // console.log('pageNumberTickets: ', pageNumberTickets) // dispatchQ({ type: "RESET" }) dispatchQ({ type: "LOAD_QUERY", payload: data.tickets }); diff --git a/frontend/src/pages/Tickets/index.js b/frontend/src/pages/Tickets/index.js index 80eb909..fc4be5a 100644 --- a/frontend/src/pages/Tickets/index.js +++ b/frontend/src/pages/Tickets/index.js @@ -78,7 +78,7 @@ const Chat = () => { className={ ticketId ? classes.contactsWrapperSmall : classes.contactsWrapper } - > + >