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 { IoCall } from "react-icons/io5"; 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 recipient = decodeURIComponent(router.params.recipient); const onHangUp = useCallback(() => setPhoneNumber(""), [setPhoneNumber]); const call = useMakeCall({ recipient, onHangUp }); const { isDeviceReady } = useDevice(); const pressDigit = useAtom(pressDigitAtom)[1]; const onDigitPressProps = useCallback( (digit: string) => ({ onPress() { pressDigit(digit); call.sendDigits(digit); }, }), [call, pressDigit], ); useEffect(() => { if (isDeviceReady) { call.makeCall(); } }, [call, 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!