Novas alterações para possibilitar abrir links

adriano 2023-06-13 16:21:08 -03:00
parent 9f2d574251
commit e88bd10244
5 changed files with 39 additions and 24 deletions

View File

@ -20,7 +20,10 @@ const ListMessagesService = async ({
ticketId ticketId
}: Request): Promise<Response> => { }: Request): Promise<Response> => {
if ((ticketId && ticketId.length > 9) || !ticketId || (ticketId && ticketId === 'undefined')) {
const regex = /^[0-9\b]+$/; // Regular expression to match only numbers
if ((ticketId && ticketId.length > 9) || !ticketId || !ticketId.match(regex)) {
return { return {
messages: [], messages: [],
ticket: new Ticket, ticket: new Ticket,

View File

@ -73,7 +73,13 @@ const CreateTicketService = async ({
} }
if (msg.length > 0) { if (msg.length > 0) {
setTimeout(async () => {
sendWhatsAppMessageSocket(ticket, msg) sendWhatsAppMessageSocket(ticket, msg)
}, 3000)
} }

View File

@ -117,7 +117,7 @@ const Ticket = () => {
useEffect(() => { useEffect(() => {
const regex = /^[0-9\b]+$/; // Regular expression to match only numbers const regex = /^[0-9\b]+$/; // Regular expression to match only numbers
if (ticketId && !ticketId.match(regex) || ticketId && ticketId.length > 9 || !ticketId) return if ((ticketId && !ticketId.match(regex)) || (ticketId && ticketId.length > 9) || (!ticketId)) return
const socket = openSocket(process.env.REACT_APP_BACKEND_URL); const socket = openSocket(process.env.REACT_APP_BACKEND_URL);

View File

@ -12,7 +12,7 @@ import ContactDrawer from "../../../components/ContactDrawer";
import MessageInput from "../../../components/MessageInput"; import MessageInput from "../../../components/MessageInput";
import TicketHeader from "../../../components/TicketHeader"; import TicketHeader from "../../../components/TicketHeader";
import TicketInfo from "../../../components/TicketInfo"; import TicketInfo from "../../../components/TicketInfo";
import TicketActionButtons from "../../../components/TicketActionButtons"; // import TicketActionButtons from "../../../components/TicketActionButtons";
import MessagesList from "../../../components/MessagesList"; import MessagesList from "../../../components/MessagesList";
import api from "../../../services/api"; import api from "../../../services/api";
import { ReplyMessageProvider } from "../../../context/ReplyingMessage/ReplyingMessageContext"; import { ReplyMessageProvider } from "../../../context/ReplyingMessage/ReplyingMessageContext";
@ -89,7 +89,7 @@ const Ticket = () => {
const [contact, setContact] = useState({}); const [contact, setContact] = useState({});
const [ticket, setTicket] = useState({}); const [ticket, setTicket] = useState({});
const [statusChatEnd, setStatusChatEnd] = useState({}) // const [statusChatEnd, setStatusChatEnd] = useState({})
useEffect(() => { useEffect(() => {
setLoading(true); setLoading(true);
@ -105,6 +105,10 @@ const Ticket = () => {
link = window.location.href link = window.location.href
console.log('>>>>>>>>>>>>>>>>>>>>> link: ', link )
// alert('LINK: '+link)
if (link.includes('/https://wa.me/')) { if (link.includes('/https://wa.me/')) {
link = window.location.href.split('/https://wa.me/') link = window.location.href.split('/https://wa.me/')
@ -112,7 +116,8 @@ const Ticket = () => {
number = link[1].split('?text=')[0] number = link[1].split('?text=')[0]
msg = link[1].split('?text=')[1] || '' msg = link[1].split('?text=')[1] || ''
} }
else if (link.includes('https://web.whatsapp.com/send/?phone')) { else if (link.includes('https://web.whatsapp.com/send/?phone') ||
link.includes('https://web.whatsapp.com/send?phone')) {
let aux = link.split('?phone=') let aux = link.split('?phone=')
@ -183,7 +188,7 @@ const Ticket = () => {
useEffect(() => { useEffect(() => {
const regex = /^[0-9\b]+$/; // Regular expression to match only numbers const regex = /^[0-9\b]+$/; // Regular expression to match only numbers
if (ticketId && !ticketId.match(regex) || ticketId && ticketId.length > 9 || !ticketId) return if ( (ticketId && !ticketId.match(regex)) || (ticketId && ticketId.length > 9) || !ticketId) return
const socket = openSocket(process.env.REACT_APP_BACKEND_URL); const socket = openSocket(process.env.REACT_APP_BACKEND_URL);
@ -241,9 +246,9 @@ const Ticket = () => {
onClick={handleDrawerOpen} onClick={handleDrawerOpen}
/> />
</div> </div>
<div className={classes.ticketActionButtons}> {/* <div className={classes.ticketActionButtons}>
<TicketActionButtons ticket={ticket} statusChatEnd={statusChatEnd} /> <TicketActionButtons ticket={ticket} statusChatEnd={statusChatEnd} />
</div> </div> */}
</TicketHeader> </TicketHeader>
<ReplyMessageProvider> <ReplyMessageProvider>
<MessagesList <MessagesList

View File

@ -37,7 +37,8 @@ const Routes = () => {
<Route exact path="/tickets/:ticketId?" component={Tickets} isPrivate /> <Route exact path="/tickets/:ticketId?" component={Tickets} isPrivate />
<Route exact path="/tickets/https://wa.me/:ticketId?" component={WhatsLink} isPrivate /> <Route exact path="/tickets/https://wa.me/:ticketId?" component={WhatsLink} isPrivate />
<Route exact path="/tickets/https://web.whatsapp.com/send/:ticketId?" component={WhatsLink} isPrivate /> {/* <Route exact path="/tickets/https://web.whatsapp.com/send/:ticketId?" component={WhatsLink} isPrivate /> */}
<Route exact path="/tickets/https://web.whatsapp.com/:ticketId?" component={WhatsLink} isPrivate />
<Route exact path="/connections" component={Connections} isPrivate /> <Route exact path="/connections" component={Connections} isPrivate />