From eb1962c1f75121fbcc7d615dcf97904ccd532c80 Mon Sep 17 00:00:00 2001 From: Tobi Abiodun Date: Mon, 4 Nov 2024 15:52:29 -0500 Subject: [PATCH] Add ability to disable outbounds using attrs on the portal object (#1284) --- src/components/phone/PhoneOverlay.vue | 4 ++-- src/hooks/useConnectFirst.ts | 31 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/components/phone/PhoneOverlay.vue b/src/components/phone/PhoneOverlay.vue index ab0b3a75d..c557edc77 100644 --- a/src/components/phone/PhoneOverlay.vue +++ b/src/components/phone/PhoneOverlay.vue @@ -486,8 +486,8 @@ const { :calls="callHistory" :table-body-style="{ height: '30rem' }" @row-click=" - ({ mobile }) => { - setManualOutbound(mobile); + ({ phone_number }) => { + setManualOutbound(phone_number); } " > diff --git a/src/hooks/useConnectFirst.ts b/src/hooks/useConnectFirst.ts index 0adc0e745..eec7beee2 100644 --- a/src/hooks/useConnectFirst.ts +++ b/src/hooks/useConnectFirst.ts @@ -241,6 +241,22 @@ export default function useConnectFirst(context: { } async function dialManualOutbound(number: string) { + const portalResponse = await axios.get( + `${import.meta.env.VITE_APP_API_BASE_URL}/portals/current`, + { + headers: { + Authorization: null, + }, + }, + ); + + const portal = portalResponse?.data; + + if (portal?.attr?.disable_outbound_calls) { + $toasted.warning(t('~~Outbound Calls are currently disabled')); + return; + } + await loginPhone(true, 'WORKING'); dialing.value = true; try { @@ -261,6 +277,21 @@ export default function useConnectFirst(context: { } async function dialNextOutbound() { + const portalResponse = await axios.get( + `${import.meta.env.VITE_APP_API_BASE_URL}/portals/current`, + { + headers: { + Authorization: null, + }, + }, + ); + + const portal = portalResponse?.data; + + if (portal?.attr?.disable_outbound_calls) { + throw new Error(t('~~Outbound Calls are currently disabled')); + } + dialing.value = true; try { const outbound = await PhoneOutbound.api().getNextOutbound({