import { useActionData, useCatch, useLoaderData, useTransition } from "@remix-run/react"; import Button from "../button"; import SettingsSection from "../settings-section"; import Alert from "~/features/core/components/alert"; import useSession from "~/features/core/hooks/use-session"; import { PhoneSettingsLoaderData } from "~/routes/__app/settings/phone"; export default function PhoneNumberForm() { const transition = useTransition(); const actionData = useActionData(); const { currentOrganization } = useSession(); const isSubmitting = transition.state === "submitting"; const isSuccess = actionData?.submitted === true; const error = actionData?.error; const isError = !!error; const hasFilledTwilioCredentials = Boolean(currentOrganization.twilioAccountSid) const availablePhoneNumbers = useLoaderData().phoneNumbers; const onSubmit = async () => { // await setPhoneNumberMutation({ phoneNumberSid }); // TODO }; if (!hasFilledTwilioCredentials) { return null; } return (
} > {isError ? (
) : null} {isSuccess ? (
) : null}
); } export function CatchBoundary() { const caught = useCatch(); return (

We failed to fetch your Twilio phone numbers. Make sure both your SID and your auth token are valid and that your Twilio account isn't suspended. {caught.data ? Related Twilio docs : null}

} /> ); }