Compare commits
2 Commits
bfae2956a5
...
42073cc821
Author | SHA1 | Date |
---|---|---|
adriano | 42073cc821 | |
adriano | c9750222c0 |
|
@ -264,7 +264,8 @@ export const remoteTicketCreation = async (
|
||||||
whatsappId,
|
whatsappId,
|
||||||
0,
|
0,
|
||||||
undefined,
|
undefined,
|
||||||
queueId
|
queueId,
|
||||||
|
true
|
||||||
);
|
);
|
||||||
botSendMessage(ticket, `${msg}`);
|
botSendMessage(ticket, `${msg}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { QueryInterface, DataTypes } from "sequelize";
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
up: (queryInterface: QueryInterface) => {
|
||||||
|
return queryInterface.addColumn("Tickets", "isRemote", {
|
||||||
|
type: DataTypes.BOOLEAN,
|
||||||
|
allowNull: true,
|
||||||
|
defaultValue: false
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
down: (queryInterface: QueryInterface) => {
|
||||||
|
return queryInterface.removeColumn("Tickets", "isRemote");
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,22 +0,0 @@
|
||||||
import { QueryInterface } from "sequelize";
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
up: (queryInterface: QueryInterface) => {
|
|
||||||
return queryInterface.bulkInsert(
|
|
||||||
"Settings",
|
|
||||||
[
|
|
||||||
{
|
|
||||||
key: "filterMediasByType",
|
|
||||||
value: "disabled",
|
|
||||||
createdAt: new Date(),
|
|
||||||
updatedAt: new Date()
|
|
||||||
}
|
|
||||||
],
|
|
||||||
{}
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
down: (queryInterface: QueryInterface) => {
|
|
||||||
return queryInterface.bulkDelete("Settings", {});
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -5,10 +5,11 @@ export default function quickAnswearByQueueFiltered(
|
||||||
quickAnswers: QuickAnswer[]
|
quickAnswers: QuickAnswer[]
|
||||||
) {
|
) {
|
||||||
let auxQuickAnswear = [];
|
let auxQuickAnswear = [];
|
||||||
|
let repet: any[] = [];
|
||||||
const userQueues = queueIds.map((uq: any) => uq.queueId);
|
const userQueues = queueIds.map((uq: any) => uq.queueId);
|
||||||
|
|
||||||
for (const quickAnswer of quickAnswers) {
|
for (const quickAnswer of quickAnswers) {
|
||||||
const { queues } = quickAnswer;
|
const { queues, id } = quickAnswer;
|
||||||
|
|
||||||
if (queues.length == 0) {
|
if (queues.length == 0) {
|
||||||
auxQuickAnswear.push(quickAnswer);
|
auxQuickAnswear.push(quickAnswer);
|
||||||
|
@ -17,7 +18,10 @@ export default function quickAnswearByQueueFiltered(
|
||||||
|
|
||||||
for (const q of queues) {
|
for (const q of queues) {
|
||||||
if (userQueues.includes(q.id)) {
|
if (userQueues.includes(q.id)) {
|
||||||
auxQuickAnswear.push(quickAnswer);
|
if (repet.includes(id)) continue;
|
||||||
|
repet.push(id);
|
||||||
|
|
||||||
|
auxQuickAnswear.push(quickAnswer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,10 @@ class Ticket extends Model<Ticket> {
|
||||||
@Column
|
@Column
|
||||||
isGroup: boolean;
|
isGroup: boolean;
|
||||||
|
|
||||||
|
@Default(false)
|
||||||
|
@Column
|
||||||
|
isRemote: boolean;
|
||||||
|
|
||||||
@ForeignKey(() => StatusChatEnd)
|
@ForeignKey(() => StatusChatEnd)
|
||||||
@Column
|
@Column
|
||||||
statusChatEndId: number;
|
statusChatEndId: number;
|
||||||
|
|
|
@ -14,7 +14,8 @@ const FindOrCreateTicketService = async (
|
||||||
whatsappId: number,
|
whatsappId: number,
|
||||||
unreadMessages: number,
|
unreadMessages: number,
|
||||||
groupContact?: Contact,
|
groupContact?: Contact,
|
||||||
queueId?: number | string
|
queueId?: number | string,
|
||||||
|
isRemote?: boolean
|
||||||
): Promise<Ticket> => {
|
): Promise<Ticket> => {
|
||||||
try {
|
try {
|
||||||
let ticket;
|
let ticket;
|
||||||
|
@ -106,7 +107,8 @@ const FindOrCreateTicketService = async (
|
||||||
queueId,
|
queueId,
|
||||||
unreadMessages,
|
unreadMessages,
|
||||||
whatsappId,
|
whatsappId,
|
||||||
phoneNumberId
|
phoneNumberId,
|
||||||
|
isRemote
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ interface TicketData {
|
||||||
statusChatEndId?: number;
|
statusChatEndId?: number;
|
||||||
unreadMessages?: number;
|
unreadMessages?: number;
|
||||||
whatsappId?: string | number;
|
whatsappId?: string | number;
|
||||||
|
isRemote?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Request {
|
interface Request {
|
||||||
|
@ -48,7 +49,8 @@ const UpdateTicketService = async ({
|
||||||
statusChatEnd,
|
statusChatEnd,
|
||||||
unreadMessages,
|
unreadMessages,
|
||||||
statusChatEndId,
|
statusChatEndId,
|
||||||
whatsappId
|
whatsappId,
|
||||||
|
isRemote
|
||||||
} = ticketData;
|
} = ticketData;
|
||||||
|
|
||||||
const ticket = await ShowTicketService(ticketId);
|
const ticket = await ShowTicketService(ticketId);
|
||||||
|
@ -68,7 +70,7 @@ const UpdateTicketService = async ({
|
||||||
if (oldStatus === "closed") {
|
if (oldStatus === "closed") {
|
||||||
await CheckContactOpenTickets(ticket.contact.id, ticket.whatsappId);
|
await CheckContactOpenTickets(ticket.contact.id, ticket.whatsappId);
|
||||||
}
|
}
|
||||||
|
|
||||||
await ticket.update({
|
await ticket.update({
|
||||||
status,
|
status,
|
||||||
queueId,
|
queueId,
|
||||||
|
@ -76,7 +78,8 @@ const UpdateTicketService = async ({
|
||||||
unreadMessages,
|
unreadMessages,
|
||||||
statusChatEnd,
|
statusChatEnd,
|
||||||
statusChatEndId,
|
statusChatEndId,
|
||||||
whatsappId
|
whatsappId,
|
||||||
|
isRemote
|
||||||
});
|
});
|
||||||
|
|
||||||
await ticket.reload();
|
await ticket.reload();
|
||||||
|
|
|
@ -70,11 +70,10 @@ const PositionModal = ({
|
||||||
}
|
}
|
||||||
|
|
||||||
const [position, setPosition] = useState(initialState)
|
const [position, setPosition] = useState(initialState)
|
||||||
const [selectedQueueIds, setSelectedQueueIds] = useState([])
|
// const [selectedQueueIds, setSelectedQueueIds] = useState([])
|
||||||
const { user, setting, getSettingValue } = useContext(AuthContext)
|
const { setting } = useContext(AuthContext)
|
||||||
const [settings, setSettings] = useState(setting)
|
const [settings, setSettings] = useState(setting)
|
||||||
|
|
||||||
// console.log('USER: ', JSON.stringify(user, null, 6))
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -121,11 +120,11 @@ const PositionModal = ({
|
||||||
if (isMounted.current) {
|
if (isMounted.current) {
|
||||||
setPosition(data)
|
setPosition(data)
|
||||||
|
|
||||||
if (data?.queues) {
|
// if (data?.queues) {
|
||||||
console.log('data.queues: ', data.queues)
|
// console.log('data.queues: ', data.queues)
|
||||||
const quickQueueIds = data.queues?.map((queue) => queue.id)
|
// const quickQueueIds = data.queues?.map((queue) => queue.id)
|
||||||
setSelectedQueueIds(quickQueueIds)
|
// setSelectedQueueIds(quickQueueIds)
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toastError(err)
|
toastError(err)
|
||||||
|
@ -203,7 +202,7 @@ const PositionModal = ({
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
{/* <div>
|
||||||
{
|
{
|
||||||
((settings && getSettingValue('quickAnswerByQueue') === 'enabled')) && (
|
((settings && getSettingValue('quickAnswerByQueue') === 'enabled')) && (
|
||||||
<QueueSelect
|
<QueueSelect
|
||||||
|
@ -215,7 +214,7 @@ const PositionModal = ({
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
</div>
|
</div> */}
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button
|
<Button
|
||||||
|
|
|
@ -79,9 +79,7 @@ const QuickAnswersModal = ({
|
||||||
const [quickAnswer, setQuickAnswer] = useState(initialState)
|
const [quickAnswer, setQuickAnswer] = useState(initialState)
|
||||||
const [selectedQueueIds, setSelectedQueueIds] = useState([])
|
const [selectedQueueIds, setSelectedQueueIds] = useState([])
|
||||||
const { user, setting, getSettingValue } = useContext(AuthContext)
|
const { user, setting, getSettingValue } = useContext(AuthContext)
|
||||||
const [settings, setSettings] = useState(setting)
|
const [settings, setSettings] = useState(setting)
|
||||||
|
|
||||||
// console.log('USER: ', JSON.stringify(user, null, 6))
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
|
@ -93,6 +91,14 @@ const QuickAnswersModal = ({
|
||||||
setSettings(setting)
|
setSettings(setting)
|
||||||
}, [setting])
|
}, [setting])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
|
||||||
|
setSelectedQueueIds([])
|
||||||
|
if (open && selectedQueueIds.length === 0 && !quickAnswerId) {
|
||||||
|
setSelectedQueueIds(user.queues.map(q => q.id))
|
||||||
|
}
|
||||||
|
|
||||||
|
}, [open,])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||||
|
@ -113,7 +119,10 @@ const QuickAnswersModal = ({
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
|
// setSelectedQueueIds([])
|
||||||
|
|
||||||
const fetchQuickAnswer = async () => {
|
const fetchQuickAnswer = async () => {
|
||||||
if (initialValues) {
|
if (initialValues) {
|
||||||
setQuickAnswer((prevState) => {
|
setQuickAnswer((prevState) => {
|
||||||
|
@ -121,15 +130,16 @@ const QuickAnswersModal = ({
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!quickAnswerId) return
|
if (!quickAnswerId) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { data } = await api.get(`/quickAnswers/${quickAnswerId}`)
|
const { data } = await api.get(`/quickAnswers/${quickAnswerId}`)
|
||||||
if (isMounted.current) {
|
if (isMounted.current) {
|
||||||
setQuickAnswer(data)
|
setQuickAnswer(data)
|
||||||
|
|
||||||
if (data?.queues) {
|
if (data?.queues) {
|
||||||
console.log('data.queues: ', data.queues)
|
|
||||||
const quickQueueIds = data.queues?.map((queue) => queue.id)
|
const quickQueueIds = data.queues?.map((queue) => queue.id)
|
||||||
setSelectedQueueIds(quickQueueIds)
|
setSelectedQueueIds(quickQueueIds)
|
||||||
}
|
}
|
||||||
|
@ -230,7 +240,7 @@ const QuickAnswersModal = ({
|
||||||
((settings && getSettingValue('quickAnswerByQueue') === 'enabled')) && (
|
((settings && getSettingValue('quickAnswerByQueue') === 'enabled')) && (
|
||||||
<QueueSelect
|
<QueueSelect
|
||||||
selectedQueueIds={selectedQueueIds}
|
selectedQueueIds={selectedQueueIds}
|
||||||
onChange={(selectedIds) => {
|
onChange={(selectedIds) => {
|
||||||
return setSelectedQueueIds(selectedIds)
|
return setSelectedQueueIds(selectedIds)
|
||||||
}}
|
}}
|
||||||
_queues={user.queues}
|
_queues={user.queues}
|
||||||
|
|
|
@ -246,7 +246,17 @@ const TicketListItem = ({ ticket }) => {
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onClick={e => handleAcepptTicket(ticket.id)}
|
onClick={e => handleAcepptTicket(ticket.id)}
|
||||||
>
|
>
|
||||||
{i18n.t("ticketsList.buttons.accept")}
|
{/* {i18n.t("ticketsList.buttons.accept")} */}
|
||||||
|
<>
|
||||||
|
{/* {i18n.t("ticketsList.buttons.accept")}<br />CAMPANHA */}
|
||||||
|
|
||||||
|
{ticket?.isRemote ? (
|
||||||
|
<>{i18n.t("ticketsList.buttons.accept")}<br />CAMPANHA</>
|
||||||
|
) : (
|
||||||
|
<>{i18n.t("ticketsList.buttons.accept")}</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
</>
|
||||||
</ButtonWithSpinner>
|
</ButtonWithSpinner>
|
||||||
)}
|
)}
|
||||||
</ListItem>
|
</ListItem>
|
||||||
|
|
Loading…
Reference in New Issue