diff --git a/backend/package.json b/backend/package.json
index 6060318..59b22e0 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -17,6 +17,7 @@
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
+ "date-fns": "^2.15.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-async-errors": "^3.1.1",
diff --git a/backend/src/controllers/TicketController.js b/backend/src/controllers/TicketController.js
index 7e835e7..1025412 100644
--- a/backend/src/controllers/TicketController.js
+++ b/backend/src/controllers/TicketController.js
@@ -1,4 +1,5 @@
const Sequelize = require("sequelize");
+const { startOfDay, endOfDay, parseISO } = require("date-fns");
const Ticket = require("../models/Ticket");
const Contact = require("../models/Contact");
@@ -6,19 +7,31 @@ const Contact = require("../models/Contact");
const { getIO } = require("../libs/socket");
exports.index = async (req, res) => {
- const { status = "" } = req.query;
+ const { status = "", date = "" } = req.query;
- let whereCondition;
- if (!status || status === "open") {
- whereCondition = ["pending", "open"];
- } else {
- whereCondition = [status];
+ let whereCondition = {};
+ if (status === "open") {
+ whereCondition = {
+ ...whereCondition,
+ status: { [Sequelize.Op.or]: ["pending", "open"] },
+ };
+ } else if (status === "closed") {
+ whereCondition = { ...whereCondition, status: "closed" };
+ }
+ if (date) {
+ whereCondition = {
+ ...whereCondition,
+ createdAt: {
+ [Sequelize.Op.between]: [
+ startOfDay(parseISO(date)),
+ endOfDay(parseISO(date)),
+ ],
+ },
+ };
}
const tickets = await Ticket.findAll({
- where: {
- status: { [Sequelize.Op.or]: whereCondition },
- },
+ where: whereCondition,
include: [
{
model: Contact,
diff --git a/backend/yarn.lock b/backend/yarn.lock
index 45fe6df..bda9710 100644
--- a/backend/yarn.lock
+++ b/backend/yarn.lock
@@ -518,6 +518,11 @@ d@1, d@^1.0.1:
es5-ext "^0.10.50"
type "^1.0.1"
+date-fns@^2.15.0:
+ version "2.15.0"
+ resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-2.15.0.tgz#424de6b3778e4e69d3ff27046ec136af58ae5d5f"
+ integrity sha512-ZCPzAMJZn3rNUvvQIMlXhDr4A+Ar07eLeGsGREoWU19a3Pqf5oYa+ccd+B3F6XVtQY6HANMFdOQ8A+ipFnvJdQ==
+
debug@2.6.9, debug@^2.2.0:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
diff --git a/frontend/package.json b/frontend/package.json
index 0693e36..7ba969d 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -23,6 +23,7 @@
"react-modal-image": "^2.5.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
+ "recharts": "^1.8.5",
"socket.io-client": "^2.3.0"
},
"scripts": {
diff --git a/frontend/src/components/NewTicketModal/index.js b/frontend/src/components/NewTicketModal/index.js
index a1f21cd..249ffd6 100644
--- a/frontend/src/components/NewTicketModal/index.js
+++ b/frontend/src/components/NewTicketModal/index.js
@@ -89,8 +89,6 @@ const NewTicketModal = ({ modalOpen, onClose, contactId }) => {
handleClose();
};
- console.log(options);
-
return (