import { useCallback } from "react"; import type { MetaFunction } from "@remix-run/node"; import { useParams } from "@remix-run/react"; import { IoCall } from "react-icons/io5"; import { getSeoMeta } from "~/utils/seo"; import { usePhoneNumber, usePressDigit } from "~/features/keypad/hooks/atoms"; import useDevice from "~/features/phone-calls/hooks/use-device"; import useMakeCall from "~/features/phone-calls/hooks/use-make-call"; import Keypad from "~/features/keypad/components/keypad"; export const meta: MetaFunction = ({ params }) => { const recipient = decodeURIComponent(params.recipient ?? ""); return { ...getSeoMeta({ title: `Calling ${recipient}`, }), }; }; export default function OutgoingCallPage() { const params = useParams<{ recipient: string }>(); const recipient = decodeURIComponent(params.recipient ?? ""); const [phoneNumber, setPhoneNumber] = usePhoneNumber(); const onHangUp = useCallback(() => setPhoneNumber(""), [setPhoneNumber]); const call = useMakeCall({ recipient, onHangUp }); const { isDeviceReady } = useDevice(); const pressDigit = usePressDigit(); const onDigitPressProps = useCallback( (digit: string) => ({ onPress() { pressDigit(digit); call.sendDigits(digit); }, }), [call, pressDigit], ); return (