From 3abbcdd33db502db7cfa092aec467243830d283d Mon Sep 17 00:00:00 2001 From: Embbnux Ji Date: Wed, 30 Oct 2024 13:01:59 +0800 Subject: [PATCH] fix: error when only CA country (#116) --- src/modules/EvCall/index.ts | 34 ++++++++++++++++++++- src/modules/EvManualDialSettingsUI/index.ts | 28 +++++++++++++++++ src/modules/Phone/index.ts | 2 +- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 src/modules/EvManualDialSettingsUI/index.ts diff --git a/src/modules/EvCall/index.ts b/src/modules/EvCall/index.ts index 471ba6d..d3552b3 100644 --- a/src/modules/EvCall/index.ts +++ b/src/modules/EvCall/index.ts @@ -1,7 +1,16 @@ import { Module } from '@ringcentral-integration/commons/lib/di'; - +import { + action, +} from '@ringcentral-integration/core'; import { EvCall as BaseEvCall } from '@ringcentral-integration/engage-voice-widgets/modules/EvCall'; +const DEFAULT_OUTBOUND_SETTING = { + dialoutCallerId: '-1', + dialoutQueueId: '-1', + dialoutCountryId: 'USA', + dialoutRingTime: 30, +}; + @Module({ deps: [], }) @@ -11,6 +20,29 @@ class EvCall extends BaseEvCall { const call = this._deps.evCallMonitor.callsMapping[this.activityCallId]; return this.activityCallId && call ? call : null; } + + @action + resetOutBoundDialSetting() { + this.dialoutCallerId = DEFAULT_OUTBOUND_SETTING.dialoutCallerId; + this.dialoutQueueId = DEFAULT_OUTBOUND_SETTING.dialoutQueueId; + this.dialoutCountryId = DEFAULT_OUTBOUND_SETTING.dialoutCountryId; + if ( + this._deps.evAuth.availableCountries.length > 0 && + !this._deps.evAuth.availableCountries.find(c => c.countryId === this.dialoutCountryId) + ) { + this.dialoutCountryId = this._deps.evAuth.availableCountries[0].countryId; + } + + this.dialoutRingTime = DEFAULT_OUTBOUND_SETTING.dialoutRingTime; + const defaultRingTime = parseInt( + this._deps.evAuth.outboundManualDefaultRingtime, + 10, + ); + if (!Number.isNaN(defaultRingTime)) { + this.formGroup.dialoutRingTime = defaultRingTime; + this.dialoutRingTime = defaultRingTime; + } + } } export { EvCall }; diff --git a/src/modules/EvManualDialSettingsUI/index.ts b/src/modules/EvManualDialSettingsUI/index.ts new file mode 100644 index 0000000..ce8122d --- /dev/null +++ b/src/modules/EvManualDialSettingsUI/index.ts @@ -0,0 +1,28 @@ +import { Module } from '@ringcentral-integration/commons/lib/di'; +import { + computed, +} from '@ringcentral-integration/core'; +import { EvManualDialSettingsUI as BaseEvManualDialSettingsUI } from '@ringcentral-integration/engage-voice-widgets/modules/EvManualDialSettingsUI'; + +@Module({ + deps: [], +}) +class EvManualDialSettingsUI extends BaseEvManualDialSettingsUI { + // override to fix country not found issue. + @computed((that: EvManualDialSettingsUI) => [ + that._deps.evAuth.availableCountries, + that._deps.evCall.formGroup.dialoutCountryId, + ]) + get country() { + const find = this._deps.evAuth.availableCountries.find( + (country) => + country.countryId === this._deps.evCall.formGroup.dialoutCountryId, + ); + if (!find) { + return this._deps.evAuth.availableCountries[0]; + } + return find; + } +} + +export { EvManualDialSettingsUI }; diff --git a/src/modules/Phone/index.ts b/src/modules/Phone/index.ts index 9bf8149..5e3478c 100644 --- a/src/modules/Phone/index.ts +++ b/src/modules/Phone/index.ts @@ -12,7 +12,6 @@ import { EvAgentScript } from '@ringcentral-integration/engage-voice-widgets/mod import { EvCallDataSource } from '@ringcentral-integration/engage-voice-widgets/modules/EvCallDataSource'; import { EvCallMonitor } from '@ringcentral-integration/engage-voice-widgets/modules/EvCallMonitor'; import { EvDialerUI } from '@ringcentral-integration/engage-voice-widgets/modules/EvDialerUI'; -import { EvManualDialSettingsUI } from '@ringcentral-integration/engage-voice-widgets/modules/EvManualDialSettingsUI'; import { EvRequeueCall } from '@ringcentral-integration/engage-voice-widgets/modules/EvRequeueCall'; import { EvSettings } from '@ringcentral-integration/engage-voice-widgets/modules/EvSettings'; import { EvSettingsUI } from '@ringcentral-integration/engage-voice-widgets/modules/EvSettingsUI'; @@ -66,6 +65,7 @@ import OAuth from '../OAuth'; import { Adapter } from '../Adapter'; import { ThirdPartyService } from '../ThirdPartyService'; import { EvCall } from '../EvCall'; +import { EvManualDialSettingsUI } from '../EvManualDialSettingsUI'; import { EvCallDisposition } from '../EvCallDisposition'; import { EvActivityCallUI } from '../EvActivityCallUI'; import { EvCallHistoryUI } from '../EvCallHistoryUI';