Fix: Ajustadado getAcessUsers que estava buscando para qualquer usuário
This commit is contained in:
parent
9ba7d0fb84
commit
a1811712a1
@ -235,6 +235,8 @@ export function useChat() {
|
||||
const currentUserId = getUserId(currentUser);
|
||||
const currentUserAreas = getUserAreas(currentUser);
|
||||
const isAdminUser = currentUserProfile === 'admin';
|
||||
const canListPresence = ['admin', 'supervisor'].includes(currentUserProfile);
|
||||
const canListAccessUsers = currentUserProfile === 'admin';
|
||||
const { status: whatsappStatus, incomingMessage, clearIncomingMessage } = useWhatsappSocket();
|
||||
const [contacts, setContacts] = useState([]);
|
||||
const [activeContactId, setActiveContactId] = useState('');
|
||||
@ -327,8 +329,8 @@ export function useChat() {
|
||||
try {
|
||||
const [options, users, presences, currentPresence] = await Promise.all([
|
||||
getAccessOptions(),
|
||||
getAccessUsers(),
|
||||
listAgentPresence(),
|
||||
canListAccessUsers ? getAccessUsers() : Promise.resolve([]),
|
||||
canListPresence ? listAgentPresence() : Promise.resolve([]),
|
||||
currentUserId ? getAgentPresence(currentUserId) : Promise.resolve(null),
|
||||
]);
|
||||
if (!isMounted) return;
|
||||
@ -350,7 +352,7 @@ export function useChat() {
|
||||
return () => {
|
||||
isMounted = false;
|
||||
};
|
||||
}, [currentUserId]);
|
||||
}, [canListAccessUsers, canListPresence, currentUserId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!currentUserId) return undefined;
|
||||
@ -359,7 +361,7 @@ export function useChat() {
|
||||
async function refreshPresence() {
|
||||
try {
|
||||
const [presences, currentPresence] = await Promise.all([
|
||||
listAgentPresence(),
|
||||
canListPresence ? listAgentPresence() : Promise.resolve([]),
|
||||
getAgentPresence(currentUserId),
|
||||
]);
|
||||
if (!isMounted) return;
|
||||
@ -376,7 +378,7 @@ export function useChat() {
|
||||
isMounted = false;
|
||||
window.clearInterval(intervalId);
|
||||
};
|
||||
}, [currentUserId]);
|
||||
}, [canListPresence, currentUserId]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isPaused) return undefined;
|
||||
@ -723,7 +725,7 @@ export function useChat() {
|
||||
setPauseSeconds(0);
|
||||
setApiError(null);
|
||||
await loadChats({ showLoading: true, ignorePause: true });
|
||||
const presences = await listAgentPresence();
|
||||
const presences = canListPresence ? await listAgentPresence() : [];
|
||||
setPresenceList(Array.isArray(presences) ? presences : []);
|
||||
} catch (error) {
|
||||
setApiError(error.message);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user