Skip to content

Commit

Permalink
fix: error when only CA country (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
embbnux authored Oct 30, 2024
1 parent aa40cea commit 3abbcdd
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
34 changes: 33 additions & 1 deletion src/modules/EvCall/index.ts
Original file line number Diff line number Diff line change
@@ -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: [],
})
Expand All @@ -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 };
28 changes: 28 additions & 0 deletions src/modules/EvManualDialSettingsUI/index.ts
Original file line number Diff line number Diff line change
@@ -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 };
2 changes: 1 addition & 1 deletion src/modules/Phone/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand Down

0 comments on commit 3abbcdd

Please sign in to comment.