// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: MIT-0 import { Checkbox, Grid, Input, Select } from "@awsui/components-react"; import React, { FC } from "react"; import "./DtmfComponent.css"; import selections from "./Selections"; import countries from "./Countries"; interface DtmfComponentProps { setDtmfChecked: (value: boolean) => void; setDtmfAction: (value: {}) => void; setDtmfParam: (value: string) => void; dtmf: string; setValid: (dtmf: string, valid: boolean) => void; } const DtmfComponent: FC = (props) => { const [dtmfChecked, setDtmfChecked] = React.useState(false); const [dtmfAction, setDtmfAction] = React.useState({}); const [dtmfParam, setDtmfParam] = React.useState(""); const [externalCountry, setExternalCountry] = React.useState({}); const setExperienceDtmfChecked = (value: boolean) => { setDtmfChecked(value); props.setDtmfChecked(value); }; const setExperienceDtmfAction = (value: {}) => { setDtmfAction(value); props.setDtmfAction(value); }; const setExperienceDtmfParam = (value: string) => { setDtmfParam(value); if (dtmfAction.value !== "external") { props.setDtmfParam(value); } else { props.setDtmfParam(externalCountry.value + ";" + externalCountry.label + value); } }; React.useEffect(() => { if (dtmfChecked) { if ((dtmfAction.value === "transfer" || dtmfAction.value === "external") && dtmfParam !== "") { props.setValid(props.dtmf, true); } } }, [dtmfChecked, dtmfAction, dtmfParam]) console.log(externalCountry); return (
{ setExperienceDtmfChecked(detail.checked); }} checked={dtmfChecked} > DTMF {props.dtmf}

When a customer presses {props.dtmf},

setExperienceDtmfParam(detail.value)} value={dtmfParam} placeholder="Enter a name for the queue" disabled={dtmfAction.value !== "transfer" || !dtmfChecked} />
)} {dtmfAction.value === "external" && (

Using the following number:

setExperienceDtmfParam(detail.value)} value={dtmfParam} placeholder="Enter an external number" disabled={dtmfAction.value !== "external" || !dtmfChecked || !externalCountry.value} />
)} {dtmfAction.value === "hangup" && (

Using the following message:

setExperienceDtmfParam(detail.value)} value={dtmfParam} placeholder="Enter a message" disabled={dtmfAction.value !== "hangup" || !dtmfChecked} />
)}
); }; export default DtmfComponent;