import type { BlitzPage, ErrorFallbackProps, WithRouterProps } from "blitz"; import { ErrorBoundary, Routes, useRouter, withRouter } from "blitz"; import { useCallback, useEffect } from "react"; import type { TwilioError } from "@twilio/voice-sdk"; import { atom, useAtom } from "jotai"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faPhoneAlt as faPhone } from "@fortawesome/pro-solid-svg-icons"; import useRequireOnboarding from "../../../core/hooks/use-require-onboarding"; import useMakeCall from "../../hooks/use-make-call"; import useDevice from "../../hooks/use-device"; import Keypad from "../../components/keypad"; const OutgoingCall: BlitzPage = () => { useRequireOnboarding(); const [phoneNumber, setPhoneNumber] = useAtom(phoneNumberAtom); const router = useRouter(); const { isDeviceReady } = useDevice(); const recipient = decodeURIComponent(router.params.recipient); const onHangUp = useCallback(() => setPhoneNumber(""), [setPhoneNumber]); const call = useMakeCall({ recipient, onHangUp }); const pressDigit = useAtom(pressDigitAtom)[1]; const onDigitPressProps = useCallback( (digit: string) => ({ onPress() { pressDigit(digit); call.sendDigits(digit); }, }), [call, pressDigit], ); useEffect(() => { if (isDeviceReady) { call.makeCall(); } }, [isDeviceReady]); return (
) : null}{error.description} ({error.code}){error.explanation}
We have been automatically notified and we're doing our best to make sure this does not happen again!