Novas alterações para possibilitar abrir links
parent
9f2d574251
commit
e88bd10244
|
@ -18,9 +18,12 @@ interface Response {
|
|||
const ListMessagesService = async ({
|
||||
pageNumber = "1",
|
||||
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 {
|
||||
messages: [],
|
||||
ticket: new Ticket,
|
||||
|
|
|
@ -42,7 +42,7 @@ const CreateTicketService = async ({
|
|||
|
||||
console.log('Create contact service........')
|
||||
|
||||
const defaultWhatsapp = await GetDefaultWhatsApp(userId);
|
||||
const defaultWhatsapp = await GetDefaultWhatsApp(userId);
|
||||
|
||||
const user = await User.findByPk(userId, { raw: true, })
|
||||
console.log('user.profile: ', user?.profile)
|
||||
|
@ -70,10 +70,16 @@ const CreateTicketService = async ({
|
|||
|
||||
if (!ticket) {
|
||||
throw new AppError("ERR_CREATING_TICKET");
|
||||
}
|
||||
|
||||
if (msg.length > 0) {
|
||||
sendWhatsAppMessageSocket(ticket, msg)
|
||||
}
|
||||
|
||||
if (msg.length > 0) {
|
||||
|
||||
setTimeout(async () => {
|
||||
|
||||
sendWhatsAppMessageSocket(ticket, msg)
|
||||
|
||||
}, 3000)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -83,14 +83,14 @@ const Ticket = () => {
|
|||
const [contact, setContact] = useState({});
|
||||
const [ticket, setTicket] = useState({});
|
||||
|
||||
const [statusChatEnd, setStatusChatEnd] = useState({})
|
||||
const [statusChatEnd, setStatusChatEnd] = useState({})
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
const delayDebounceFn = setTimeout(() => {
|
||||
const fetchTicket = async () => {
|
||||
try {
|
||||
|
||||
|
||||
// maria julia
|
||||
|
||||
const { data } = await api.get("/tickets/" + ticketId);
|
||||
|
@ -101,7 +101,7 @@ const Ticket = () => {
|
|||
setContact(data.contact.contact);
|
||||
setTicket(data.contact);
|
||||
|
||||
setStatusChatEnd(data.statusChatEnd)
|
||||
setStatusChatEnd(data.statusChatEnd)
|
||||
|
||||
setLoading(false);
|
||||
} catch (err) {
|
||||
|
@ -115,9 +115,9 @@ const Ticket = () => {
|
|||
}, [ticketId, history]);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
@ -176,7 +176,7 @@ const Ticket = () => {
|
|||
/>
|
||||
</div>
|
||||
<div className={classes.ticketActionButtons}>
|
||||
<TicketActionButtons ticket={ticket} statusChatEnd={statusChatEnd}/>
|
||||
<TicketActionButtons ticket={ticket} statusChatEnd={statusChatEnd} />
|
||||
</div>
|
||||
</TicketHeader>
|
||||
<ReplyMessageProvider>
|
||||
|
|
|
@ -12,7 +12,7 @@ import ContactDrawer from "../../../components/ContactDrawer";
|
|||
import MessageInput from "../../../components/MessageInput";
|
||||
import TicketHeader from "../../../components/TicketHeader";
|
||||
import TicketInfo from "../../../components/TicketInfo";
|
||||
import TicketActionButtons from "../../../components/TicketActionButtons";
|
||||
// import TicketActionButtons from "../../../components/TicketActionButtons";
|
||||
import MessagesList from "../../../components/MessagesList";
|
||||
import api from "../../../services/api";
|
||||
import { ReplyMessageProvider } from "../../../context/ReplyingMessage/ReplyingMessageContext";
|
||||
|
@ -89,7 +89,7 @@ const Ticket = () => {
|
|||
const [contact, setContact] = useState({});
|
||||
const [ticket, setTicket] = useState({});
|
||||
|
||||
const [statusChatEnd, setStatusChatEnd] = useState({})
|
||||
// const [statusChatEnd, setStatusChatEnd] = useState({})
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
|
@ -105,6 +105,10 @@ const Ticket = () => {
|
|||
|
||||
link = window.location.href
|
||||
|
||||
console.log('>>>>>>>>>>>>>>>>>>>>> link: ', link )
|
||||
|
||||
// alert('LINK: '+link)
|
||||
|
||||
if (link.includes('/https://wa.me/')) {
|
||||
|
||||
link = window.location.href.split('/https://wa.me/')
|
||||
|
@ -112,7 +116,8 @@ const Ticket = () => {
|
|||
number = link[1].split('?text=')[0]
|
||||
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=')
|
||||
|
||||
|
@ -127,14 +132,14 @@ const Ticket = () => {
|
|||
msg = msg.split('&type=')[0]
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (msg && msg.trim().length > 0) {
|
||||
msg = decodeURIComponent(msg);
|
||||
}
|
||||
|
||||
console.log('NUMBER: ', number, ' | MESSAGE: ', msg)
|
||||
}
|
||||
|
||||
console.log('NUMBER: ', number, ' | MESSAGE: ', msg)
|
||||
|
||||
const { data: data0 } = await api.get("/contacts/", { params: { searchParam: number, pageNumber: "1" }, });
|
||||
|
||||
if (data0 && data0.contacts.length > 0) {
|
||||
|
@ -183,7 +188,7 @@ const Ticket = () => {
|
|||
useEffect(() => {
|
||||
|
||||
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);
|
||||
|
||||
|
@ -241,9 +246,9 @@ const Ticket = () => {
|
|||
onClick={handleDrawerOpen}
|
||||
/>
|
||||
</div>
|
||||
<div className={classes.ticketActionButtons}>
|
||||
{/* <div className={classes.ticketActionButtons}>
|
||||
<TicketActionButtons ticket={ticket} statusChatEnd={statusChatEnd} />
|
||||
</div>
|
||||
</div> */}
|
||||
</TicketHeader>
|
||||
<ReplyMessageProvider>
|
||||
<MessagesList
|
||||
|
|
|
@ -37,7 +37,8 @@ const Routes = () => {
|
|||
<Route exact path="/tickets/:ticketId?" component={Tickets} 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 />
|
||||
|
|
Loading…
Reference in New Issue