54 lines · 1.3 KB · TypeScript
RawDownload
import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router"; import {  HostedPairingRouteSurface,  PairingPendingSurface,  PairingRouteSurface,} from "../components/auth/PairingRouteSurface"; export const Route = createFileRoute("/pair")({  beforeLoad: async ({ context }) => {    const { authGateState } = context;    if (authGateState.status === "hosted-pairing") {      return {        authGateState,      };    }     if (authGateState.status === "authenticated" || authGateState.status === "hosted-static") {      throw redirect({ to: "/", replace: true });    }    return {      authGateState,    };  },  component: PairRouteView,  pendingComponent: PairRoutePendingView,}); function PairRouteView() {  const { authGateState } = Route.useRouteContext();  const navigate = useNavigate();   if (!authGateState) {    return null;  }   if (authGateState.status === "hosted-pairing") {    return <HostedPairingRouteSurface />;  }   return (    <PairingRouteSurface      auth={authGateState.auth}      onAuthenticated={() => {        void navigate({ to: "/", replace: true });      }}      {...(authGateState.errorMessage ? { initialErrorMessage: authGateState.errorMessage } : {})}    />  );} function PairRoutePendingView() {  return <PairingPendingSurface />;}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t