diff --git a/backend/src/controllers/WhatsAppController.ts b/backend/src/controllers/WhatsAppController.ts index b442e79..c6eea35 100644 --- a/backend/src/controllers/WhatsAppController.ts +++ b/backend/src/controllers/WhatsAppController.ts @@ -422,9 +422,11 @@ export const store = async (req: Request, res: Response): Promise => { } else if (!isOfficial) { phoneNumberId = ""; wabaId = ""; - number = ""; + //number = ""; + } + if(!number){ + number = getNumberFromName(name) } - let invalidPhoneName = validatePhoneName(name); if (invalidPhoneName) { @@ -524,9 +526,11 @@ export const update = async ( } else if (!isOfficial) { whatsappData.phoneNumberId = ""; whatsappData.wabaId = ""; - whatsappData.number = ""; + //whatsappData.number = ""; + } + if(!whatsappData?.number){ + whatsappData.number = getNumberFromName(whatsappData.name) } - const { whatsapp, oldDefaultWhatsapp } = await UpdateWhatsAppService({ whatsappData, whatsappId diff --git a/backend/src/helpers/controllByNumber.ts b/backend/src/helpers/controllByNumber.ts index e202f6f..6ffad64 100644 --- a/backend/src/helpers/controllByNumber.ts +++ b/backend/src/helpers/controllByNumber.ts @@ -13,43 +13,44 @@ async function controllByNumber() { let controll: any[] = []; for (const ticket of tickets) { - let match = ticket.match(/"whatsappId":(\d+)/); + let match = ticket?.match(/"whatsappId":(\d+)/); let whatsappId = match ? match[1] : null; const whatsapp = await get({ key: `whatsapp:${whatsappId}` }); - match = whatsapp.match(/"number":"(\d+)"/); + match = whatsapp?.match(/"number":"(\d+)"/); let number = match ? match[1] : null; - match = ticket.match(/"id":(\d+)/); + match = ticket?.match(/"id":(\d+)/); let ticketId = match ? match[1] : null; number = JSON.parse(number); ticketId = JSON.parse(ticketId); - const index = controll.findIndex((c: any) => c.number == number); + const index = controll?.findIndex((c: any) => c.number == number); if (index == -1) { - controll.push({ ticketId, number }); + controll?.push({ ticketId, number }); } } - const ticketIds = controll.map((c: any) => c.ticketId); + const ticketIds = controll?.map((c: any) => c.ticketId); - console.log("=======> ticketIds: ", ticketIds); + //console.log("=======> ticketIds: ", ticketIds); for (const ticketId of ticketIds) { const ticket: any = await Ticket.findByPk(ticketId); + if(ticket){ + const { status } = ticket; - const { status } = ticket; - - if (status == "pending") { - await UpdateTicketService({ - ticketData: { statusChatEnd: uuidv4() }, - ticketId: ticket.id - }); + if (status && status == "pending") { + await UpdateTicketService({ + ticketData: { statusChatEnd: uuidv4() }, + ticketId: ticket.id + }); + } } } diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index db8604a..53b50e2 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -184,12 +184,10 @@ const verifyMediaMessage = async ( phoneNumberId: msg?.phoneNumberId, fromAgent: false }; - if ( - messageData.mediaType === "video" || - (messageData.mediaType === "audio" && - getSettingValue("blockAudioVideoMedia")?.value === "enabled") - ) { - mediaAuthorized = false; + if(getSettingValue('blockAudioVideoMedia')?.value === 'enabled'){ + if( messageData.mediaType === 'video' || messageData.mediaType === 'audio' ){ + mediaAuthorized = false; + } } if (msg?.fromMe) { messageData = { ...messageData, fromAgent: true }; diff --git a/frontend/src/components/ChatEnd/TimerPickerSelect/index.js b/frontend/src/components/ChatEnd/TimerPickerSelect/index.js index b49ccf7..b642246 100644 --- a/frontend/src/components/ChatEnd/TimerPickerSelect/index.js +++ b/frontend/src/components/ChatEnd/TimerPickerSelect/index.js @@ -45,7 +45,7 @@ import { import ptBrLocale from "date-fns/locale/pt-BR"; - +import esLocale from 'date-fns/locale/es'; const ResponsiveTimePickers = (props) => { @@ -63,7 +63,7 @@ const ResponsiveTimePickers = (props) => { - + { }} > {({ values, touched, errors, isSubmitting }) => ( - +
@@ -299,7 +300,7 @@ const ConfigModal = ({ open, onClose, change }) => { { { checked={values.businessTimeEnable} /> } - label={'Ativar/Desativar'} /> + label={i18n.t('configModal.titles.enableDisable')} />
{ { { checked={values.businessTimeEnableSaturday} /> } - label={'Ativar/Desativar'} /> + label={i18n.t('configModal.titles.enableDisable')} />
{
{/* SABADO FIM */}
- + {/* Saturday and Sunday date */}
@@ -430,13 +431,13 @@ const ConfigModal = ({ open, onClose, change }) => { checked={values.enableWeekendMessage} /> } - label={'Ativar/Desativar'} + label={i18n.t('configModal.titles.enableDisable')} />
{ @@ -475,13 +476,13 @@ const ConfigModal = ({ open, onClose, change }) => { checked={values.holidayDateEnable} /> } - label={'Ativar/Desativar'} + label={i18n.t('configModal.titles.enableDisable')} />
{ checked={values.ticketExpirationEnable} /> } - label={'Ativar/Desativar'} + label={i18n.t('configModal.titles.enableDisable')} />
{ size={24} className={classes.buttonProgress} /> - ) : 'Salvar'} + ) : i18n.t('configModal.titles.save')} diff --git a/frontend/src/components/DashboardUser/CardUser.jsx b/frontend/src/components/DashboardUser/CardUser.jsx index eea89d1..bd595dd 100644 --- a/frontend/src/components/DashboardUser/CardUser.jsx +++ b/frontend/src/components/DashboardUser/CardUser.jsx @@ -23,6 +23,8 @@ import CheckCircleIcon from "@material-ui/icons/CheckCircle"; import ErrorIcon from "@material-ui/icons/Error"; import RemoveCircleIcon from "@material-ui/icons/RemoveCircle"; +import { i18n } from "../../translate/i18n"; + const CardUser = ({ classes, usersOnlineInfo, logout }) => { const [search, setSearch] = React.useState(""); @@ -46,14 +48,14 @@ const CardUser = ({ classes, usersOnlineInfo, logout }) => { color="primary" style={{ marginBottom: "16px" }} > - Lista de Usuários + {i18n.t('dashboard.titles.listUser')} { Todos Online Offline - Não entrou + {i18n.t('dashboard.titles.notEnter')} @@ -161,7 +163,7 @@ const CardUser = ({ classes, usersOnlineInfo, logout }) => { {user.sumOnlineTime && user.sumOnlineTime.sum ? user.sumOnlineTime.sum - : "Não entrou Hoje"} + : i18n.t('dashboard.titles.notEnterToday')} diff --git a/frontend/src/components/DashboardUser/TableUser.jsx b/frontend/src/components/DashboardUser/TableUser.jsx index e574d56..899f98f 100644 --- a/frontend/src/components/DashboardUser/TableUser.jsx +++ b/frontend/src/components/DashboardUser/TableUser.jsx @@ -75,7 +75,7 @@ const TableUser = ({ classes, usersOnlineInfo, logout }) => { Todos Online Offline - Não entrou + {i18n.t('dashboard.titles.notEnter')} @@ -221,7 +221,7 @@ const TableUser = ({ classes, usersOnlineInfo, logout }) => {
- {user.sumOnlineTime ? user.sumOnlineTime.sum : "Não entrou"} + {user.sumOnlineTime ? user.sumOnlineTime.sum : i18n.t('dashboard.titles.notEnter')} {user.statusOnline && user.statusOnline.status === "online" ? ( diff --git a/frontend/src/components/MessageInput/index.js b/frontend/src/components/MessageInput/index.js index 9f0b895..f20b25a 100644 --- a/frontend/src/components/MessageInput/index.js +++ b/frontend/src/components/MessageInput/index.js @@ -247,7 +247,7 @@ const MessageInput = ({ ticketStatus, ticketLastMessage, ticketIsRemote }) => { setInputMessage(ticketLastMessage) } else { - setInputMessage("") + //setInputMessage("") } }, [countTicketMsg, ticketIsRemote, ticketLastMessage]) diff --git a/frontend/src/components/ModalUpdateScheduleReminder/DatePicker2/index.js b/frontend/src/components/ModalUpdateScheduleReminder/DatePicker2/index.js index a4e953e..0dd343c 100644 --- a/frontend/src/components/ModalUpdateScheduleReminder/DatePicker2/index.js +++ b/frontend/src/components/ModalUpdateScheduleReminder/DatePicker2/index.js @@ -13,7 +13,7 @@ import { import ptBrLocale from "date-fns/locale/pt-BR"; - +import esLocale from 'date-fns/locale/es'; function formatDateDatePicker(data){ return String(new Date(data).getFullYear())+'-'+ @@ -50,7 +50,7 @@ function ResponsiveDatePickers(props) { return ( - + { - + - + { const dataChat = props.data.map((dt) => { return { - 'fromMe': dt.fromMe ? 'Atendente' : 'Cliente', + 'fromMe': dt.fromMe ? i18n.t('dashboard.titles.attendant') : 'Cliente', 'body': dt.body, 'createdAt': dt.createdAt } diff --git a/frontend/src/components/ReportModal/index.js b/frontend/src/components/ReportModal/index.js index 35c8216..5ae5095 100644 --- a/frontend/src/components/ReportModal/index.js +++ b/frontend/src/components/ReportModal/index.js @@ -11,7 +11,8 @@ import FormControl from '@mui/material/FormControl'; import InputLabel from '@mui/material/InputLabel'; import MenuItem from '@mui/material/MenuItem'; import Select from '@mui/material/Select'; - + +import { i18n } from "../../translate/i18n"; @@ -56,11 +57,11 @@ useEffect(()=>{ open={open} onClose={handleClose} > - Relatórios + {i18n.t('dashboard.titles.dialogTitle')} - Escolha uma opção de relatório abaixo + {i18n.t('dashboard.titles.dialogContentText')} { fullWidth />
-