fix: Resolve duplicated quick responses bug and remove queue selection field on position page
parent
c9750222c0
commit
42073cc821
|
@ -5,10 +5,11 @@ export default function quickAnswearByQueueFiltered(
|
|||
quickAnswers: QuickAnswer[]
|
||||
) {
|
||||
let auxQuickAnswear = [];
|
||||
let repet: any[] = [];
|
||||
const userQueues = queueIds.map((uq: any) => uq.queueId);
|
||||
|
||||
for (const quickAnswer of quickAnswers) {
|
||||
const { queues } = quickAnswer;
|
||||
const { queues, id } = quickAnswer;
|
||||
|
||||
if (queues.length == 0) {
|
||||
auxQuickAnswear.push(quickAnswer);
|
||||
|
@ -17,7 +18,10 @@ export default function quickAnswearByQueueFiltered(
|
|||
|
||||
for (const q of queues) {
|
||||
if (userQueues.includes(q.id)) {
|
||||
auxQuickAnswear.push(quickAnswer);
|
||||
if (repet.includes(id)) continue;
|
||||
repet.push(id);
|
||||
|
||||
auxQuickAnswear.push(quickAnswer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,11 +70,10 @@ const PositionModal = ({
|
|||
}
|
||||
|
||||
const [position, setPosition] = useState(initialState)
|
||||
const [selectedQueueIds, setSelectedQueueIds] = useState([])
|
||||
const { user, setting, getSettingValue } = useContext(AuthContext)
|
||||
// const [selectedQueueIds, setSelectedQueueIds] = useState([])
|
||||
const { setting } = useContext(AuthContext)
|
||||
const [settings, setSettings] = useState(setting)
|
||||
|
||||
// console.log('USER: ', JSON.stringify(user, null, 6))
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
|
@ -121,11 +120,11 @@ const PositionModal = ({
|
|||
if (isMounted.current) {
|
||||
setPosition(data)
|
||||
|
||||
if (data?.queues) {
|
||||
console.log('data.queues: ', data.queues)
|
||||
const quickQueueIds = data.queues?.map((queue) => queue.id)
|
||||
setSelectedQueueIds(quickQueueIds)
|
||||
}
|
||||
// if (data?.queues) {
|
||||
// console.log('data.queues: ', data.queues)
|
||||
// const quickQueueIds = data.queues?.map((queue) => queue.id)
|
||||
// setSelectedQueueIds(quickQueueIds)
|
||||
// }
|
||||
}
|
||||
} catch (err) {
|
||||
toastError(err)
|
||||
|
@ -203,7 +202,7 @@ const PositionModal = ({
|
|||
fullWidth
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
{/* <div>
|
||||
{
|
||||
((settings && getSettingValue('quickAnswerByQueue') === 'enabled')) && (
|
||||
<QueueSelect
|
||||
|
@ -215,7 +214,7 @@ const PositionModal = ({
|
|||
/>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
</div> */}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button
|
||||
|
|
|
@ -79,9 +79,7 @@ const QuickAnswersModal = ({
|
|||
const [quickAnswer, setQuickAnswer] = useState(initialState)
|
||||
const [selectedQueueIds, setSelectedQueueIds] = useState([])
|
||||
const { user, setting, getSettingValue } = useContext(AuthContext)
|
||||
const [settings, setSettings] = useState(setting)
|
||||
|
||||
// console.log('USER: ', JSON.stringify(user, null, 6))
|
||||
const [settings, setSettings] = useState(setting)
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
|
@ -93,6 +91,14 @@ const QuickAnswersModal = ({
|
|||
setSettings(setting)
|
||||
}, [setting])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
setSelectedQueueIds([])
|
||||
if (open && selectedQueueIds.length === 0 && !quickAnswerId) {
|
||||
setSelectedQueueIds(user.queues.map(q => q.id))
|
||||
}
|
||||
|
||||
}, [open,])
|
||||
|
||||
useEffect(() => {
|
||||
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
|
||||
|
@ -113,7 +119,10 @@ const QuickAnswersModal = ({
|
|||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
useEffect(() => {
|
||||
|
||||
// setSelectedQueueIds([])
|
||||
|
||||
const fetchQuickAnswer = async () => {
|
||||
if (initialValues) {
|
||||
setQuickAnswer((prevState) => {
|
||||
|
@ -121,15 +130,16 @@ const QuickAnswersModal = ({
|
|||
})
|
||||
}
|
||||
|
||||
if (!quickAnswerId) return
|
||||
if (!quickAnswerId) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const { data } = await api.get(`/quickAnswers/${quickAnswerId}`)
|
||||
if (isMounted.current) {
|
||||
setQuickAnswer(data)
|
||||
|
||||
if (data?.queues) {
|
||||
console.log('data.queues: ', data.queues)
|
||||
if (data?.queues) {
|
||||
const quickQueueIds = data.queues?.map((queue) => queue.id)
|
||||
setSelectedQueueIds(quickQueueIds)
|
||||
}
|
||||
|
@ -230,7 +240,7 @@ const QuickAnswersModal = ({
|
|||
((settings && getSettingValue('quickAnswerByQueue') === 'enabled')) && (
|
||||
<QueueSelect
|
||||
selectedQueueIds={selectedQueueIds}
|
||||
onChange={(selectedIds) => {
|
||||
onChange={(selectedIds) => {
|
||||
return setSelectedQueueIds(selectedIds)
|
||||
}}
|
||||
_queues={user.queues}
|
||||
|
|
Loading…
Reference in New Issue