Skip to content

Commit

Permalink
support carrier dtmf type selection (#465)
Browse files Browse the repository at this point in the history
* support carrier dtmf type selection

* fix review comments
  • Loading branch information
xquanluu authored Nov 27, 2024
1 parent 294b7b2 commit 8d4ffdd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
5 changes: 5 additions & 0 deletions src/api/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,11 @@ export const USER_SCOPE_SELECTION: SelectorOptions[] = [
{ name: "Account", value: "account" },
];

export const DTMF_TYPE_SELECTION: SelectorOptions[] = [
{ name: "RFC 2833", value: "rfc2833" },
{ name: "Tones", value: "tones" },
];

/** Available webhook methods */
export const WEBHOOK_METHODS: WebhookOption[] = [
{
Expand Down
3 changes: 3 additions & 0 deletions src/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,8 @@ export interface CarrierRegisterStatus {
callId: null | string;
}

export type DtmfType = "rfc2833" | "tones" | "info";

export interface Carrier {
voip_carrier_sid: string;
name: string;
Expand All @@ -477,6 +479,7 @@ export interface Carrier {
smpp_inbound_password: null | string;
smpp_enquire_link_interval: number;
register_status: CarrierRegisterStatus;
dtmf_type: DtmfType;
}

export interface PredefinedCarrier extends Carrier {
Expand Down
46 changes: 35 additions & 11 deletions src/containers/internal/views/carriers/form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
import {
DEFAULT_SIP_GATEWAY,
DEFAULT_SMPP_GATEWAY,
DTMF_TYPE_SELECTION,
FQDN,
FQDN_TOP_LEVEL,
INVALID,
Expand All @@ -29,7 +30,7 @@ import {
TECH_PREFIX_MINLENGTH,
USER_ACCOUNT,
} from "src/api/constants";
import { Icons, Section } from "src/components";
import { Icons, Section, Tooltip } from "src/components";
import {
Checkzone,
Message,
Expand All @@ -52,16 +53,17 @@ import {
isNotBlank,
} from "src/utils";

import type {
Account,
UseApiDataMap,
Carrier,
SipGateway,
SmppGateway,
PredefinedCarrier,
Sbc,
Smpp,
Application,
import {
type Account,
type UseApiDataMap,
type Carrier,
type SipGateway,
type SmppGateway,
type PredefinedCarrier,
type Sbc,
type Smpp,
type Application,
DtmfType,
} from "src/api/types";
import { setAccountFilter, setLocation } from "src/store/localStore";
import { RegisterStatus } from "./register-status";
Expand Down Expand Up @@ -101,6 +103,7 @@ export const CarrierForm = ({
const [e164, setE164] = useState(false);
const [applicationSid, setApplicationSid] = useState("");
const [accountSid, setAccountSid] = useState("");
const [dtmfType, setDtmfType] = useState<DtmfType>("rfc2833");

const [sipRegister, setSipRegister] = useState(false);
const [sipUser, setSipUser] = useState("");
Expand Down Expand Up @@ -216,6 +219,9 @@ export const CarrierForm = ({
if (obj.smpp_inbound_password) {
setSmppInboundPass(obj.smpp_inbound_password);
}
if (obj.dtmf_type) {
setDtmfType(obj.dtmf_type);
}
}
};

Expand Down Expand Up @@ -524,6 +530,7 @@ export const CarrierForm = ({
smpp_password: smppPass.trim() || null,
smpp_inbound_system_id: smppInboundSystemId.trim() || null,
smpp_inbound_password: smppInboundPass.trim() || null,
dtmf_type: dtmfType,
};

if (carrier && carrier.data) {
Expand Down Expand Up @@ -764,6 +771,23 @@ export const CarrierForm = ({
: false
}
/>

<label htmlFor="dtmf_type">
<Tooltip
text={
"RFC 2833 is commonly used on VoIP networks. Do not change unless you are certain this carrier does not support it"
}
>
DTMF type
</Tooltip>
</label>
<Selector
id="dtmf_type"
name="dtmf_type"
value={dtmfType}
options={DTMF_TYPE_SELECTION}
onChange={(e) => setDtmfType(e.target.value as DtmfType)}
/>
{user &&
disableDefaultTrunkRouting(user?.scope) &&
accountSid &&
Expand Down

0 comments on commit 8d4ffdd

Please sign in to comment.