diff --git a/backend/package.json b/backend/package.json
index 1c450d6..4d3bdec 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -22,6 +22,7 @@
"@types/pino": "^6.3.4",
"axios": "^1.2.3",
"bcryptjs": "^2.4.3",
+ "compression": "^1.7.4",
"cookie-parser": "^1.4.5",
"cors": "^2.8.5",
"date-fns": "^2.30.0",
@@ -56,9 +57,9 @@
"yup": "^0.32.8"
},
"devDependencies": {
- "@types/lodash": "4.14",
"@types/bcryptjs": "^2.4.2",
"@types/bluebird": "^3.5.32",
+ "@types/compression": "^1.7.5",
"@types/cookie-parser": "^1.4.2",
"@types/cors": "^2.8.7",
"@types/express": "^4.17.13",
@@ -66,6 +67,7 @@
"@types/faker": "^5.1.3",
"@types/jest": "^26.0.15",
"@types/jsonwebtoken": "^8.5.0",
+ "@types/lodash": "4.14",
"@types/multer": "^1.4.4",
"@types/node": "^14.11.8",
"@types/supertest": "^2.0.10",
diff --git a/backend/src/app.ts b/backend/src/app.ts
index fea4c81..7fe1d45 100644
--- a/backend/src/app.ts
+++ b/backend/src/app.ts
@@ -11,6 +11,7 @@ import uploadConfig from "./config/upload";
import AppError from "./errors/AppError";
import routes from "./routes";
import { logger } from "./utils/logger";
+import compression from 'compression';
Sentry.init({ dsn: process.env.SENTRY_DSN });
@@ -23,6 +24,7 @@ app.use(
})
);
+app.use(compression());
app.use(cookieParser());
app.use(express.json());
app.use(Sentry.Handlers.requestHandler());
diff --git a/backend/src/services/ContactServices/CreateOrUpdateContactService.ts b/backend/src/services/ContactServices/CreateOrUpdateContactService.ts
index 50d5d5f..e63085d 100644
--- a/backend/src/services/ContactServices/CreateOrUpdateContactService.ts
+++ b/backend/src/services/ContactServices/CreateOrUpdateContactService.ts
@@ -1,5 +1,6 @@
import { getIO } from "../../libs/socket";
import Contact from "../../models/Contact";
+const { Op } = require('sequelize');
import { createOrUpdateContactCache } from '../../helpers/ContactsCache'
import { tr } from "date-fns/locale";
@@ -35,15 +36,37 @@ const CreateOrUpdateContactService = async ({
const io = getIO();
let contact: Contact | null;
-
- contact = await Contact.findOne({ where: { number } });
+ const firstFourDigits = number.slice(0, 4);
+ const lastEightDigits = number.slice(-8);
+
+ //const numberFormat = number?.length === 13 && number[4] == '9' ? number.slice(0, 4) + number.slice(0, 4) : number;
+ //contact = await Contact.findOne({ where: { number } });
+ contact = await Contact.findOne({
+ where: {
+ [Op.and]: [
+ {
+ number: {
+ [Op.like]: `%${firstFourDigits}%`
+ }
+ },
+ {
+ number: {
+ [Op.like]: `%${lastEightDigits}%`
+ }
+ }
+ ]
+ }
+ });
if (contact) {
- contact.update({ profilePicUrl });
- // TEST DEL
- await createOrUpdateContactCache(`contact:${contact.id}`, { profilePicUrl })
- //
+ if(contact.number == number){
+ contact.update({ profilePicUrl });
+ await createOrUpdateContactCache(`contact:${contact.id}`, { profilePicUrl })
+ } else{
+ contact.update({ profilePicUrl, number });
+ await createOrUpdateContactCache(`contact:${contact.id}`, { profilePicUrl, number })
+ }
io.emit("contact", {
action: "update",
diff --git a/backend/src/services/TicketServices/FindOrCreateTicketServiceBot.ts b/backend/src/services/TicketServices/FindOrCreateTicketServiceBot.ts
index 5ba09e7..a98a34b 100644
--- a/backend/src/services/TicketServices/FindOrCreateTicketServiceBot.ts
+++ b/backend/src/services/TicketServices/FindOrCreateTicketServiceBot.ts
@@ -101,8 +101,6 @@ const FindOrCreateTicketServiceBot = async (
unreadMessages
});
- console.log("lxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
-
await dialogFlowStartContext(contact, ticket, botInfo);
}
}
@@ -128,8 +126,6 @@ const FindOrCreateTicketServiceBot = async (
phoneNumberId
});
- console.log("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy");
-
await dialogFlowStartContext(contact, ticket, botInfo);
}
diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts
index 948a412..6d5136f 100644
--- a/backend/src/services/WbotServices/wbotMessageListener.ts
+++ b/backend/src/services/WbotServices/wbotMessageListener.ts
@@ -1061,8 +1061,6 @@ const handleMessage = async (
// console.log('----------> chat: ', JSON.parse(JSON.stringify(chat)))
- console
-
if (chat.isGroup) {
// let msgGroupContact;
diff --git a/frontend/src/routes/Route.js b/frontend/src/routes/Route.js
index fab61b3..91ce315 100644
--- a/frontend/src/routes/Route.js
+++ b/frontend/src/routes/Route.js
@@ -1,9 +1,14 @@
-import React, { useContext } from "react";
+import React, { useContext, Suspense, lazy } from "react";
import { Route as RouterRoute, Redirect } from "react-router-dom";
import { AuthContext } from "../context/Auth/AuthContext";
import BackdropLoading from "../components/BackdropLoading";
+// Exemplo de como vocĂȘ carregaria componentes de forma lazy
+const Dashboard = lazy(() => import("../pages/Dashboard"));
+const Login = lazy(() => import("../pages/Login"));
+const Signup = lazy(() => import("../pages/Signup"));
+
const Route = ({ component: Component, isPrivate = false, ...rest }) => {
const { isAuth, loading } = useContext(AuthContext);
@@ -20,7 +25,7 @@ const Route = ({ component: Component, isPrivate = false, ...rest }) => {
return (
<>
{loading && }
- ;
+
>
);
}
@@ -28,9 +33,11 @@ const Route = ({ component: Component, isPrivate = false, ...rest }) => {
return (
<>
{loading && }
-
+ }>
+
+
>
);
};
-export default Route;
+export default Route;
\ No newline at end of file
diff --git a/frontend/src/routes/index.js b/frontend/src/routes/index.js
index 3400c44..8f053a4 100644
--- a/frontend/src/routes/index.js
+++ b/frontend/src/routes/index.js
@@ -1,94 +1,85 @@
-import React from 'react'
+import React, { Suspense, lazy } from 'react';
import { BrowserRouter, Switch } from 'react-router-dom'
import { ToastContainer } from 'react-toastify'
-import LoggedInLayout from '../layout'
-import Dashboard from '../pages/Dashboard/'
-
-import Report from '../pages/Report/'
-import SchedulesReminder from '../pages/SchedulesReminder/'
-
-import Tickets from '../pages/Tickets/'
-import Signup from '../pages/Signup/'
-import Login from '../pages/Login/'
-import Connections from '../pages/Connections/'
-import Campaign from '../pages/Campaign'
-import Settings from '../pages/Settings/'
-import Users from '../pages/Users'
-import Contacts from '../pages/Contacts/'
-import QuickAnswers from '../pages/QuickAnswers/'
-import StatusChatEnd from '../pages/StatusChatEnd/'
-import Position from '../pages/Position/'
-
-import Queues from '../pages/Queues/'
import { AuthProvider } from '../context/Auth/AuthContext'
import { WhatsAppsProvider } from '../context/WhatsApp/WhatsAppsContext'
+import LoggedInLayout from '../layout'
import Route from './Route'
+import BackdropLoading from "../components/BackdropLoading";
+
+const Dashboard = lazy(() => import('../pages/Dashboard/'));
+const Report = lazy(() => import('../pages/Report/'));
+const SchedulesReminder = lazy(() => import('../pages/SchedulesReminder/'));
+const Tickets = lazy(() => import('../pages/Tickets/'));
+const Signup = lazy(() => import('../pages/Signup/'));
+const Login = lazy(() => import('../pages/Login/'));
+const Connections = lazy(() => import('../pages/Connections/'));
+const Campaign = lazy(() => import('../pages/Campaign/'));
+const Settings = lazy(() => import('../pages/Settings/'));
+const Users = lazy(() => import('../pages/Users/'));
+const Contacts = lazy(() => import('../pages/Contacts/'));
+const QuickAnswers = lazy(() => import('../pages/QuickAnswers/'));
+const StatusChatEnd = lazy(() => import('../pages/StatusChatEnd/'));
+const Position = lazy(() => import('../pages/Position/'));
+const Queues = lazy(() => import('../pages/Queues/'));
const Routes = () => {
return (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ }>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- )
+ );
}
export default Routes
diff --git a/package-lock.json b/package-lock.json
index f1ff13b..e17b739 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,5 +1,5 @@
{
- "name": "whaticket",
+ "name": "projeto-hit",
"lockfileVersion": 2,
"requires": true,
"packages": {